Skip to content

Commit

Permalink
Automatic code cleanup.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 433549877
  • Loading branch information
Googler authored and copybara-github committed Mar 9, 2022
1 parent 68bf2ea commit f815bf0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
28 changes: 12 additions & 16 deletions src/main/java/com/google/devtools/build/lib/unix/FileStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,26 @@ public boolean isRegularFile() {
return (st_mode & S_IFMT) == S_IFREG;
}

/**
* Returns true iff this file is a directory.
*/
/** Returns true iff this file is a directory. */
public boolean isDirectory() {
return (st_mode & S_IFMT) == S_IFDIR;
}

/**
* Returns true iff this file is a symbolic link.
*/
public static boolean isDirectory(int rawType) {
int type = rawType & S_IFMT;
return type == S_IFDIR;
}

/** Returns true iff this file is a symbolic link. */
public boolean isSymbolicLink() {
return (st_mode & S_IFMT) == S_IFLNK;
}

public static boolean isSymbolicLink(int rawType) {
int type = rawType & S_IFMT;
return type == S_IFLNK;
}

/**
* Returns true iff this file is a character device.
*/
Expand Down Expand Up @@ -268,14 +274,4 @@ public static boolean isSpecialFile(int rawType) {
int type = rawType & S_IFMT;
return type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR || type == S_IFIFO;
}

public static boolean isDirectory(int rawType) {
int type = rawType & S_IFMT;
return type == S_IFDIR;
}

public static boolean isSymbolicLink(int rawType) {
int type = rawType & S_IFMT;
return type == S_IFLNK;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,32 @@ public static native boolean mkdir(String path, int mode)
* Native wrapper around POSIX opendir(2)/readdir(3)/closedir(3) syscall.
*
* @param path the directory to read.
* @return the list of directory entries in the order they were returned by
* the system, excluding "." and "..".
* @return the list of directory entries in the order they were returned by the system, excluding
* "." and "..".
* @throws IOException if the call to opendir failed for any reason.
*/
public static String[] readdir(String path) throws IOException {
return readdir(path, ReadTypes.NONE).names;
}

/**
* Native wrapper around POSIX opendir(2)/readdir(3)/closedir(3) syscall.
*
* @param path the directory to read.
* @param readTypes How the types of individual entries should be returned. If {@code NONE}, the
* "types" field in the result will be null.
* @return a Dirents object, containing "names", the list of directory entries (excluding "." and
* "..") in the order they were returned by the system, and "types", an array of entry types
* (file, directory, etc) corresponding positionally to "names".
* @throws IOException if the call to opendir failed for any reason.
*/
public static Dirents readdir(String path, ReadTypes readTypes) throws IOException {
// Passing enums to native code is possible, but onerous; we use a char instead.
return readdir(path, readTypes.getCode());
}

private static native Dirents readdir(String path, char typeCode) throws IOException;

/**
* An enum for specifying now the types of the individual entries returned by
* {@link #readdir(String, ReadTypes)} is to be returned.
Expand Down Expand Up @@ -274,26 +292,6 @@ public Type getType(int i) {
}
}

/**
* Native wrapper around POSIX opendir(2)/readdir(3)/closedir(3) syscall.
*
* @param path the directory to read.
* @param readTypes How the types of individual entries should be returned. If {@code NONE},
* the "types" field in the result will be null.
* @return a Dirents object, containing "names", the list of directory entries
* (excluding "." and "..") in the order they were returned by the system,
* and "types", an array of entry types (file, directory, etc) corresponding
* positionally to "names".
* @throws IOException if the call to opendir failed for any reason.
*/
public static Dirents readdir(String path, ReadTypes readTypes) throws IOException {
// Passing enums to native code is possible, but onerous; we use a char instead.
return readdir(path, readTypes.getCode());
}

private static native Dirents readdir(String path, char typeCode)
throws IOException;

/**
* Native wrapper around POSIX rename(2) syscall.
*
Expand Down

0 comments on commit f815bf0

Please sign in to comment.