43 return fopen(filename.c_str(), mode.c_str());
48 FILE* stream = fopen(filename.c_str(), mode.c_str());
49 if (stream ==
nullptr) {
50 tprintf(
"Unable to open '%s' in mode '%s': %s\n", filename.c_str(),
51 mode.c_str(), strerror(errno));
58 FILE* stream = fopen(filename.c_str(),
"wb");
59 if (stream ==
nullptr) {
60 tprintf(
"Unable to open '%s' for writing: %s\n",
61 filename.c_str(), strerror(errno));
64 fputs(str.c_str(), stream);
69 FILE* stream = fopen(filename.c_str(),
"rb");
70 if (stream ==
nullptr) {
78 FILE* stream =
File::Open(filename.c_str(),
"rb");
79 if (stream ==
nullptr)
return false;
83 return in.CloseFile();
87 return (prefix.empty() || prefix[prefix.size() - 1] ==
'/')
89 : prefix +
"/" + suffix;
93 #if !defined(_WIN32) || defined(__MINGW32__)
94 const int status = unlink(pathname);
96 const int status = _unlink(pathname);
99 tprintf(
"ERROR: Unable to delete file '%s$: %s\n", pathname,
108 WIN32_FIND_DATA data;
110 HANDLE handle = FindFirstFile(pattern, &data);
111 bool all_deleted =
true;
112 if (handle != INVALID_HANDLE_VALUE) {
113 for (; result; result = FindNextFile(handle, &data)) {
124 bool all_deleted =
true;
125 if (glob(pattern, 0,
nullptr, &pglob) == 0) {
126 for (paths = pglob.gl_pathv; *paths !=
nullptr; paths++) {
147 if (stream_ !=
nullptr) {
153 char buf[BUFSIZ + 1];
155 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
156 if (ferror(stream_)) {
167 int ret = fclose(stream_);
185 if (stream_ !=
nullptr) {
191 fputs(str.c_str(), stream_);
195 int ret = fclose(stream_);