55 FILE* stream = fopen(
filename.c_str(),
"wb");
60 fputs(str.c_str(), stream);
65 FILE* stream = fopen(
filename.c_str(),
"rb");
84 return (prefix.empty() || prefix[prefix.size() - 1] ==
'/')
86 : prefix +
"/" + suffix;
90 const int status = unlink(pathname);
92 tprintf(
"ERROR: Unable to delete file %s\n", pathname);
100 WIN32_FIND_DATA data;
102 HANDLE handle = FindFirstFile(pattern, &data);
103 bool all_deleted =
true;
104 if (handle != INVALID_HANDLE_VALUE) {
105 for (; result; result = FindNextFile(handle, &data)) {
116 bool all_deleted =
true;
117 if (glob(pattern, 0, NULL, &pglob) == 0) {
118 for (paths = pglob.gl_pathv; *paths != NULL; paths++) {
132 fseek(stream_, 0, SEEK_END);
133 filesize_ = ftell(stream_);
134 fseek(stream_, 0, SEEK_SET);
139 fseek(stream_, 0, SEEK_END);
140 filesize_ = ftell(stream_);
141 fseek(stream_, 0, SEEK_SET);
145 if (stream_ != NULL) {
151 char buf[BUFSIZ + 1];
153 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
154 if (ferror(stream_)) {
165 int ret = fclose(stream_);
183 if (stream_ != NULL) {
189 fputs(str.c_str(), stream_);
193 int ret = fclose(stream_);
static bool DeleteMatchingFiles(const char *pattern)
OutputBuffer(FILE *stream)
static bool Readable(const string &filename)
static FILE * OpenOrDie(const string &filename, const string &mode)
InputBuffer(FILE *stream)
static FILE * Open(const string &filename, const string &mode)
static bool ReadFileToString(const string &filename, string *out)
void WriteString(const string &str)
static string JoinPath(const string &prefix, const string &suffix)
static bool Delete(const char *pathname)
static void WriteStringToFileOrDie(const string &str, const string &filename)