diff options
author | Brad King <brad.king@kitware.com> | 2016-02-03 18:20:00 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-02-03 18:42:18 (GMT) |
commit | 858386d8415d2ee932fe3c01ebfbe5e0737f94a3 (patch) | |
tree | 794bd049a0217fda35c9dd3be483cca03cd3367b /src/disk_interface.h | |
parent | f9487ac7971a668ddf142d5adc741f789c7bbb68 (diff) | |
download | Ninja-858386d8415d2ee932fe3c01ebfbe5e0737f94a3.zip Ninja-858386d8415d2ee932fe3c01ebfbe5e0737f94a3.tar.gz Ninja-858386d8415d2ee932fe3c01ebfbe5e0737f94a3.tar.bz2 |
Expose more details in FileReader::ReadFile signature
Return a status so callers can distinguish a missing file from an empty
file. This allows our VirtualFileSystem test infrastructure to report
as missing any file for which it has no entry.
Diffstat (limited to 'src/disk_interface.h')
-rw-r--r-- | src/disk_interface.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/disk_interface.h b/src/disk_interface.h index 94f25dc..145e089 100644 --- a/src/disk_interface.h +++ b/src/disk_interface.h @@ -26,8 +26,17 @@ using namespace std; struct FileReader { virtual ~FileReader() {} - /// Read a file to a string. Fill in |err| on error. - virtual string ReadFile(const string& path, string* err) = 0; + /// Result of ReadFile. + enum Status { + Okay, + NotFound, + OtherError + }; + + /// 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; }; /// Interface for accessing the disk. @@ -69,7 +78,7 @@ struct RealDiskInterface : public DiskInterface { 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 string ReadFile(const string& path, string* err); + virtual Status ReadFile(const string& path, string* contents, string* err); virtual int RemoveFile(const string& path); /// Whether stat information can be cached. Only has an effect on Windows. |