Renamed PosixFile to PosixFiles

This commit is contained in:
Adam Murdoch
2013-12-07 08:42:58 +11:00
parent 9c83de44d4
commit 242f3991f3
5 changed files with 135 additions and 137 deletions

View File

@@ -152,7 +152,7 @@ configurations {
def deployer = uploadJni.repositories.mavenDeployer
binaries.withType(SharedLibraryBinary) { binary ->
if (!buildable) {
if (!buildable || targetPlatform.operatingSystem.name == 'linux' && targetPlatform.architecture.name != System.properties['os.arch']) {
return
}

View File

@@ -22,7 +22,7 @@ import java.io.File;
* Functions to query and modify a file's POSIX meta-data.
*/
@ThreadSafe
public interface PosixFile extends NativeIntegration {
public interface PosixFiles extends NativeIntegration {
/**
* Sets the mode for the given file.
*

View File

@@ -17,12 +17,12 @@
package net.rubygrapefruit.platform.internal;
import net.rubygrapefruit.platform.NativeException;
import net.rubygrapefruit.platform.PosixFile;
import net.rubygrapefruit.platform.PosixFiles;
import net.rubygrapefruit.platform.internal.jni.PosixFileFunctions;
import java.io.File;
public class DefaultPosixFile implements PosixFile {
public class DefaultPosixFiles implements PosixFiles {
public void setMode(File file, int perms) {
FunctionResult result = new FunctionResult();
PosixFileFunctions.chmod(file.getPath(), perms, result);
@@ -41,7 +41,6 @@ public class DefaultPosixFile implements PosixFile {
return stat.mode;
}
@Override
public String readLink(File link) throws NativeException {
FunctionResult result = new FunctionResult();
String contents = PosixFileFunctions.readlink(link.getPath(), result);
@@ -51,7 +50,6 @@ public class DefaultPosixFile implements PosixFile {
return contents;
}
@Override
public void symlink(File link, String contents) throws NativeException {
FunctionResult result = new FunctionResult();
PosixFileFunctions.symlink(link.getPath(), contents, result);

View File

@@ -137,8 +137,8 @@ public abstract class Platform {
@Override
public <T extends NativeIntegration> T get(Class<T> type, NativeLibraryLoader nativeLibraryLoader) {
if (type.equals(PosixFile.class)) {
return type.cast(new DefaultPosixFile());
if (type.equals(PosixFiles.class)) {
return type.cast(new DefaultPosixFiles());
}
if (type.equals(Process.class)) {
return type.cast(new WrapperProcess(new DefaultProcess(), false));

View File

@@ -23,13 +23,13 @@ import spock.lang.IgnoreIf
import net.rubygrapefruit.platform.internal.Platform
@IgnoreIf({Platform.current().windows})
class PosixFileTest extends Specification {
class PosixFilesTest extends Specification {
@Rule TemporaryFolder tmpDir
final PosixFile file = Native.get(PosixFile.class)
final PosixFiles file = Native.get(PosixFiles.class)
def "caches file instance"() {
expect:
Native.get(PosixFile.class) == file
Native.get(PosixFiles.class) == file
}
def "can set mode on a file"() {