| Index: base/file_util.cc
|
| diff --git a/base/file_util.cc b/base/file_util.cc
|
| index 078e3afa2e5ac6c2271fb9436c18ec16d2e2db75..8ecb1cc1d5640c727b57a09219cc5c2b46eff0d8 100644
|
| --- a/base/file_util.cc
|
| +++ b/base/file_util.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "base/file_util.h"
|
|
|
| +#if defined(OS_WIN)
|
| +#include <io.h>
|
| +#endif
|
| #include <stdio.h>
|
|
|
| #include <fstream>
|
| @@ -276,6 +279,24 @@ bool CloseFile(FILE* file) {
|
| return fclose(file) == 0;
|
| }
|
|
|
| +bool TruncateFile(FILE* file) {
|
| + if (file == NULL)
|
| + return false;
|
| + long current_offset = ftell(file);
|
| + if (current_offset == -1)
|
| + return false;
|
| +#if defined(OS_WIN)
|
| + int fd = _fileno(file);
|
| + if (_chsize(fd, current_offset) != 0)
|
| + return false;
|
| +#else
|
| + int fd = fileno(file);
|
| + if (ftruncate(fd, current_offset) != 0)
|
| + return false;
|
| +#endif
|
| + return true;
|
| +}
|
| +
|
| bool ContainsPath(const FilePath &parent, const FilePath& child) {
|
| FilePath abs_parent = FilePath(parent);
|
| FilePath abs_child = FilePath(child);
|
|
|