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

Unified Diff: base/platform_file_posix.cc

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
Index: base/platform_file_posix.cc
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
index 9b42c7a184fea0d22ee060e1e3022c87325686c3..8023b82e36d7c3448d4cd2d62873b5650ee19d2a 100644
--- a/base/platform_file_posix.cc
+++ b/base/platform_file_posix.cc
@@ -78,6 +78,9 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
NOTREACHED();
}
+ if (flags & PLATFORM_FILE_TERMINAL_DEVICE)
+ open_flags |= O_NOCTTY | O_NDELAY;
+
COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero);
int mode = S_IRUSR | S_IWUSR;
@@ -175,6 +178,24 @@ int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
return bytes_read ? bytes_read : rv;
}
+int ReadPlatformFileFromCurrentPos(PlatformFile file, char* data, int size) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || size < 0)
+ return -1;
+
+ int bytes_read = 0;
+ int rv;
+ do {
+ rv = HANDLE_EINTR(read(file, data, size));
+ if (rv <= 0)
+ break;
+
+ bytes_read += rv;
+ } while (bytes_read < size);
+
+ return bytes_read ? bytes_read : rv;
+}
+
int ReadPlatformFileNoBestEffort(PlatformFile file, int64 offset,
char* data, int size) {
base::ThreadRestrictions::AssertIOAllowed();
@@ -204,6 +225,25 @@ int WritePlatformFile(PlatformFile file, int64 offset,
return bytes_written ? bytes_written : rv;
}
+int WritePlatformFileFromCurrentPos(PlatformFile file,
+ const char* data, int size) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ if (file < 0 || size < 0)
+ return -1;
+
+ int bytes_written = 0;
+ int rv;
+ do {
+ rv = HANDLE_EINTR(write(file, data, size));
+ if (rv <= 0)
+ break;
+
+ bytes_written += rv;
+ } while (bytes_written < size);
+
+ return bytes_written ? bytes_written : rv;
+}
+
bool TruncatePlatformFile(PlatformFile file, int64 length) {
base::ThreadRestrictions::AssertIOAllowed();
return ((file >= 0) && !HANDLE_EINTR(ftruncate(file, length)));
« base/platform_file.h ('K') | « base/platform_file.h ('k') | base/platform_file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698