org.eclipse.jgit.util.FileUtils.mkdirs()方法的使用及代码示例

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

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

FileUtils.mkdirs介绍

[英]Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.
[中]创建以此抽象路径名命名的目录,包括任何必要但不存在的父目录。请注意,如果此操作失败,它可能已成功创建一些必要的父目录。

代码示例

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

/**
 * Creates the directory named by this abstract pathname, including any
 * necessary but nonexistent parent directories. Note that if this operation
 * fails it may have succeeded in creating some of the necessary parent
 * directories.
 *
 * @param d
 *            directory to be created
 * @throws java.io.IOException
 *             if creation of {@code d} fails. This may occur if {@code d}
 *             did exist when the method was called. This can therefore
 *             cause java.io.IOExceptions during race conditions when
 *             multiple concurrent threads all try to create the same
 *             directory.
 */
public static void mkdirs(File d) throws IOException {
  mkdirs(d, false);
}

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

/** {@inheritDoc} */
@Override
public void create() throws IOException {
  FileUtils.mkdirs(objects);
  FileUtils.mkdir(infoDirectory);
  FileUtils.mkdir(packDirectory);
}

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

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

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

private void checkoutGitlink(String path, DirCacheEntry entry)
    throws IOException {
  File gitlinkDir = new File(repo.getWorkTree(), path);
  FileUtils.mkdirs(gitlinkDir, true);
  FS fs = repo.getFS();
  entry.setLastModified(fs.lastModified(gitlinkDir));
}

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

/**
 * Try to establish the lock.
 *
 * @return true if the lock is now held by the caller; false if it is held
 *         by someone else.
 * @throws java.io.IOException
 *             the temporary output file could not be created. The caller
 *             does not hold the lock.
 */
public boolean lock() throws IOException {
  FileUtils.mkdirs(lck.getParentFile(), true);
  token = FS.DETECTED.createNewFileAtomic(lck);
  if (token.isCreated()) {
    haveLck = true;
    try {
      os = new FileOutputStream(lck);
    } catch (IOException ioe) {
      unlock();
      throw ioe;
    }
  } else {
    closeToken();
  }
  return haveLck;
}

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

/**
 * Creates the directory named by this abstract pathname, including any
 * necessary but nonexistent parent directories. Note that if this operation
 * fails it may have succeeded in creating some of the necessary parent
 * directories.
 *
 * @param d
 *            directory to be created
 * @throws IOException
 *             if creation of {@code d} fails. This may occur if {@code d}
 *             did exist when the method was called. This can therefore
 *             cause IOExceptions during race conditions when multiple
 *             concurrent threads all try to create the same directory.
 */
public static void mkdirs(final File d) throws IOException {
  mkdirs(d, false);
}

代码示例来源:origin: berlam/github-bucket

/**
 * Creates the directory named by this abstract pathname, including any
 * necessary but nonexistent parent directories. Note that if this operation
 * fails it may have succeeded in creating some of the necessary parent
 * directories.
 *
 * @param d
 *            directory to be created
 * @throws java.io.IOException
 *             if creation of {@code d} fails. This may occur if {@code d}
 *             did exist when the method was called. This can therefore
 *             cause java.io.IOExceptions during race conditions when
 *             multiple concurrent threads all try to create the same
 *             directory.
 */
public static void mkdirs(File d) throws IOException {
  mkdirs(d, false);
}

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

File f = new File(repo.getWorkTree(), entry.getPathString());
File parentDir = f.getParentFile();
FileUtils.mkdirs(parentDir, true);
FS fs = repo.getFS();
WorkingTreeOptions opt = repo.getConfig().get(WorkingTreeOptions.KEY);

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

