Index a directory
@param path complete path like /path/to/subdir
507559
private void indexDirectory(String path) throws Exception {
        fr.pilato.elasticsearch.crawler.fs.beans.Path pathObject = new fr.pilato.elasticsearch.crawler.fs.beans.Path();
        // The real and complete path
        pathObject.setReal(path);
        String rootdir = path.substring(0, path.lastIndexOf(File.separator));
        // Encoded version of the parent dir
        pathObject.setRoot(SignTool.sign(rootdir));
        // The virtual URL (not including the initial root dir)
        pathObject.setVirtual(computeVirtualPathName(stats.getRootPath(), path));

        indexDirectory(SignTool.sign(path), pathObject);
    }
1063206
private void registerDirectory(Path dir) throws IOException {
        Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                WatchKey key = dir.register(watchService, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
                watchKeyToDirectory.put(key, dir);

                return FileVisitResult.CONTINUE;
            }

        });
    }
603328
def dir_contents(path)
      path = File.expand_path(path)
      Dir["#{ path }/**/*"].map {|e| e.sub(/^#{ path }/, '') }.sort
    end
480611
function listDir (path, originalPath) {
  if (!originalPath) {
    originalPath = path + separator;
  }

  // promises for sub listDir calls
  var dirs = [];

  return Promise.resolve(fs.readdir(path))
    // include only files
    .filter(function (item) {
      var absolutePath = join(path, item);

      return fs.stat(absolutePath).then(function (stat) {
        var isDirectory = stat.isDirectory();

        // if directory, read it
        if (isDirectory) {
          var list = listDir(absolutePath, originalPath);

          dirs.push(list);
        }

        return !isDirectory;
      });
    })
    // return relative paths
    .map(function (file) {
      var absolutePath = join(path, file);
      var relativePath = absolutePath.replace(originalPath, '');

      return relativePath;
    })
    // add files from sub-directories
    .then(function (files) {
      // wait for all listDir() to complete
      // and merge their results
      return Promise
        .all(dirs)
        .then(function () {
          dirs.forEach(function (promise) {
            var subFiles = promise.value();

            files = files.concat(subFiles);
          });

          return files;
        });
    });
}
507743
private void addPaths(Path p) {

        for (String d : p.list()) {
            File dir = new File(d);
            if (dir.exists() && dir.isDirectory()) {
                if (!includeDirectories.contains(dir))
                    includeDirectories.add(dir);
            }
        }
    }
180187
public final void setDirectory(final String directory) {
        if (SwingUtilities.isEventDispatchThread()) {
            setDirectoryIntern(directory);
        } else {
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        setDirectoryIntern(directory);
                    }
                });
            } catch (final Exception ex) {
                ignore();
            }
        }
    }
1180707
public static void deleteRecursively(final Path path) throws IOException {
        DeploymentRepositoryLogger.ROOT_LOGGER.debugf("Deleting %s recursively", path);
        if (Files.exists(path)) {
            Files.walkFileTree(path, new FileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    Files.delete(file);
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                    DeploymentRepositoryLogger.ROOT_LOGGER.cannotDeleteFile(exc, path);
                    throw exc;
                }

                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    Files.delete(dir);
                    return FileVisitResult.CONTINUE;
                }
            });
        }
    }
172241
protected void addSourceFolder(String path) {
		final List<String> existingFolders1 = this.project.getCompileSourceRoots();
		final List<String> existingFolders2 = this.project.getTestCompileSourceRoots();
		if (!existingFolders1.contains(path) && !existingFolders2.contains(path)) {
			getLog().info(MessageFormat.format(Messages.InitializeMojo_0, path));
			this.session.getCurrentProject().addCompileSourceRoot(path);
		} else {
			getLog().info(MessageFormat.format(Messages.InitializeMojo_1, path));
		}
	}
1221189
public static void directoryCheck(String dir) throws IOException {
		final File file = new File(dir);

		if (!file.exists()) {
			FileUtils.forceMkdir(file);
		}
	}
1047807
def _list_dir(self, path):
        """"""
        try:
            elements = [
                os.path.join(path, x) for x in os.listdir(path)
            ] if os.path.isdir(path) else []
            elements.sort()
        except OSError:
            elements = None
        return elements
1184671
@Override
	public boolean isDirectory(String path) {

		String resourcePath = getResolver().getResourcePath(path);
		return rsBrowser.isDirectory(resourcePath);
	}
