40 return fopen(filename.c_str(), mode.c_str());
45 FILE* stream = fopen(filename.c_str(), mode.c_str());
47 tprintf(
"Unable to open '%s' in mode '%s'\n", filename.c_str(),
55 FILE* stream = fopen(filename.c_str(),
"wb");
57 tprintf(
"Unable to open '%s' for writing\n", filename.c_str());
60 fputs(str.c_str(), stream);
65 FILE* stream = fopen(filename.c_str(),
"rb");
74 FILE* stream =
File::Open(filename.c_str(),
"rb");
85 "Failed to read file: %s\n", filename.c_str());
90 return (!prefix.size() || prefix[prefix.size() - 1] ==
'/') ?
91 prefix + suffix : prefix +
"/" + suffix;
95 const int status = unlink(pathname);
97 tprintf(
"ERROR: Unable to delete file %s\n", pathname);
105 WIN32_FIND_DATA data;
107 HANDLE handle = FindFirstFile(pattern, &data);
108 bool all_deleted =
true;
109 if (handle != INVALID_HANDLE_VALUE) {
110 for (; result; result = FindNextFile(handle, &data)) {
121 bool all_deleted =
true;
122 if (glob(pattern, 0,
NULL, &pglob) == 0) {
123 for (paths = pglob.gl_pathv; *paths !=
NULL; paths++) {
137 fseek(stream_, 0, SEEK_END);
138 filesize_ = ftell(stream_);
139 fseek(stream_, 0, SEEK_SET);
144 fseek(stream_, 0, SEEK_END);
145 filesize_ = ftell(stream_);
146 fseek(stream_, 0, SEEK_SET);
150 if (stream_ !=
NULL) {
156 char buf[BUFSIZ + 1];
158 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
159 if (ferror(stream_)) {
170 int ret = fclose(stream_);
188 if (stream_ !=
NULL) {
194 fputs(str.c_str(), stream_);
198 int ret = fclose(stream_);
static bool ReadFileToString(const string &filename, string *out)
void WriteString(const string &str)
static bool Readable(const string &filename)
static string JoinPath(const string &prefix, const string &suffix)
static bool Delete(const char *pathname)
static FILE * OpenOrDie(const string &filename, const string &mode)
static void WriteStringToFileOrDie(const string &str, const string &filename)
#define ASSERT_HOST_MSG(x, msg...)
static bool DeleteMatchingFiles(const char *pattern)
static FILE * Open(const string &filename, const string &mode)
OutputBuffer(FILE *stream)
static void ReadFileToStringOrDie(const string &filename, string *out)
InputBuffer(FILE *stream)