/** * Change permissions via NIO. */ private static void _chmod(File f, int mask) throws IOException { // TODO WindowsPosix actually does something here (WindowsLibC._wchmod); should we let it? // Anyway the existing calls already skip this method if on Windows. if (File.pathSeparatorChar==';') return; // noop if (Util.NATIVE_CHMOD_MODE) { PosixAPI.jnr().chmod(f.getAbsolutePath(), mask); } else { Files.setPosixFilePermissions(fileToPath(f), Util.modeToPermissions(mask)); } }
public static void setReadOnly(Path absolutePath) { posix.chmod(absolutePath.toFile().toString(), Integer.parseInt("0444", 8)); }
/** * Run chmod via jnr-posix */ private static void _chmod(File f, int mask) throws IOException { // TODO WindowsPosix actually does something here (WindowsLibC._wchmod); should we let it? // Anyway the existing calls already skip this method if on Windows. if (File.pathSeparatorChar==';') return; // noop PosixAPI.jnr().chmod(f.getAbsolutePath(),mask); }
public int chmod(String filename, int mode) { return posix().chmod(filename, mode); }
public int chmod(String filename, int mode) { try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public int chmod(String filename, int mode) { return posix().chmod(filename, mode); }
public int chmod(String filename, int mode) { return posix().chmod(filename, mode); }
public int chmod(String filename, int mode) { try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public int chmod(String filename, int mode) { try { return posix.chmod(filename, mode); } catch (UnsatisfiedLinkError ule) { return unimplementedInt(); } }
public static void setWritable(Path absolutePath) { FileStat s = posix.stat(absolutePath.toFile().toString()); posix.chmod(absolutePath.toFile().toString(), s.mode() | Integer.parseInt("0700", 8)); }
public static void chmod(PyObject path, int mode) { if (os == OS.NT) { try { if (!absolutePath(path).toFile().setWritable((mode & FileStat.S_IWUSR) != 0)) { throw Py.OSError(Errno.EPERM, path); } } catch (SecurityException ex) { throw Py.OSError(Errno.EACCES, path); } } else if (posix.chmod(absolutePath(path).toString(), mode) < 0) { throw errorFromErrno(path); } }
@JRubyMethod(required = 1) public IRubyObject chmod(ThreadContext context, IRubyObject arg) { checkClosed(context); int mode = (int) arg.convertToInteger().getLongValue(); if (!new File(path).exists()) { throw context.runtime.newErrnoENOENTError(path); } return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode)); }
@JRubyMethod(required = 1) public IRubyObject chmod(ThreadContext context, IRubyObject arg) { checkClosed(context); int mode = (int) arg.convertToInteger().getLongValue(); if (!new File(path).exists()) { throw context.runtime.newErrnoENOENTError(path); } return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode)); }
@JRubyMethod(required = 1) public IRubyObject chmod(ThreadContext context, IRubyObject arg) { checkClosed(context); int mode = (int) arg.convertToInteger().getLongValue(); final String path = getPath(); if ( ! new File(path).exists() ) { throw context.runtime.newErrnoENOENTError(path); } return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode)); }
@JRubyMethod(required = 1) public IRubyObject chmod(ThreadContext context, IRubyObject arg) { checkClosed(context); int mode = (int) arg.convertToInteger().getLongValue(); final String path = getPath(); if ( ! new File(path).exists() ) { throw context.runtime.newErrnoENOENTError(path); } return context.runtime.newFixnum(context.runtime.getPosix().chmod(path, mode)); }
public String start() throws Exception { authSocket = createLocalSocketAddress(); address = new UnixSocketAddress(new File(authSocket)); channel = UnixServerSocketChannel.open(); channel.configureBlocking(false); socket = channel.socket(); socket.bind(address); selector = NativeSelectorProvider.getInstance().openSelector(); channel.register(selector, SelectionKey.OP_ACCEPT, new SshAgentServerSocketHandler()); POSIXFactory.getPOSIX().chmod(authSocket, 0600); thread = new Thread(new AgentSocketAcceptor(), "SSH Agent socket acceptor " + authSocket); thread.setDaemon(true); thread.start(); return authSocket; }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (extension.length() > 0) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (extension.length() > 0) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); }
private void initializeOpen(IOOptions ioOptions) { getRuntime().getPosix().chmod(path, 0600); MakeOpenFile(); openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600); }
private void initializeOpen(IOOptions ioOptions) { getRuntime().getPosix().chmod(path, 0600); MakeOpenFile(); openFile.setMode(ioOptions.getModeFlags().getOpenFileFlags()); openFile.setPath(path); sysopenInternal19(path, ioOptions.getModeFlags().getOpenFileFlags(), 0600); }