Search in sources :

Example 1 with Dirents

use of com.google.devtools.build.lib.unix.NativePosixFiles.Dirents in project bazel by bazelbuild.

the class UnixFileSystem method readdir.

@Override
protected Collection<Dirent> readdir(Path path, boolean followSymlinks) throws IOException {
    String name = path.getPathString();
    long startTime = Profiler.nanoTimeMaybe();
    try {
        Dirents unixDirents = NativePosixFiles.readdir(name, followSymlinks ? ReadTypes.FOLLOW : ReadTypes.NOFOLLOW);
        Preconditions.checkState(unixDirents.hasTypes());
        List<Dirent> dirents = Lists.newArrayListWithCapacity(unixDirents.size());
        for (int i = 0; i < unixDirents.size(); i++) {
            dirents.add(new Dirent(unixDirents.getName(i), convertToDirentType(unixDirents.getType(i))));
        }
        return dirents;
    } finally {
        profiler.logSimpleTask(startTime, ProfilerTask.VFS_DIR, name);
    }
}
Also used : Dirent(com.google.devtools.build.lib.vfs.Dirent) Dirents(com.google.devtools.build.lib.unix.NativePosixFiles.Dirents)

Aggregations

Dirents (com.google.devtools.build.lib.unix.NativePosixFiles.Dirents)1 Dirent (com.google.devtools.build.lib.vfs.Dirent)1