public String getcwd() { byte[] cwd = new byte[1024]; long result = libc().getcwd(cwd, 1024); if (result == -1) return null; int len = 0; for (; len < 1024; len++) if (cwd[len] == 0) break; return new String(cwd, 0, len); }
public String getcwd() { byte[] cwd = new byte[1024]; long result = libc().getcwd(cwd, 1024); if (result == -1) return null; int len = 0; for (; len < 1024; len++) if (cwd[len] == 0) break; return new String(cwd, 0, len); }
public String readlink(String oldpath) throws IOException { // TODO: this should not be hardcoded to 256 bytes ByteBuffer buffer = ByteBuffer.allocate(256); int result = libc().readlink(oldpath, buffer, buffer.capacity()); if (result == -1) return null; buffer.position(0); buffer.limit(result); return Charset.forName("ASCII").decode(buffer).toString(); }
public String readlink(String oldpath) throws IOException { // TODO: this should not be hardcoded to 256 bytes ByteBuffer buffer = ByteBuffer.allocate(256); int result = libc().readlink(oldpath, buffer, buffer.capacity()); if (result == -1) return null; buffer.position(0); buffer.limit(result); return Charset.forName("ASCII").decode(buffer).toString(); }
public int lchown(String filename, int user, int group) { try { return libc().lchown(filename, user, group); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public int lchmod(String filename, int mode) { try { return libc().lchmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public int lchown(String filename, int user, int group) { try { return libc().lchown(filename, user, group); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public int lchmod(String filename, int mode) { try { return libc().lchmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
private Pointer nativeSpawnAttributes(Collection<? extends SpawnAttribute> spawnAttributes) { Pointer nativeSpawnAttributes = allocatePosixSpawnattr(); ((UnixLibC) libc()).posix_spawnattr_init(nativeSpawnAttributes); for (SpawnAttribute action : spawnAttributes) { action.set(this, nativeSpawnAttributes); } return nativeSpawnAttributes; }
private Pointer nativeFileActions(Collection<? extends SpawnFileAction> fileActions) { Pointer nativeFileActions = allocatePosixSpawnFileActions(); ((UnixLibC) libc()).posix_spawn_file_actions_init(nativeFileActions); for (SpawnFileAction action : fileActions) { action.act(this, nativeFileActions); } return nativeFileActions; }
public byte[] crypt(byte[] key, byte[] salt) { Pointer ptr = libc().crypt(key, salt); if (ptr == null) return null; int end = ptr.indexOf(0, (byte)0); byte[] bytes = new byte[end + 1]; ptr.get(0, bytes, 0, end); return bytes; }
public int rmdir(String path) { int res = libc().rmdir(path); if (res < 0) handler.error(Errno.valueOf(errno()), "rmdir", path); return res; }
public int rmdir(String path) { int res = libc().rmdir(path); if (res < 0) handler.error(Errno.valueOf(errno()), "rmdir", path); return res; }
public int rmdir(String path) { int res = libc().rmdir(path); if (res < 0) handler.error(Errno.valueOf(errno()), "rmdir", path); return res; }
public int mkdir(String path, int mode) { int res = libc().mkdir(path, mode); if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
public int setrlimit(int resource, long rlimCur, long rlimMax) { RLimit rlim = new DefaultNativeRLimit(getRuntime()); rlim.init(rlimCur, rlimMax); return libc().setrlimit(resource, rlim); }
public int mkdir(String path, int mode) { int res = libc().mkdir(path, mode); if (res < 0) { int errno = errno(); handler.error(Errno.valueOf(errno), "mkdir", path); } return res; }
public int utimes(String path, long[] atimeval, long[] mtimeval) { Timeval[] times = null; if (atimeval != null && mtimeval != null) { times = Struct.arrayOf(getRuntime(), DefaultNativeTimeval.class, 2); times[0].setTime(atimeval); times[1].setTime(mtimeval); } return libc().utimes(path, times); }
public int utimensat(int dirfd, String path, long[] atimespec, long[] mtimespec, int flag) { Timespec[] times = null; if (atimespec != null && mtimespec != null) { times = Struct.arrayOf(getRuntime(), DefaultNativeTimespec.class, 2); times[0].setTime(atimespec); times[1].setTime(mtimespec); } return libc().utimensat(dirfd, path, times, flag); }
public int lutimes(String path, long[] atimeval, long[] mtimeval) { Timeval[] times = null; if (atimeval != null && mtimeval != null) { times = Struct.arrayOf(getRuntime(), DefaultNativeTimeval.class, 2); times[0].setTime(atimeval); times[1].setTime(mtimeval); } return libc().lutimes(path, times); }