Skip to content
This repository has been archived by the owner on Mar 22, 2023. It is now read-only.

Commit

Permalink
add cross-platform support
Browse files Browse the repository at this point in the history
  • Loading branch information
uwx committed Feb 1, 2016
1 parent 83097fc commit 85fad17
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
6 changes: 1 addition & 5 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding=".settings/|bin/|data/|libraries/|music/|mystages/|stages/|mycars/" kind="src" path="">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="NFMM/libraries/dlls"/>
</attributes>
</classpathentry>
<classpathentry excluding=".settings/|bin/|data/|libraries/|music/|mystages/|stages/|mycars/|libraries/dlls/win32/|libraries/dlls/win64/" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="libraries/dragshotMod.jar"/>
<classpathentry kind="lib" path="libraries/easyogg.jar"/>
Expand Down
34 changes: 34 additions & 0 deletions RadicalBASS.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.awt.image.BufferedImage;
import java.io.File;
import java.lang.reflect.Field;

import jouvieje.bass.BassInit;
import jouvieje.bass.callbacks.SYNCPROC;
Expand Down Expand Up @@ -85,6 +86,7 @@ public void init() {
* NativeBass Init
*/
try {
BassInit.DEBUG = true;
BassInit.loadLibraries();
} catch (final BassException e) {
printfExit("NativeBass error! %s\n", e.getMessage());
Expand Down Expand Up @@ -251,10 +253,42 @@ private int getIndexColor(final int index) {

public RadicalBASS(final File songFile) {
file = songFile;
System.out.println(System.getProperty("java.library.path"));

try {
if (isUnix) {
System.out.println("running on a unix system");
appendToPath(workingDirectory + "/libraries/dlls/linux" + x64 + "/");
} else if (isMac) {
System.out.println("running on a mac system");
appendToPath(workingDirectory + "/libraries/dlls/mac/");
} else if (isWindows) {
System.out.println("running on a windows system");
appendToPath(workingDirectory + "\\libraries\\dlls\\win" + x64 + "\\");
}
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
}

init();
//run();
}

private static final String os = System.getProperty("os.name").toLowerCase();
private static final String x64 = System.getProperty("sun.arch.data.model").equals("64") ? "64" : "32";
private static final boolean isUnix = os.indexOf("nix") == 0 || os.indexOf("nux") == 0;
private static final boolean isWindows = os.indexOf("win") == 0;
private static final boolean isMac = os.indexOf("mac") == 0;
private static final String workingDirectory = ".";
//private static final String workingDirectory = System.getProperty("user.dir");

private static void appendToPath(final String s) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
System.setProperty( "java.library.path", System.getProperty("java.library.path") + (isWindows ? ";" : ":") + s );

Field fieldSysPath = ClassLoader.class.getDeclaredField( "sys_paths" );
fieldSysPath.setAccessible( true );
fieldSysPath.set( null, null );
}

@Override
public int getType() {
// TODO Auto-generated method stub
Expand Down

0 comments on commit 85fad17

Please sign in to comment.