use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method listStatus.
/**
* Each string is a name rather than a complete path.
*
* @param path the path to list
* @return An array with the statuses of the files and directories in the directory
* denoted by this path. The array will be empty if the directory is empty. Returns
* null if this path does not denote a directory
*/
@Override
@Nullable
public UfsStatus[] listStatus(String path) throws IOException {
path = stripPath(path);
String[] lst = listDirectory(path);
if (lst != null) {
UfsStatus[] status = new UfsStatus[lst.length];
for (int i = 0; i < status.length; i++) {
CephStat stat = new CephStat();
lstat(PathUtils.concatPath(path, lst[i]), stat);
if (!stat.isDir()) {
String contentHash = UnderFileSystemUtils.approximateContentHash(stat.size, stat.m_time);
status[i] = new UfsFileStatus(lst[i], contentHash, stat.size, stat.m_time, "", "", (short) stat.mode);
} else {
status[i] = new UfsDirectoryStatus(lst[i], "", "", (short) stat.mode);
}
}
return status;
}
return null;
}
use of com.ceph.fs.CephStat in project alluxio by Alluxio.
the class CephFSUnderFileSystem method exists.
@Override
public boolean exists(String path) throws IOException {
path = stripPath(path);
try {
CephStat stat = new CephStat();
lstat(path, stat);
return true;
} catch (FileNotFoundException e) {
return false;
}
}
Aggregations