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

Unified Diff: util/file/file_io.h

Issue 812593005: Add LoggingSeekFile (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: SetFilePointerEx Created 6 years 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 | « no previous file | 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 5e00601ac175c13333ef50cf4fd66616fbbb9011..2c59f598883e70cf1825067d40e515b63487bb34 100644
--- a/util/file/file_io.h
+++ b/util/file/file_io.h
@@ -30,10 +30,18 @@ class FilePath;
namespace crashpad {
#if defined(OS_POSIX) || DOXYGEN
+
//! \brief Platform-specific alias for a low-level file handle.
using FileHandle = int;
+
+//! \brief Platform-specific alias for a position in an open file.
+using FileOffset = off_t;
+
#elif defined(OS_WIN)
+
using FileHandle = HANDLE;
+using FileOffset = LONGLONG;
+
#endif
//! \brief Determines the mode that LoggingOpenFileForWrite() uses.
@@ -166,6 +174,17 @@ FileHandle LoggingOpenFileForWrite(const base::FilePath& path,
FileWriteMode write_mode,
bool world_readable);
+//! \brief Wraps `lseek()` or `SetFilePointerEx()`. Logs an error if the
+//! operation fails.
+//!
+//! Repositions the offset of the open \a file to the specified \a offset,
+//! relative to \a whence. \a whence must be one of `SEEK_SET`, `SEEK_CUR`, or
+//! `SEEK_END`, and is interpreted in the usual way.
+//!
+//! \return The resulting offset in bytes from the beginning of the file, or
+//! `-1` on failure.
+FileOffset LoggingSeekFile(FileHandle file, FileOffset offset, int whence);
+
//! \brief Wraps `close()` or `CloseHandle()`, logging an error if the operation
//! fails.
//!
« no previous file with comments | « no previous file | util/file/file_io_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698