1040037
public void mkdirs(URI path) throws IOException {
    logger.atFine().log("mkdirs(%s)", path);
    Preconditions.checkNotNull(path);

    if (path.equals(GCS_ROOT)) {
      // GCS_ROOT directory always exists, no need to go through the rest of the method.
      return;
    }

    StorageResourceId resourceId = pathCodec.validatePathAndGetId(path, true);
    resourceId = FileInfo.convertToDirectoryPath(resourceId);

    // Create a list of all intermediate paths.
    // For example,
    // gs://foo/bar/zoo/ => (gs://foo/, gs://foo/bar/, gs://foo/bar/zoo/)
    //
    // We also need to find out if any of the subdir path item exists as a file
    // therefore, also create a list of file equivalent of each subdir path.
    // For example,
    // gs://foo/bar/zoo/ => (gs://foo/bar, gs://foo/bar/zoo)
    List<String> subdirs = getSubDirs(resourceId.getObjectName());
    List<StorageResourceId> itemIds = new ArrayList<>(subdirs.size() * 2 + 1);
    for (String subdir : subdirs) {
      itemIds.add(new StorageResourceId(resourceId.getBucketName(), subdir));
      if (!Strings.isNullOrEmpty(subdir)) {
        itemIds.add(
            new StorageResourceId(resourceId.getBucketName(), FileInfo.convertToFilePath(subdir)));
      }
    }
    // Add the bucket portion.
    itemIds.add(new StorageResourceId(resourceId.getBucketName()));
    logger.atFine().log("mkdirs: items: %s", itemIds);

    List<GoogleCloudStorageItemInfo> itemInfos = gcs.getItemInfos(itemIds);

    // Each intermediate path must satisfy one of the following conditions:
    // -- it does not exist or
    // -- if it exists, it is a directory
    //
    // If any of the intermediate paths violates these requirements then
    // bail out early so that we do not end up with partial set of
    // created sub-directories. It is possible that the status of intermediate
    // paths can change after we make this check therefore this is a
    // good faith effort and not a guarantee.
    GoogleCloudStorageItemInfo bucketInfo = null;
    List<StorageResourceId> subdirsToCreate = new ArrayList<>(subdirs.size());
    for (GoogleCloudStorageItemInfo info : itemInfos) {
      if (info.isBucket()) {
        checkState(bucketInfo == null, "bucketInfo should be null");
        bucketInfo = info;
      } else if (info.getResourceId().isDirectory() && !info.exists()) {
        subdirsToCreate.add(info.getResourceId());
      } else if (!info.getResourceId().isDirectory() && info.exists()) {
        throw new FileAlreadyExistsException(
            "Cannot create directories because of existing file: " + info.getResourceId());
      }
    }

    if (!checkNotNull(bucketInfo, "bucketInfo should not be null").exists()) {
      gcs.create(bucketInfo.getBucketName());
    }
    gcs.createEmptyObjects(subdirsToCreate);

    // Update parent directories, but not the ones we just created because we just created them.
    List<URI> createdDirectories =
        subdirsToCreate.stream()
            .map(s -> pathCodec.getPath(s.getBucketName(), s.getObjectName(), false))
            .collect(toImmutableList());
    tryUpdateTimestampsForParentDirectories(createdDirectories, createdDirectories);
  }
372184
private void addDirectoryClasses(final Path location, final Path subPath) {
        for (final File file : location.toFile().listFiles()) {
            if (file.isDirectory())
                addDirectoryClasses(location.resolve(file.getName()), subPath.resolve(file.getName()));
            else if (file.isFile() && file.getName().endsWith(".class")) {
                final String classFileName = subPath.resolve(file.getName()).toString();
                classes.add(toQualifiedClassName(classFileName));
            }
        }
    }
218104
private void cleanEmptyParentDirectory(Path path) throws IOException {
        Path normPath = path.normalize();
        if(normPath.equals(Paths.get(getDirectory()).normalize()) || normPath.equals(Paths.get(System.getProperty("java.io.tmpdir")).normalize())) { //stop if we reach the output or temporary directory
            return;
        }
        try {
            Files.deleteIfExists(path); //delete the directory if empty
            cleanEmptyParentDirectory(path.getParent()); //do the same with parent directory
        }
        catch(DirectoryNotEmptyException ex) {
            //if directory non-empty ignore exception
        }
    }
1007608
void setPathUserIndex(int path, int index, int value) {
		AttributeStreamOfInt32 stream = m_pathindices.get(index);
		int pindex = getPathIndex_(path);
		if (stream.size() < m_path_areas.size())
			stream.resize(m_path_areas.size(), -1);
		stream.write(pindex, value);
	}
1255035
def mkdir(self, path):
        """"""

        resp = self._sendRequest("MKCOL", path)
        if resp.status_code != 201:
            if resp.status_code == 409:
                raise YaDiskException(409, "Part of path {} does not exists".format(path))
            elif resp.status_code == 405:
                raise YaDiskException(405, "Path {} already exists".format(path))
            else:
                raise YaDiskException(resp.status_code, resp.content)
142260
private static function rmdir($path) {
        foreach (glob($path . '/*') as $file) {
            if (is_dir($file)) {
                self::rmdir($file);
            } else {
                unlink($file);
            }
        }

        // Remove the remaining directory
        rmdir($path);
    }