Index: storage/browser/database/vfs_backend.cc |
diff --git a/storage/browser/database/vfs_backend.cc b/storage/browser/database/vfs_backend.cc |
index 1f8c97bfc0022efd379adec80a8234f577394042..214eada628b8f470b1115f09d3d8d5b861596d03 100644 |
--- a/storage/browser/database/vfs_backend.cc |
+++ b/storage/browser/database/vfs_backend.cc |
@@ -155,4 +155,19 @@ int64 VfsBackend::GetFileSize(const base::FilePath& file_path) { |
return (base::GetFileSize(file_path, &size) ? size : 0); |
} |
+// static |
+bool VfsBackend::SetFileSize(const base::FilePath& file_path, int64 size) { |
+ // TODO(shess): Is there a base::File sitting around to do this? Otherwise it |
michaeln
2015/03/19 00:36:33
There is not, IPC::TakeFileHandleForProcess(file.P
michaeln
2015/04/01 21:04:48
Except for incognito profiles.
Scott Hess - ex-Googler
2015/04/01 22:42:20
Seems like I should change the comment either way
|
+ // might make sense to expose truncate() somewhere rather than having to open |
+ // a file. |
+ int flags = 0; |
+ flags |= base::File::FLAG_READ; |
+ flags |= base::File::FLAG_WRITE; |
+ flags |= base::File::FLAG_OPEN; |
+ base::File file = base::File(file_path, flags); |
michaeln
2015/03/19 00:36:33
Depending on when/how xTruncate is used, seems lik
Scott Hess - ex-Googler
2015/03/25 20:24:23
On POSIX, locks are advisory only, so the file des
|
+ if (!file.IsValid()) |
+ return false; |
+ return file.SetLength(size); |
+} |
+ |
} // namespace storage |