39 return fopen(filename.c_str(), mode.c_str());
44 FILE*
stream = fopen(filename.c_str(), mode.c_str());
45 if (stream ==
nullptr) {
46 tprintf(
"Unable to open '%s' in mode '%s'\n", filename.c_str(),
54 FILE*
stream = fopen(filename.c_str(),
"wb");
55 if (stream ==
nullptr) {
56 tprintf(
"Unable to open '%s' for writing\n", filename.c_str());
59 fputs(str.c_str(),
stream);
64 FILE*
stream = fopen(filename.c_str(),
"rb");
65 if (stream ==
nullptr) {
74 if (stream ==
nullptr)
return false;
82 return (prefix.empty() || prefix[prefix.size() - 1] ==
'/')
84 : prefix +
"/" + suffix;
88 const int status = unlink(pathname);
90 tprintf(
"ERROR: Unable to delete file %s\n", pathname);
100 HANDLE handle = FindFirstFile(pattern, &data);
101 bool all_deleted =
true;
103 for (; result; result = FindNextFile(handle, &data)) {
114 bool all_deleted =
true;
115 if (glob(pattern, 0,
nullptr, &pglob) == 0) {
116 for (paths = pglob.gl_pathv; *paths !=
nullptr; paths++) {
131 filesize_ = ftell(stream_);
138 filesize_ = ftell(stream_);
143 if (stream_ !=
nullptr) {
149 char buf[BUFSIZ + 1];
151 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
152 if (ferror(stream_)) {
163 int ret = fclose(stream_);
181 if (stream_ !=
nullptr) {
187 fputs(str.c_str(), stream_);
191 int ret = fclose(stream_);
static void WriteStringToFileOrDie(const string &str, const string &filename)
OutputBuffer(FILE *stream)
static bool DeleteMatchingFiles(const char *pattern)
static FILE * Open(const string &filename, const string &mode)
static string JoinPath(const string &prefix, const string &suffix)
static FILE * OpenOrDie(const string &filename, const string &mode)
static bool Readable(const string &filename)
void WriteString(const string &str)
static bool Delete(const char *pathname)
InputBuffer(FILE *stream)
#define INVALID_HANDLE_VALUE
static bool ReadFileToString(const string &filename, string *out)