JGitText.get().repositoryAlreadyExists, getDirectory()));
FileUtils.mkdirs(getDirectory(), true);
HideDotFiles hideDotFiles = getConfig().getEnum(
    ConfigConstants.CONFIG_CORE_SECTION, null,

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

/**
 * Creates a unique directory for a test
 *
 * @param name
 *            a subdirectory
 * @return a unique directory for a test
 * @throws IOException
 */
protected File createTempDirectory(String name) throws IOException {
  File directory = new File(createTempFile(), name);
  FileUtils.mkdirs(directory);
  return directory.getCanonicalFile();
}

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

/**
 * Creates a unique directory for a test
 *
 * @param name
 *            a subdirectory
 * @return a unique directory for a test
 * @throws IOException
 */
protected File createTempDirectory(String name) throws IOException {
  File directory = new File(createTempFile(), name);
  FileUtils.mkdirs(directory);
  return directory.getCanonicalFile();
}

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

/**
 * Creates a unique directory for a test
 *
 * @param name
 *            a subdirectory
 * @return a unique directory for a test
 * @throws IOException
 */
protected File createTempDirectory(String name) throws IOException {
  File directory = new File(createTempFile(), name);
  FileUtils.mkdirs(directory);
  return directory.getCanonicalFile();
}

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

/**
 * Write a string as a UTF-8 file.
 *
 * @param f
 *            file to write the string to. Caller is responsible for making
 *            sure it is in the trash directory or will otherwise be cleaned
 *            up at the end of the test. If the parent directory does not
 *            exist, the missing parent directories are automatically
 *            created.
 * @param body
 *            content to write to the file.
 * @throws IOException
 *             the file could not be written.
 */
public static void write(File f, String body)
    throws IOException {
  FileUtils.mkdirs(f.getParentFile(), true);
  try (Writer w = new OutputStreamWriter(new FileOutputStream(f),
      UTF_8)) {
    w.write(body);
  }
}

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

/**
 * Write a string as a UTF-8 file.
 *
 * @param f
 *            file to write the string to. Caller is responsible for making
 *            sure it is in the trash directory or will otherwise be cleaned
 *            up at the end of the test. If the parent directory does not
 *            exist, the missing parent directories are automatically
 *            created.
 * @param body
 *            content to write to the file.
 * @throws IOException
 *             the file could not be written.
 */
public static void write(final File f, final String body)
    throws IOException {
  FileUtils.mkdirs(f.getParentFile(), true);
  Writer w = new OutputStreamWriter(new FileOutputStream(f), "UTF-8");
  try {
    w.write(body);
  } finally {
    w.close();
  }
}

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

/**
 * Try to establish the lock.
 *
 * @return true if the lock is now held by the caller; false if it is held
 *         by someone else.
 * @throws IOException
 *             the temporary output file could not be created. The caller
 *             does not hold the lock.
 */
public boolean lock() throws IOException {
  FileUtils.mkdirs(lck.getParentFile(), true);
  if (lck.createNewFile()) {
    haveLck = true;
    try {
      os = new FileOutputStream(lck);
    } catch (IOException ioe) {
      unlock();
      throw ioe;
    }
  }
  return haveLck;
}

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

@Override
public void create() throws IOException {
  FileUtils.mkdirs(objects);
  FileUtils.mkdir(infoDirectory);
  FileUtils.mkdir(packDirectory);
}

代码示例来源:origin: berlam/github-bucket

/** {@inheritDoc} */
@Override
public void create() throws IOException {
  FileUtils.mkdirs(objects);
  FileUtils.mkdir(infoDirectory);
  FileUtils.mkdir(packDirectory);
}

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

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

代码示例来源:origin: berlam/github-bucket

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

代码示例来源:origin: berlam/github-bucket

private void checkoutGitlink(String path, DirCacheEntry entry)
    throws IOException {
  File gitlinkDir = new File(repo.getWorkTree(), path);
  FileUtils.mkdirs(gitlinkDir, true);
  FS fs = repo.getFS();
  entry.setLastModified(fs.lastModified(gitlinkDir));
}

相关文章