diff options
author | Jan Niklas Hasse <jhasse@bixense.com> | 2020-11-28 11:22:23 (GMT) |
---|---|---|
committer | Jan Niklas Hasse <jhasse@bixense.com> | 2020-11-28 11:22:23 (GMT) |
commit | 9cf70a20685ac3bd48fceac2ea268d449c7e78d5 (patch) | |
tree | 433402b91ee03f5a476da5c0bdb26f6d3bad7809 /src/disk_interface.h | |
parent | a1f879b29c9aafe6a2bc0ba885701f8f4f19f772 (diff) | |
parent | ed056bdd8c8d578a9952bd93b76f29c14199c85b (diff) | |
download | Ninja-9cf70a20685ac3bd48fceac2ea268d449c7e78d5.zip Ninja-9cf70a20685ac3bd48fceac2ea268d449c7e78d5.tar.gz Ninja-9cf70a20685ac3bd48fceac2ea268d449c7e78d5.tar.bz2 |
Merge branch 'master' into release
Diffstat (limited to 'src/disk_interface.h')
-rw-r--r-- | src/disk_interface.h | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/disk_interface.h b/src/disk_interface.h index 145e089..bc29ab7 100644 --- a/src/disk_interface.h +++ b/src/disk_interface.h @@ -17,7 +17,6 @@ #include <map> #include <string> -using namespace std; #include "timestamp.h" @@ -35,8 +34,8 @@ struct FileReader { /// Read and store in given string. On success, return Okay. /// On error, return another Status and fill |err|. - virtual Status ReadFile(const string& path, string* contents, - string* err) = 0; + virtual Status ReadFile(const std::string& path, std::string* contents, + std::string* err) = 0; }; /// Interface for accessing the disk. @@ -46,25 +45,26 @@ struct FileReader { struct DiskInterface: public FileReader { /// stat() a file, returning the mtime, or 0 if missing and -1 on /// other errors. - virtual TimeStamp Stat(const string& path, string* err) const = 0; + virtual TimeStamp Stat(const std::string& path, std::string* err) const = 0; /// Create a directory, returning false on failure. - virtual bool MakeDir(const string& path) = 0; + virtual bool MakeDir(const std::string& path) = 0; /// Create a file, with the specified name and contents /// Returns true on success, false on failure - virtual bool WriteFile(const string& path, const string& contents) = 0; + virtual bool WriteFile(const std::string& path, + const std::string& contents) = 0; /// Remove the file named @a path. It behaves like 'rm -f path' so no errors /// are reported if it does not exists. /// @returns 0 if the file has been removed, /// 1 if the file does not exist, and /// -1 if an error occurs. - virtual int RemoveFile(const string& path) = 0; + virtual int RemoveFile(const std::string& path) = 0; /// Create all the parent directories for path; like mkdir -p /// `basename path`. - bool MakeDirs(const string& path); + bool MakeDirs(const std::string& path); }; /// Implementation of DiskInterface that actually hits the disk. @@ -75,11 +75,12 @@ struct RealDiskInterface : public DiskInterface { #endif {} virtual ~RealDiskInterface() {} - virtual TimeStamp Stat(const string& path, string* err) const; - virtual bool MakeDir(const string& path); - virtual bool WriteFile(const string& path, const string& contents); - virtual Status ReadFile(const string& path, string* contents, string* err); - virtual int RemoveFile(const string& path); + virtual TimeStamp Stat(const std::string& path, std::string* err) const; + virtual bool MakeDir(const std::string& path); + virtual bool WriteFile(const std::string& path, const std::string& contents); + virtual Status ReadFile(const std::string& path, std::string* contents, + std::string* err); + virtual int RemoveFile(const std::string& path); /// Whether stat information can be cached. Only has an effect on Windows. void AllowStatCache(bool allow); @@ -89,10 +90,10 @@ struct RealDiskInterface : public DiskInterface { /// Whether stat information can be cached. bool use_cache_; - typedef map<string, TimeStamp> DirCache; + typedef std::map<std::string, TimeStamp> DirCache; // TODO: Neither a map nor a hashmap seems ideal here. If the statcache // works out, come up with a better data structure. - typedef map<string, DirCache> Cache; + typedef std::map<std::string, DirCache> Cache; mutable Cache cache_; #endif }; |