/** {@inheritDoc} */ @Override public FS newInstance() { return new FS_POSIX(this); }
/** {@inheritDoc} */ @Override public boolean setExecute(File f, boolean canExecute) { if (!isFile(f)) return false; if (!canExecute) return f.setExecutable(false, false); try { Path path = FileUtils.toPath(f); Set<PosixFilePermission> pset = Files.getPosixFilePermissions(path); // owner (user) is always allowed to execute. pset.add(PosixFilePermission.OWNER_EXECUTE); int mask = umask(); apply(pset, mask, PosixFilePermission.GROUP_EXECUTE, 1 << 3); apply(pset, mask, PosixFilePermission.OTHERS_EXECUTE, 1); Files.setPosixFilePermissions(path, pset); return true; } catch (IOException e) { // The interface doesn't allow to throw IOException final boolean debug = Boolean.parseBoolean(SystemReader .getInstance().getProperty("jgit.fs.debug")); //$NON-NLS-1$ if (debug) System.err.println(e); return false; } }
/** {@inheritDoc} */ @Override public ProcessResult runHookIfPresent(Repository repository, String hookName, String[] args, PrintStream outRedirect, PrintStream errRedirect, String stdinArgs) throws JGitInternalException { return internalRunHookIfPresent(repository, hookName, args, outRedirect, errRedirect, stdinArgs); }
/** {@inheritDoc} */ @Override protected File discoverGitExe() { String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$ File gitExe = searchPath(path, "git"); //$NON-NLS-1$ if (gitExe == null) { if (SystemReader.getInstance().isMacOS()) { if (searchPath(path, "bash") != null) { //$NON-NLS-1$ // On MacOSX, PATH is shorter when Eclipse is launched from the // Finder than from a terminal. Therefore try to launch bash as a // login shell and search using that. String w; try { w = readPipe(userHome(), new String[]{"bash", "--login", "-c", "which git"}, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ Charset.defaultCharset().name()); } catch (CommandFailedException e) { LOG.warn(e.getMessage()); return null; } if (!StringUtils.isEmptyOrNull(w)) { gitExe = new File(w); } } } } return gitExe; }
private int umask() { int u = umask; if (u == -1) { u = readUmask(); umask = u; } return u; }
/** {@inheritDoc} */ @Override public boolean supportsAtomicCreateNewFile() { if (supportsAtomicCreateNewFile == AtomicFileCreation.UNDEFINED) { determineAtomicFileCreationSupport(); } return supportsAtomicCreateNewFile == AtomicFileCreation.SUPPORTED; }
@Override protected File discoverGitExe() { String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$ File gitExe = searchPath(path, "git"); //$NON-NLS-1$ if (gitExe == null) { if (SystemReader.getInstance().isMacOS()) { if (searchPath(path, "bash") != null) { //$NON-NLS-1$ // On MacOSX, PATH is shorter when Eclipse is launched from the // Finder than from a terminal. Therefore try to launch bash as a // login shell and search using that. String w; try { w = readPipe(userHome(), new String[]{"bash", "--login", "-c", "which git"}, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ Charset.defaultCharset().name()); } catch (CommandFailedException e) { LOG.warn(e.getMessage()); return null; } if (!StringUtils.isEmptyOrNull(w)) { gitExe = new File(w); } } } } return gitExe; }
private int umask() { int u = umask; if (u == -1) { u = readUmask(); umask = u; } return u; }
/** {@inheritDoc} */ @Override public boolean supportsAtomicCreateNewFile() { if (supportsAtomicCreateNewFile == AtomicFileCreation.UNDEFINED) { determineAtomicFileCreationSupport(); } return supportsAtomicCreateNewFile == AtomicFileCreation.SUPPORTED; }
@Override public boolean setExecute(File f, boolean canExecute) { if (!isFile(f)) return false; if (!canExecute) return f.setExecutable(false); try { Path path = f.toPath(); Set<PosixFilePermission> pset = Files.getPosixFilePermissions(path); // owner (user) is always allowed to execute. pset.add(PosixFilePermission.OWNER_EXECUTE); int mask = umask(); apply(pset, mask, PosixFilePermission.GROUP_EXECUTE, 1 << 3); apply(pset, mask, PosixFilePermission.OTHERS_EXECUTE, 1); Files.setPosixFilePermissions(path, pset); return true; } catch (IOException e) { // The interface doesn't allow to throw IOException final boolean debug = Boolean.parseBoolean(SystemReader .getInstance().getProperty("jgit.fs.debug")); //$NON-NLS-1$ if (debug) System.err.println(e); return false; } }
/** {@inheritDoc} */ @Override protected File discoverGitExe() { String path = SystemReader.getInstance().getenv("PATH"); //$NON-NLS-1$ File gitExe = searchPath(path, "git"); //$NON-NLS-1$ if (gitExe == null) { if (SystemReader.getInstance().isMacOS()) { if (searchPath(path, "bash") != null) { //$NON-NLS-1$ // On MacOSX, PATH is shorter when Eclipse is launched from the // Finder than from a terminal. Therefore try to launch bash as a // login shell and search using that. String w; try { w = readPipe(userHome(), new String[]{"bash", "--login", "-c", "which git"}, // //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ Charset.defaultCharset().name()); } catch (CommandFailedException e) { LOG.warn(e.getMessage()); return null; } if (!StringUtils.isEmptyOrNull(w)) { gitExe = new File(w); } } } } return gitExe; }
/** * Detect the file system * * @param cygwinUsed * @return FS instance */ public FS detect(Boolean cygwinUsed) { if (SystemReader.getInstance().isWindows()) { if (cygwinUsed == null) cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin()); if (cygwinUsed.booleanValue()) return new FS_Win32_Cygwin(); else return new FS_Win32(); } else { return new FS_POSIX(); } } }
/** * @since 4.0 */ @Override public ProcessResult runHookIfPresent(Repository repository, String hookName, String[] args, PrintStream outRedirect, PrintStream errRedirect, String stdinArgs) throws JGitInternalException { return internalRunHookIfPresent(repository, hookName, args, outRedirect, errRedirect, stdinArgs); }
private int umask() { int u = umask; if (u == -1) { u = readUmask(); umask = u; } return u; }
/** {@inheritDoc} */ @Override public boolean setExecute(File f, boolean canExecute) { if (!isFile(f)) return false; if (!canExecute) return f.setExecutable(false, false); try { Path path = FileUtils.toPath(f); Set<PosixFilePermission> pset = Files.getPosixFilePermissions(path); // owner (user) is always allowed to execute. pset.add(PosixFilePermission.OWNER_EXECUTE); int mask = umask(); apply(pset, mask, PosixFilePermission.GROUP_EXECUTE, 1 << 3); apply(pset, mask, PosixFilePermission.OTHERS_EXECUTE, 1); Files.setPosixFilePermissions(path, pset); return true; } catch (IOException e) { // The interface doesn't allow to throw IOException final boolean debug = Boolean.parseBoolean(SystemReader .getInstance().getProperty("jgit.fs.debug")); //$NON-NLS-1$ if (debug) System.err.println(e); return false; } }
/** {@inheritDoc} */ @Override public FS newInstance() { return new FS_POSIX(this); }
/** {@inheritDoc} */ @Override public ProcessResult runHookIfPresent(Repository repository, String hookName, String[] args, PrintStream outRedirect, PrintStream errRedirect, String stdinArgs) throws JGitInternalException { return internalRunHookIfPresent(repository, hookName, args, outRedirect, errRedirect, stdinArgs); }
@Override public FS newInstance() { return new FS_POSIX(this); }
/** * Detect the file system * * @param cygwinUsed * @return FS instance */ public FS detect(Boolean cygwinUsed) { if (SystemReader.getInstance().isWindows()) { if (cygwinUsed == null) cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin()); if (cygwinUsed.booleanValue()) return new FS_Win32_Cygwin(); else return new FS_Win32(); } else { return new FS_POSIX(); } } }
/** * Detect the file system * * @param cygwinUsed * @return FS instance */ public FS detect(Boolean cygwinUsed) { if (SystemReader.getInstance().isWindows()) { if (cygwinUsed == null) cygwinUsed = Boolean.valueOf(FS_Win32_Cygwin.isCygwin()); if (cygwinUsed.booleanValue()) return new FS_Win32_Cygwin(); else return new FS_Win32(); } else { return new FS_POSIX(); } } }