Skip to content

Commit

Permalink
Add IsDirectory() to Env and FS (#6711)
Browse files Browse the repository at this point in the history
Summary:
IsDirectory() is a common API to check whether a path is a regular file or
directory.
POSIX: call stat() and use S_ISDIR(st_mode)
Windows: PathIsDirectoryA() and PathIsDirectoryW()
HDFS: FileSystem.IsDirectory()
Java: File.IsDirectory()
...
Pull Request resolved: facebook/rocksdb#6711

Test Plan: make check

Reviewed By: anand1976

Differential Revision: D21053520

Pulled By: riversand963

fbshipit-source-id: 680aadfd8ce982b63689190cf31b3145d5a89e27
Signed-off-by: Changlong Chen <levisonchen@live.cn>
  • Loading branch information
riversand963 authored and Changlong Chen committed Jun 18, 2021
1 parent 4043dc0 commit 1b362ad
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/rocksdb/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ class FileSystem {
return IOStatus::NotSupported();
}

virtual IOStatus IsDirectory(const std::string& /*path*/,
const IOOptions& options, bool* is_dir,
IODebugContext* /*dgb*/) = 0;

// If you're adding methods here, remember to add them to EnvWrapper too.

private:
Expand Down Expand Up @@ -1193,6 +1197,10 @@ class FileSystemWrapper : public FileSystem {
uint64_t* diskfree, IODebugContext* dbg) override {
return target_->GetFreeSpace(path, options, diskfree, dbg);
}
IOStatus IsDirectory(const std::string& path, const IOOptions& options,
bool* is_dir, IODebugContext* dbg) override {
return target_->IsDirectory(path, options, is_dir, dbg);
}

private:
std::shared_ptr<FileSystem> target_;
Expand Down

0 comments on commit 1b362ad

Please sign in to comment.