org.eclipse.jgit.util.FS类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.7k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.eclipse.jgit.util.FS类的一些代码示例,展示了FS类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FS类的具体详情如下:
包路径:org.eclipse.jgit.util.FS
类名称:FS

FS介绍

[英]Abstraction to support various file system operations not in Java.
[中]抽象以支持各种非Java文件系统操作。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private static File getDefaultFile() {
  File home = FS.DETECTED.userHome();
  File netrc = new File(home, ".netrc"); //$NON-NLS-1$
  if (netrc.exists())
    return netrc;
  netrc = new File(home, "_netrc"); //$NON-NLS-1$
  if (netrc.exists())
    return netrc;
  return null;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
   * {@inheritDoc}
   *
   * @since 4.10
   */
  @Override
  protected byte[] readIncludedConfig(String relPath)
      throws ConfigInvalidException {
    final File file;
    if (relPath.startsWith("~/")) { //$NON-NLS-1$
      file = fs.resolve(fs.userHome(), relPath.substring(2));
    } else {
      file = fs.resolve(configFile.getParentFile(), relPath);
    }

    if (!file.exists()) {
      return null;
    }

    try {
      return IO.readFully(file);
    } catch (IOException ioe) {
      throw new ConfigInvalidException(MessageFormat
          .format(JGitText.get().cannotReadFile, relPath), ioe);
    }
  }
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private static String readContentAsNormalizedString(DirCacheEntry entry,
    ObjectReader reader) throws MissingObjectException, IOException {
  ObjectLoader open = reader.open(entry.getObjectId());
  byte[] cachedBytes = open.getCachedBytes();
  return FS.detect().normalize(RawParseUtils.decode(cachedBytes));
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if ((options & SKIP_MISSING) != 0 && !fs.exists(f))
  return;
if ((options & RECURSIVE) != 0 && fs.isDirectory(f)) {
  final File[] items = f.listFiles();
  if (items != null) {
  if ((options & RETRY) != 0 && fs.exists(f)) {
    for (int i = 1; i < 10; i++) {
      try {

代码示例来源:origin: diffplug/spotless

FS fs = FS.detect();
if (globalAttributesPath.startsWith("~/")) { //$NON-NLS-1$
  globalAttributesFile = fs.resolve(fs.userHome(), globalAttributesPath.substring(2));
} else {
  globalAttributesFile = fs.resolve(null, globalAttributesPath);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if (hideDotFiles != HideDotFiles.FALSE && !isBare()
    && getDirectory().getName().startsWith(".")) //$NON-NLS-1$
  getFS().setHidden(getDirectory(), true);
refs.create();
objectDatabase.create();
if (getFS().supportsExecute()) {
  File tmp = File.createTempFile("try", "execute", getDirectory()); //$NON-NLS-1$ //$NON-NLS-2$
  getFS().setExecute(tmp, true);
  final boolean on = getFS().canExecute(tmp);
  getFS().setExecute(tmp, false);
  final boolean off = getFS().canExecute(tmp);
  FileUtils.delete(tmp);
if (getFS().supportsSymlinks()) {
  File tmp = new File(getDirectory(), "tmplink"); //$NON-NLS-1$
  try {
    getFS().createSymLink(tmp, "target"); //$NON-NLS-1$
    symLinks = null;
    FileUtils.delete(tmp);

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

FileUtils.delete(f, FileUtils.RECURSIVE);
  fs.createSymLink(f, target);
  entry.setLength(bytes.length);
  entry.setLastModified(fs.lastModified(f));
  return;
    new FileOutputStream(tmpFile), nonNullEolStreamType);
if (checkoutMetadata.smudgeFilterCommand != null) {
  ProcessBuilder filterProcessBuilder = fs.runInShell(
      checkoutMetadata.smudgeFilterCommand, new String[0]);
  filterProcessBuilder.directory(repo.getWorkTree());
  try {
    result = fs.execute(filterProcessBuilder, ol.openStream());
    rc = result.getRc();
    if (rc == 0) {
if (opt.isFileMode() && fs.supportsExecute()) {
  if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
    if (!fs.canExecute(tmpFile))
      fs.setExecute(tmpFile, true);
  } else {
    if (fs.canExecute(tmpFile))
      fs.setExecute(tmpFile, false);
entry.setLastModified(fs.lastModified(f));

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

FileUtils.delete(f, FileUtils.RECURSIVE);
  fs.createSymLink(f, target);
  entry.setLength(bytes.length);
  entry.setLastModified(fs.lastModified(f));
  return;
if (opt.isFileMode() && fs.supportsExecute()) {
  if (FileMode.EXECUTABLE_FILE.equals(entry.getRawMode())) {
    if (!fs.canExecute(tmpFile))
      fs.setExecute(tmpFile, true);
  } else {
    if (fs.canExecute(tmpFile))
      fs.setExecute(tmpFile, false);
entry.setLastModified(fs.lastModified(f));

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

RefDirectory(FileRepository db) {
  final FS fs = db.getFS();
  parent = db;
  gitDir = db.getDirectory();
  refsDir = fs.resolve(gitDir, R_REFS);
  logsDir = fs.resolve(gitDir, LOGS);
  logsRefsDir = fs.resolve(gitDir, LOGS + '/' + R_REFS);
  packedRefsFile = fs.resolve(gitDir, PACKED_REFS);
  looseRefs.set(RefList.<LooseRef> emptyList());
  packedRefs.set(NO_PACKED_REFS);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

PrintStream errRedirect, String stdinArgs)
  throws JGitInternalException {
final File hookFile = findHook(repository, hookName);
if (hookFile == null)
  return new ProcessResult(Status.NOT_PRESENT);
else
  runDirectory = repository.getWorkTree();
final String cmd = relativize(runDirectory.getAbsolutePath(),
    hookPath);
ProcessBuilder hookProcess = runInShell(cmd, args);
hookProcess.directory(runDirectory);
Map<String, String> environment = hookProcess.environment();
  return new ProcessResult(runProcess(hookProcess, outRedirect,
      errRedirect, stdinArgs), Status.OK);
} catch (IOException e) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Check if the path may have been modified since the snapshot was saved.
 *
 * @param path
 *            the path the snapshot describes.
 * @return true if the path needs to be read again.
 */
public boolean isModified(File path) {
  long currLastModified;
  try {
    currLastModified = FS.DETECTED.lastModified(path);
  } catch (IOException e) {
    currLastModified = path.lastModified();
  }
  return isModified(currLastModified);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
  public boolean isModified(File path) {
    return FS.DETECTED.exists(path);
  }
};

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

for (String p : status.getIgnoredNotInIndex()) {
  File f = new File(repo.getWorkTree(), p);
  if (fs.isFile(f) || fs.isSymLink(f)) {
    untrackedFiles.add(p);
  } else if (fs.isDirectory(f)) {
    untrackedDirs.add(p);

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Auto-detect the appropriate file system abstraction.
 *
 * @return detected file system abstraction
 */
public static FS detect() {
  return detect(null);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

CheckoutMetadata checkoutMetadata, ObjectLoader ol, FS fs,
  OutputStream channel) throws IOException {
ProcessBuilder filterProcessBuilder = fs.runInShell(
    checkoutMetadata.smudgeFilterCommand, new String[0]);
filterProcessBuilder.directory(repo.getWorkTree());
try {
  result = fs.execute(filterProcessBuilder, ol.openStream());
  rc = result.getRc();
  if (rc == 0) {

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

List<Entry> result = new ArrayList<>();
FS fs = this;
boolean checkExecutable = fs.supportsExecute();
try {
  Files.walkFileTree(directory.toPath(),

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

/**
 * Checks whether the given hook is defined for the given repository, then
 * runs it with the given arguments.
 * <p>
 * The hook's standard output and error streams will be redirected to
 * <code>System.out</code> and <code>System.err</code> respectively. The
 * hook will have no stdin.
 * </p>
 *
 * @param repository
 *            The repository for which a hook should be run.
 * @param hookName
 *            The name of the hook to be executed.
 * @param args
 *            Arguments to pass to this hook. Cannot be <code>null</code>,
 *            but can be an empty array.
 * @return The ProcessResult describing this hook's execution.
 * @throws org.eclipse.jgit.api.errors.JGitInternalException
 *             if we fail to run the hook somehow. Causes may include an
 *             interrupted process or I/O errors.
 * @since 4.0
 */
public ProcessResult runHookIfPresent(Repository repository,
    final String hookName,
    String[] args) throws JGitInternalException {
  return runHookIfPresent(repository, hookName, args, System.out, System.err,
      null);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

@Override
public FileBasedConfig openSystemConfig(Config parent, FS fs) {
  File configFile = fs.getGitSystemConfig();
  if (configFile == null) {
    return new FileBasedConfig(null, fs) {
      @Override
      public void load() {
        // empty, do not load
      }
      @Override
      public boolean isOutdated() {
        // regular class would bomb here
        return false;
      }
    };
  }
  return new FileBasedConfig(parent, configFile, fs);
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit.lfs

/** {@inheritDoc} */
@Override
public Void call() throws Exception {
  StoredConfig cfg = null;
  if (repository == null) {
    cfg = loadUserConfig();
  } else {
    cfg = repository.getConfig();
  }
  cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION,
      ConfigConstants.CONFIG_SECTION_LFS,
      ConfigConstants.CONFIG_KEY_USEJGITBUILTIN, true);
  cfg.setBoolean(ConfigConstants.CONFIG_FILTER_SECTION,
      ConfigConstants.CONFIG_SECTION_LFS,
      ConfigConstants.CONFIG_KEY_REQUIRED, true);
  cfg.save();
  // try to run git lfs install, we really don't care if it is present
  // and/or works here (yet).
  ProcessBuilder builder = FS.DETECTED.runInShell("git", //$NON-NLS-1$
      repository == null ? ARGS_USER : ARGS_LOCAL);
  if (repository != null) {
    builder.directory(repository.isBare() ? repository.getDirectory()
        : repository.getWorkTree());
  }
  FS.DETECTED.runProcess(builder, null, null, (String) null);
  return null;
}

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

if (repo.getFS().isFile(inTree)) {
  RawText rawText = getRawText(inTree);
  gen.push(null, rawText);

相关文章