diff options
author | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-29 12:57:10 +0000 |
---|---|---|
committer | loislo@chromium.org <loislo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-29 12:57:10 +0000 |
commit | 891128f4847bfb32e10604ced9a3b93c0272a80d (patch) | |
tree | 001b3799eda821b47e2efa01a8412a194377fc8b /base/file_util_posix.cc | |
parent | 19bacfe41d03eede36a797ea37e8c8c2a477e995 (diff) | |
download | chromium_src-891128f4847bfb32e10604ced9a3b93c0272a80d.zip chromium_src-891128f4847bfb32e10604ced9a3b93c0272a80d.tar.gz chromium_src-891128f4847bfb32e10604ced9a3b93c0272a80d.tar.bz2 |
AppendToFile implementation.
DevTools wants to save very big files like HeapSnapshots.
It is not possible at the moment because the file can be about ~6Gb.
BUG=none
TEST=FileUtilTest.AppendToFile
Review URL: http://codereview.chromium.org/10263003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 00c96fd..f1113d5 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -664,6 +664,18 @@ int WriteFileDescriptor(const int fd, const char* data, int size) { return bytes_written_total; } +int AppendToFile(const FilePath& filename, const char* data, int size) { + base::ThreadRestrictions::AssertIOAllowed(); + int fd = HANDLE_EINTR(open(filename.value().c_str(), O_WRONLY | O_APPEND)); + if (fd < 0) + return -1; + + int bytes_written = WriteFileDescriptor(fd, data, size); + if (int ret = HANDLE_EINTR(close(fd)) < 0) + return ret; + return bytes_written; +} + // Gets the current working directory for the process. bool GetCurrentDirectory(FilePath* dir) { // getcwd can return ENOENT, which implies it checks against the disk. |