diff options
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. |