Add preliminary methods to env class
This commit is contained in:
parent
5451813add
commit
9b9b9bbda9
@ -111,6 +111,13 @@ class Env {
|
||||
Status NewRandomAccessFile(const std::string& fname,
|
||||
std::unique_ptr<RandomAccessFile>* result);
|
||||
|
||||
Status NewRandomAccessFile(const std::string& fname, TransactionToken* token,
|
||||
std::unique_ptr<RandomAccessFile>* result) {
|
||||
// We duplicate these methods due to Google internal coding style prevents
|
||||
// virtual functions with default arguments. See PR #41615.
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Creates an object that writes to a new file with the specified
|
||||
/// name.
|
||||
///
|
||||
@ -127,6 +134,11 @@ class Env {
|
||||
Status NewWritableFile(const std::string& fname,
|
||||
std::unique_ptr<WritableFile>* result);
|
||||
|
||||
Status NewWritableFile(const std::string& fname, TransactionToken* token,
|
||||
std::unique_ptr<WritableFile>* result) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Creates an object that either appends to an existing file, or
|
||||
/// writes to a new file (if the file does not exist to begin with).
|
||||
///
|
||||
@ -142,6 +154,10 @@ class Env {
|
||||
Status NewAppendableFile(const std::string& fname,
|
||||
std::unique_ptr<WritableFile>* result);
|
||||
|
||||
Status NewAppendableFile(const std::string& fname, TransactionToken* token,
|
||||
std::unique_ptr<WritableFile>* result) {
|
||||
return Status::OK();
|
||||
}
|
||||
/// \brief Creates a readonly region of memory with the file context.
|
||||
///
|
||||
/// On success, it returns a pointer to read-only memory region
|
||||
@ -156,21 +172,41 @@ class Env {
|
||||
Status NewReadOnlyMemoryRegionFromFile(
|
||||
const std::string& fname, std::unique_ptr<ReadOnlyMemoryRegion>* result);
|
||||
|
||||
Status NewReadOnlyMemoryRegionFromFile(
|
||||
const std::string& fname, TransactionToken* token,
|
||||
std::unique_ptr<ReadOnlyMemoryRegion>* result) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// Returns OK if the named path exists and NOT_FOUND otherwise.
|
||||
Status FileExists(const std::string& fname);
|
||||
|
||||
Status FileExists(const std::string& fname, TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// Returns true if all the listed files exist, false otherwise.
|
||||
/// if status is not null, populate the vector with a detailed status
|
||||
/// for each file.
|
||||
bool FilesExist(const std::vector<string>& files,
|
||||
std::vector<Status>* status);
|
||||
|
||||
bool FilesExist(const std::vector<string>& files, TransactionToken* token,
|
||||
std::vector<Status>* status) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// \brief Stores in *result the names of the children of the specified
|
||||
/// directory. The names are relative to "dir".
|
||||
///
|
||||
/// Original contents of *results are dropped.
|
||||
Status GetChildren(const std::string& dir, std::vector<string>* result);
|
||||
|
||||
Status GetChildren(const std::string& dir, TransactionToken* token,
|
||||
std::vector<string>* result) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Returns true if the path matches the given pattern. The wildcards
|
||||
/// allowed in pattern are described in FileSystem::GetMatchingPaths.
|
||||
virtual bool MatchPath(const std::string& path,
|
||||
@ -183,9 +219,18 @@ class Env {
|
||||
virtual Status GetMatchingPaths(const std::string& pattern,
|
||||
std::vector<string>* results);
|
||||
|
||||
Status GetMatchingPaths(const std::string& pattern, TransactionToken* token,
|
||||
std::vector<string>* results) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// Deletes the named file.
|
||||
Status DeleteFile(const std::string& fname);
|
||||
|
||||
Status DeleteFile(const std::string& fname, TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Deletes the specified directory and all subdirectories and files
|
||||
/// underneath it. This is accomplished by traversing the directory tree
|
||||
/// rooted at dirname and deleting entries as they are encountered.
|
||||
@ -213,6 +258,11 @@ class Env {
|
||||
Status DeleteRecursively(const std::string& dirname, int64* undeleted_files,
|
||||
int64* undeleted_dirs);
|
||||
|
||||
Status DeleteRecursively(const std::string& dirname, TransactionToken* token,
|
||||
int64* undeleted_files, int64* undeleted_dirs) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Creates the specified directory and all the necessary
|
||||
/// subdirectories. Typical return codes.
|
||||
/// * OK - successfully created the directory and sub directories, even if
|
||||
@ -220,18 +270,35 @@ class Env {
|
||||
/// * PERMISSION_DENIED - dirname or some subdirectory is not writable.
|
||||
Status RecursivelyCreateDir(const std::string& dirname);
|
||||
|
||||
Status RecursivelyCreateDir(const std::string& dirname,
|
||||
TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
/// \brief Creates the specified directory. Typical return codes
|
||||
/// * OK - successfully created the directory.
|
||||
/// * ALREADY_EXISTS - directory already exists.
|
||||
/// * PERMISSION_DENIED - dirname is not writable.
|
||||
Status CreateDir(const std::string& dirname);
|
||||
|
||||
Status CreateDir(const std::string& dirname, TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// Deletes the specified directory.
|
||||
Status DeleteDir(const std::string& dirname);
|
||||
|
||||
Status DeleteDir(const std::string& dirname, TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// Obtains statistics for the given path.
|
||||
Status Stat(const std::string& fname, FileStatistics* stat);
|
||||
|
||||
Status Stat(const std::string& fname, TransactionToken* token,
|
||||
FileStatistics* stat) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Returns whether the given path is a directory or not.
|
||||
/// Typical return codes (not guaranteed exhaustive):
|
||||
/// * OK - The path exists and is a directory.
|
||||
@ -256,13 +323,59 @@ class Env {
|
||||
/// Stores the size of `fname` in `*file_size`.
|
||||
Status GetFileSize(const std::string& fname, uint64* file_size);
|
||||
|
||||
Status GetFileSize(const std::string& fname, TransactionToken* token,
|
||||
uint64* file_size) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Renames file src to target. If target already exists, it will be
|
||||
/// replaced.
|
||||
Status RenameFile(const std::string& src, const std::string& target);
|
||||
|
||||
Status RenameFile(const std::string& src, const std::string& target,
|
||||
TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Copy the src to target.
|
||||
Status CopyFile(const std::string& src, const std::string& target);
|
||||
|
||||
Status CopyFile(const std::string& src, const std::string& target,
|
||||
TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief starts a new transaction on the filesystem that handles filename
|
||||
Status StartTransaction(const std::string& filename,
|
||||
TransactionToken** token) {
|
||||
token = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Adds `path` to transaction in `token` if token belongs to
|
||||
/// filesystem that handles the path.
|
||||
Status AddToTransaction(const std::string& path, TransactionToken* token) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Get token for `path` or start a new transaction and add `path` to
|
||||
/// it.
|
||||
Status GetTokenOrStartTransaction(const std::string& path,
|
||||
TransactionToken** token) {
|
||||
*token = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Returns the transaction for `path` or nullptr in `token`
|
||||
Status GetTransactionForPath(const std::string& path,
|
||||
TransactionToken** token) {
|
||||
token = nullptr;
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/// \brief Finalizes the transaction
|
||||
Status EndTransaction(TransactionToken* token) { return Status::OK(); }
|
||||
|
||||
/// \brief Returns the absolute path of the current executable. It resolves
|
||||
/// symlinks if there is any.
|
||||
std::string GetExecutablePath();
|
||||
|
Loading…
Reference in New Issue
Block a user