Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: base/files/file_util.h

Issue 614893004: Refactor AppendToFile and WriteFileDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/files/file_util_posix.cc » ('j') | base/files/file_util_win.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains utility functions for dealing with the local 5 // This file contains utility functions for dealing with the local
6 // filesystem. 6 // filesystem.
7 7
8 #ifndef BASE_FILES_FILE_UTIL_H_ 8 #ifndef BASE_FILES_FILE_UTIL_H_
9 #define BASE_FILES_FILE_UTIL_H_ 9 #define BASE_FILES_FILE_UTIL_H_
10 10
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // Reads at most the given number of bytes from the file into the buffer. 319 // Reads at most the given number of bytes from the file into the buffer.
320 // Returns the number of read bytes, or -1 on error. 320 // Returns the number of read bytes, or -1 on error.
321 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size); 321 BASE_EXPORT int ReadFile(const FilePath& filename, char* data, int max_size);
322 322
323 // Writes the given buffer into the file, overwriting any data that was 323 // Writes the given buffer into the file, overwriting any data that was
324 // previously there. Returns the number of bytes written, or -1 on error. 324 // previously there. Returns the number of bytes written, or -1 on error.
325 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data, 325 BASE_EXPORT int WriteFile(const FilePath& filename, const char* data,
326 int size); 326 int size);
327 327
328 #if defined(OS_POSIX) 328 #if defined(OS_POSIX)
329 // Append the data to |fd|. Does not close |fd| when done. 329 // Append |data| to |fd|. Does not close |fd| when done. Returns true if all of
rvargas (doing something else) 2014/10/01 20:01:14 nit: appends
330 BASE_EXPORT int WriteFileDescriptor(const int fd, const char* data, int size); 330 // |data| was written, false otherwise. In case of error, guarantees that the
331 // last system error is preserved.
332 BASE_EXPORT bool WriteFileDescriptor(const int fd, const char* data, int size);
331 #endif 333 #endif
332 334
333 // Append the given buffer into the file. Returns the number of bytes written, 335 // Append |data| to |filename|. Returns true if all of |data| was written,
334 // or -1 on error. 336 // false otherwise. In case of error, guarantees that the last system error is
rvargas (doing something else) 2014/10/01 20:01:14 I'm a on the fence about the last error bit. There
335 BASE_EXPORT int AppendToFile(const FilePath& filename, 337 // preserved.
336 const char* data, int size); 338 BASE_EXPORT bool AppendToFile(const FilePath& filename,
339 const char* data,
340 int size);
337 341
338 // Gets the current working directory for the process. 342 // Gets the current working directory for the process.
339 BASE_EXPORT bool GetCurrentDirectory(FilePath* path); 343 BASE_EXPORT bool GetCurrentDirectory(FilePath* path);
340 344
341 // Sets the current working directory for the process. 345 // Sets the current working directory for the process.
342 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path); 346 BASE_EXPORT bool SetCurrentDirectory(const FilePath& path);
343 347
344 // Attempts to find a number that can be appended to the |path| to make it 348 // Attempts to find a number that can be appended to the |path| to make it
345 // unique. If |path| does not exist, 0 is returned. If it fails to find such 349 // unique. If |path| does not exist, 0 is returned. If it fails to find such
346 // a number, -1 is returned. If |suffix| is not empty, also checks the 350 // a number, -1 is returned. If |suffix| is not empty, also checks the
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 // This function simulates Move(), but unlike Move() it works across volumes. 434 // This function simulates Move(), but unlike Move() it works across volumes.
431 // This function is not transactional. 435 // This function is not transactional.
432 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path, 436 BASE_EXPORT bool CopyAndDeleteDirectory(const FilePath& from_path,
433 const FilePath& to_path); 437 const FilePath& to_path);
434 #endif // defined(OS_WIN) 438 #endif // defined(OS_WIN)
435 439
436 } // namespace internal 440 } // namespace internal
437 } // namespace base 441 } // namespace base
438 442
439 #endif // BASE_FILES_FILE_UTIL_H_ 443 #endif // BASE_FILES_FILE_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/file_util_posix.cc » ('j') | base/files/file_util_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698