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

Unified Diff: util/file/file_io.h

Issue 999953002: Use LockFile/UnlockFile for Settings to port to Windows (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@lock-fileio-2
Patch Set: Tag inside, no info spam Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/settings_test.cc ('k') | util/file/file_io_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/file/file_io.h
diff --git a/util/file/file_io.h b/util/file/file_io.h
index 5d5a957d79b3eb19861d314ed3e26d532849555d..c3120c9639875cff165c4b2acca0c5fd072fc232 100644
--- a/util/file/file_io.h
+++ b/util/file/file_io.h
@@ -188,9 +188,9 @@ FileHandle LoggingOpenFileForRead(const base::FilePath& path);
//! \brief Wraps `open()` or `CreateFile()`, creating a file for output. Logs
//! an error if the operation fails.
//!
-//! \a write_mode determines the style (truncate, reuse, etc.) that is used to
-//! open the file. On POSIX, \a permissions determines the value that is passed
-//! as `mode` to `open()`. On Windows, the file is always opened in binary mode
+//! \a mode determines the style (truncate, reuse, etc.) that is used to open
+//! the file. On POSIX, \a permissions determines the value that is passed as
+//! `mode` to `open()`. On Windows, the file is always opened in binary mode
//! (that is, no CRLF translation). On Windows, the file is opened for sharing,
//! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access.
//!
@@ -200,9 +200,27 @@ FileHandle LoggingOpenFileForRead(const base::FilePath& path);
//! \sa FilePermissions
//! \sa ScopedFileHandle
FileHandle LoggingOpenFileForWrite(const base::FilePath& path,
- FileWriteMode write_mode,
+ FileWriteMode mode,
FilePermissions permissions);
+//! \brief Wraps `open()` or `CreateFile()`, creating a file for both input and
+//! output. Logs an error if the operation fails.
+//!
+//! \a mode determines the style (truncate, reuse, etc.) that is used to open
+//! the file. On POSIX, \a permissions determines the value that is passed as
+//! `mode` to `open()`. On Windows, the file is always opened in binary mode
+//! (that is, no CRLF translation). On Windows, the file is opened for sharing,
+//! see LoggingLockFile() and LoggingUnlockFile() to control concurrent access.
+//!
+//! \return The newly opened FileHandle, or an invalid FileHandle on failure.
+//!
+//! \sa FileWriteMode
+//! \sa FilePermissions
+//! \sa ScopedFileHandle
+FileHandle LoggingOpenFileForReadAndWrite(const base::FilePath& path,
+ FileWriteMode mode,
+ FilePermissions permissions);
+
//! \brief Locks the given \a file using `flock()` on POSIX or `LockFileEx()` on
//! Windows.
//!
@@ -243,6 +261,11 @@ bool LoggingUnlockFile(FileHandle file);
//! `-1` on failure.
FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence);
+//! \brief Truncates the given \a file to zero bytes in length.
+//!
+//! \return `true` on success, or `false`, and a message will be logged.
+bool LoggingTruncateFile(FileHandle file);
+
//! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation
//! fails.
//!
« no previous file with comments | « client/settings_test.cc ('k') | util/file/file_io_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698