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

Unified Diff: base/platform_file.h

Issue 10392181: Implement serial API for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: TerminalDevice -> FromCurrentPos Created 8 years, 7 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 | « no previous file | base/platform_file_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/platform_file.h
diff --git a/base/platform_file.h b/base/platform_file.h
index 2bfd181a16c7c0f960356710d735c2c70c4a764f..e851958500fd8af8292b8d7f120a68b77d8c304b 100644
--- a/base/platform_file.h
+++ b/base/platform_file.h
@@ -32,26 +32,29 @@ const PlatformFile kInvalidPlatformFileValue = -1;
// exactly one of the five (possibly combining with other flags) when opening
// or creating a file.
enum PlatformFileFlags {
- PLATFORM_FILE_OPEN = 1, // Opens a file, only if it exists.
- PLATFORM_FILE_CREATE = 2, // Creates a new file, only if it does not
- // already exist.
- PLATFORM_FILE_OPEN_ALWAYS = 4, // May create a new file.
- PLATFORM_FILE_CREATE_ALWAYS = 8, // May overwrite an old file.
- PLATFORM_FILE_OPEN_TRUNCATED = 16, // Opens a file and truncates it, only if
- // it exists.
- PLATFORM_FILE_READ = 32,
- PLATFORM_FILE_WRITE = 64,
- PLATFORM_FILE_EXCLUSIVE_READ = 128, // EXCLUSIVE is opposite of Windows SHARE
- PLATFORM_FILE_EXCLUSIVE_WRITE = 256,
- PLATFORM_FILE_ASYNC = 512,
- PLATFORM_FILE_TEMPORARY = 1024, // Used on Windows only
- PLATFORM_FILE_HIDDEN = 2048, // Used on Windows only
- PLATFORM_FILE_DELETE_ON_CLOSE = 4096,
-
- PLATFORM_FILE_WRITE_ATTRIBUTES = 8192, // Used on Windows only
- PLATFORM_FILE_ENUMERATE = 16384, // May enumerate directory
-
- PLATFORM_FILE_SHARE_DELETE = 32768, // Used on Windows only
+ PLATFORM_FILE_OPEN = 1 << 0, // Opens a file, only if it exists.
+ PLATFORM_FILE_CREATE = 1 << 1, // Creates a new file, only if it
+ // does not already exist.
+ PLATFORM_FILE_OPEN_ALWAYS = 1 << 2, // May create a new file.
+ PLATFORM_FILE_CREATE_ALWAYS = 1 << 3, // May overwrite an old file.
+ PLATFORM_FILE_OPEN_TRUNCATED = 1 << 4, // Opens a file and truncates it,
+ // only if it exists.
+ PLATFORM_FILE_READ = 1 << 5,
+ PLATFORM_FILE_WRITE = 1 << 6,
+ PLATFORM_FILE_EXCLUSIVE_READ = 1 << 7, // EXCLUSIVE is opposite of Windows
+ // SHARE
+ PLATFORM_FILE_EXCLUSIVE_WRITE = 1 << 8,
+ PLATFORM_FILE_ASYNC = 1 << 9,
+ PLATFORM_FILE_TEMPORARY = 1 << 10, // Used on Windows only
+ PLATFORM_FILE_HIDDEN = 1 << 11, // Used on Windows only
+ PLATFORM_FILE_DELETE_ON_CLOSE = 1 << 12,
+
+ PLATFORM_FILE_WRITE_ATTRIBUTES = 1 << 13, // Used on Windows only
+ PLATFORM_FILE_ENUMERATE = 1 << 14, // May enumerate directory
+
+ PLATFORM_FILE_SHARE_DELETE = 1 << 15, // Used on Windows only
+
+ PLATFORM_FILE_TERMINAL_DEVICE = 1 << 16, // Serial port flags
};
// PLATFORM_FILE_ERROR_ACCESS_DENIED is returned when a call fails because of
@@ -124,6 +127,10 @@ BASE_EXPORT bool ClosePlatformFile(PlatformFile file);
BASE_EXPORT int ReadPlatformFile(PlatformFile file, int64 offset,
char* data, int size);
+// Same as above but without seek.
+BASE_EXPORT int ReadPlatformFileFromCurrentPos(PlatformFile file,
+ char* data, int size);
+
// Reads the given number of bytes (or until EOF is reached) starting with the
// given offset, but does not make any effort to read all data on all platforms.
// Returns the number of bytes read, or -1 on error.
@@ -137,6 +144,10 @@ BASE_EXPORT int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
BASE_EXPORT int WritePlatformFile(PlatformFile file, int64 offset,
const char* data, int size);
+// Save as above but without seek.
+BASE_EXPORT int WritePlatformFileFromCurrentPos(PlatformFile file,
darin (slow to review) 2012/05/29 20:24:10 nitty-nit: I forgot to consider how this would loo
miket_OOO 2012/05/29 20:53:03 Very interesting! I thought of it as "reading from
+ const char* data, int size);
+
// Truncates the given file to the given length. If |length| is greater than
// the current size of the file, the file is extended with zeros. If the file
// doesn't exist, |false| is returned.
« no previous file with comments | « no previous file | base/platform_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698