class FileSystem
Defined at line 20 of file ../../third_party/cobalt/src/lib/util/file_system.h
FileSystem is an abstract class used for interacting with the file system
in a platform independent way.
Public Methods
bool MakeDirectory (const std::string & directory)
MakeDirectory creates a directory on the file system.
|directory|. An absolute path to the directory to be created.
Returns: True if the directory was created successfully.
lib::statusor::StatusOr<std::vector<std::string>> ListFiles (const std::string & directory)
ListFiles lists the files in a given directory.
|directory|. An absolute path to the directory to list.
Returns: A StatusOr with a vector of filenames. An Ok status indicates that the list operation
succeeded, even if the vector is empty.
Note: On unix like systems, the directories "." and ".." should not be returned.
bool Delete (const std::string & file)
Delete deletes a file or an empty directory.
|file|. An absolute path to the file or directory to be deleted.
Returns: True if the file was successfully deleted.
bool DeleteRecursive (const std::string & directory)
Deletes a directory and all children of that directory.
|directory|. The starting directory of the delete.
Returns: True if the directory was successfully deleted.
Note: The default implementation is a wrapper around Delete(). A more efficient implementation
should be used if it exists on the target system.
lib::statusor::StatusOr<size_t> FileSize (const std::string & file)
FileSize returns the size of the |file| on disk.
|file|. An absolute path to the file whose size is needed.
Returns: A StatusOr containing the size of the file in bytes. An OK status indicates that the
FileSize operation succeeded, even if the size_t is 0.
bool FileExists (const std::string & file)
FileExists returns true if the |file| exists.
lib::statusor::StatusOr<ProtoInputStreamPtr> NewProtoInputStream (const std::string & file)
Open a file for reading.
|file|. An absolute path to the file to be read.
Defined at line 82 of file ../../third_party/cobalt/src/lib/util/file_system.h
bool Rename (const std::string & from, const std::string & to)
Rename renames a file.
|from|. An absolute path to the file that is to be renamed.
|to|. An absolute path to the new name for the file.
Returns: True if the file was renamed successfully.
lib::statusor::StatusOr<ProtoInputStreamPtr> NewProtoInputStream (const std::string & file, int block_size)
Open a file for reading.
|file|. An absolute path to the file to be read.
|block_size|. The block size the underlying ZeroCopyStream should use.
lib::statusor::StatusOr<ProtoOutputStreamPtr> NewProtoOutputStream (const std::string & file)
Open a file for writing.
|file|. An absolute path to the file to be written.
Defined at line 96 of file ../../third_party/cobalt/src/lib/util/file_system.h
lib::statusor::StatusOr<ProtoOutputStreamPtr> NewProtoOutputStream (const std::string & file, bool append)
Open a file for writing.
|file|. An absolute path to the file to be written.
|append|. True if the file should be opened in append mode.
Defined at line 104 of file ../../third_party/cobalt/src/lib/util/file_system.h
lib::statusor::StatusOr<ProtoOutputStreamPtr> NewProtoOutputStream (const std::string & file, bool append, int block_size)
Open a file for writing.
|file|. An absolute path to the file to be writing.
|append|. True if the file should be opened in append mode.
|block_size|. The block size the underlying ZeroCopyStream should use.
void ~FileSystem ()
Defined at line 117 of file ../../third_party/cobalt/src/lib/util/file_system.h
void FileSystem (const FileSystem & )
Disable copy and assignment
Defined at line 120 of file ../../third_party/cobalt/src/lib/util/file_system.h
FileSystem & operator= (const FileSystem & )
Defined at line 121 of file ../../third_party/cobalt/src/lib/util/file_system.h
void FileSystem ()
Defined at line 122 of file ../../third_party/cobalt/src/lib/util/file_system.h