aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/platform/file_system.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2016-07-12 21:12:47 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-07-12 22:17:06 -0700
commit2094bb5349c060516907f02975bcdc6e752d407b (patch)
treee9456682a1ac6deb9a4a1991ec33ebf6c8bea8d2 /tensorflow/core/platform/file_system.h
parentf6f36020a7e9c2da563cf4053cf653ef00fbd4f7 (diff)
Adding FileSystem::Stat to the core filesystem API. Implemented versions of it for all subclasses except for GCS File System for now.
Change: 127282696
Diffstat (limited to 'tensorflow/core/platform/file_system.h')
-rw-r--r--tensorflow/core/platform/file_system.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/tensorflow/core/platform/file_system.h b/tensorflow/core/platform/file_system.h
index c080ad5ec3..f372b379f5 100644
--- a/tensorflow/core/platform/file_system.h
+++ b/tensorflow/core/platform/file_system.h
@@ -34,6 +34,16 @@ class RandomAccessFile;
class ReadOnlyMemoryRegion;
class WritableFile;
+struct FileStatistics {
+ // The length of the file or -1 if finding file length is not supported.
+ int64 length;
+ // The last modified time in nanoseconds.
+ int64 mtime_nsec;
+ // This field contains more than just the permissions bits. More information
+ // can be found on the man page for stat(2).
+ mode_t mode;
+};
+
/// A generic interface for accessing a file system.
class FileSystem {
public:
@@ -60,6 +70,8 @@ class FileSystem {
virtual Status GetChildren(const string& dir,
std::vector<string>* result) = 0;
+ virtual Status Stat(const string& fname, FileStatistics* stat) = 0;
+
virtual Status DeleteFile(const string& fname) = 0;
virtual Status CreateDir(const string& dirname) = 0;
@@ -73,6 +85,15 @@ class FileSystem {
// Translate an URI to a filename usable by the FileSystem implementation. The
// implementation in this class returns the name as-is.
virtual string TranslateName(const string& name) const;
+
+ // Returns whether the given path is a directory or not.
+ // Typical return codes (not guaranteed exhaustive):
+ // * OK - The path exists and is a directory.
+ // * FAILED_PRECONDITION - The path exists and is not a directory.
+ // * NOT_FOUND - The path entry does not exist.
+ // * PERMISSION_DENIED - Insufficient permissions.
+ // * UNIMPLEMENTED - The file factory doesn't support directories.
+ virtual Status IsDirectory(const string& fname);
};
// Degenerate file system that provides no implementations.
@@ -129,6 +150,10 @@ class NullFileSystem : public FileSystem {
Status RenameFile(const string& src, const string& target) override {
return errors::Unimplemented("RenameFile unimplemented");
}
+
+ Status Stat(const string& fname, FileStatistics* stat) override {
+ return errors::Unimplemented("Stat unimplemented");
+ }
};
/// A file abstraction for randomly reading the contents of a file.