示例#1
0
  /**
   * Deletes file or directory. If directory is not empty, it's deleted recursively.
   *
   * @param fs IGFS.
   * @param path File or directory path.
   * @throws IgniteException In case of error.
   */
  private static void delete(IgniteFileSystem fs, IgfsPath path) throws IgniteException {
    assert fs != null;
    assert path != null;

    if (fs.exists(path)) {
      boolean isFile = fs.info(path).isFile();

      try {
        fs.delete(path, true);

        System.out.println();
        System.out.println(">>> Deleted " + (isFile ? "file" : "directory") + ": " + path);
      } catch (IgfsException e) {
        System.out.println();
        System.out.println(
            ">>> Failed to delete "
                + (isFile ? "file" : "directory")
                + " [path="
                + path
                + ", msg="
                + e.getMessage()
                + ']');
      }
    } else {
      System.out.println();
      System.out.println(">>> Won't delete file or directory (doesn't exist): " + path);
    }
  }
示例#2
0
  /**
   * Creates directories.
   *
   * @param fs IGFS.
   * @param path Directory path.
   * @throws IgniteException In case of error.
   */
  private static void mkdirs(IgniteFileSystem fs, IgfsPath path) throws IgniteException {
    assert fs != null;
    assert path != null;

    try {
      fs.mkdirs(path);

      System.out.println();
      System.out.println(">>> Created directory: " + path);
    } catch (IgfsException e) {
      System.out.println();
      System.out.println(
          ">>> Failed to create a directory [path=" + path + ", msg=" + e.getMessage() + ']');
    }

    System.out.println();
  }