diff options
author | unknown <petr@meloun.(none)> | 2012-02-09 21:23:35 (GMT) |
---|---|---|
committer | unknown <petr@meloun.(none)> | 2012-02-09 21:23:35 (GMT) |
commit | af070e520806987bd3b175bf222774de923b62dd (patch) | |
tree | 0eff2859034dd46b6cbd8bd93fed41b8824e642e /src/disk_interface.cc | |
parent | 7504ab4e5dbb153979333c67a8a43448040b718d (diff) | |
download | Ninja-af070e520806987bd3b175bf222774de923b62dd.zip Ninja-af070e520806987bd3b175bf222774de923b62dd.tar.gz Ninja-af070e520806987bd3b175bf222774de923b62dd.tar.bz2 |
Response files
Diffstat (limited to 'src/disk_interface.cc')
-rw-r--r-- | src/disk_interface.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 789f199..96a1e59 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -103,6 +103,26 @@ TimeStamp RealDiskInterface::Stat(const string& path) { #endif } +bool RealDiskInterface::WriteFile(const string & path, const string & contents) { + FILE * fp = fopen(path.c_str(), "w"); + if (fp == NULL) { + Error("WriteFile(%s): Unable to create file. %s", path.c_str(), strerror(errno)); + return false; + } + + if (fwrite(contents.data(), 1, contents.length(), fp) < contents.length()) { + Error("WriteFile(%s): Unable to write to the file. %s", path.c_str(), strerror(errno)); + return false; + } + + if (fclose(fp) == EOF) { + Error("WriteFile(%s): Unable to close the file. %s", path.c_str(), strerror(errno)); + return false; + } + + return true; +} + bool RealDiskInterface::MakeDir(const string& path) { if (::MakeDir(path) < 0) { Error("mkdir(%s): %s", path.c_str(), strerror(errno)); |