Moved some classes around.

This commit is contained in:
Adam Murdoch
2012-08-04 13:32:41 +10:00
parent a1c46d3dfa
commit e9b300f610
17 changed files with 302 additions and 252 deletions

View File

@@ -0,0 +1,29 @@
package net.rubygrapefruit.platform.internal;
import net.rubygrapefruit.platform.NativeException;
import net.rubygrapefruit.platform.PosixFile;
import net.rubygrapefruit.platform.internal.jni.PosixFileFunctions;
import java.io.File;
public class DefaultPosixFile implements PosixFile {
@Override
public void setMode(File file, int perms) {
FunctionResult result = new FunctionResult();
PosixFileFunctions.chmod(file.getPath(), perms, result);
if (result.isFailed()) {
throw new NativeException(String.format("Could not set UNIX mode on %s: %s", file, result.getMessage()));
}
}
@Override
public int getMode(File file) {
FunctionResult result = new FunctionResult();
FileStat stat = new FileStat();
PosixFileFunctions.stat(file.getPath(), stat, result);
if (result.isFailed()) {
throw new NativeException(String.format("Could not get UNIX mode on %s: %s", file, result.getMessage()));
}
return stat.mode;
}
}