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

Side by Side Diff: runtime/bin/file.h

Issue 9415043: Port async file operations to be using native ports instead or an isolate (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed remaining issues Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef BIN_FILE_H_ 5 #ifndef BIN_FILE_H_
6 #define BIN_FILE_H_ 6 #define BIN_FILE_H_
7 7
8 #if defined(_WIN32) 8 #if defined(_WIN32)
9 typedef signed __int64 int64_t; 9 typedef signed __int64 int64_t;
10 typedef unsigned __int8 uint8_t; 10 typedef unsigned __int8 uint8_t;
(...skipping 11 matching lines...) Expand all
22 22
23 class File { 23 class File {
24 public: 24 public:
25 enum FileOpenMode { 25 enum FileOpenMode {
26 kRead = 0, 26 kRead = 0,
27 kWrite = 1, 27 kWrite = 1,
28 kTruncate = 1 << 2, 28 kTruncate = 1 << 2,
29 kWriteTruncate = kWrite | kTruncate 29 kWriteTruncate = kWrite | kTruncate
30 }; 30 };
31 31
32 // These values have to be kept in sync with the mode values of
33 // FileMode.READ, FileMode.WRITE and FileMode.APPEND in file.dart.
34 enum DartFileOpenMode {
35 kDartRead = 0,
36 kDartWrite = 1,
37 kDartAppend = 2
38 };
39
32 enum StdioHandleType { 40 enum StdioHandleType {
33 kTerminal = 0, 41 kTerminal = 0,
34 kPipe = 1, 42 kPipe = 1,
35 kFile = 2, 43 kFile = 2,
36 kOther = 3 44 kOther = 3
37 }; 45 };
38 46
47 enum FileRequest {
48 kExistsRequest = 0,
49 kCreateRequest = 1,
50 kDeleteRequest = 2,
51 kOpenRequest = 3,
52 kFullPathRequest = 4,
53 kCloseRequest = 5,
54 kPositionRequest = 6,
55 kSetPositionRequest = 7,
56 kTruncateRequest = 8,
57 kLengthRequest = 9,
58 kFlushRequest = 10,
59 kReadByteRequest = 11,
60 kWriteByteRequest = 12,
61 kReadListRequest = 13,
62 kWriteListRequest = 14,
63 kWriteStringRequest = 15
64 };
65
39 ~File(); 66 ~File();
40 67
41 // Read/Write attempt to transfer num_bytes to/from buffer. It returns 68 // Read/Write attempt to transfer num_bytes to/from buffer. It returns
42 // the number of bytes read/written. 69 // the number of bytes read/written.
43 int64_t Read(void* buffer, int64_t num_bytes); 70 int64_t Read(void* buffer, int64_t num_bytes);
44 int64_t Write(const void* buffer, int64_t num_bytes); 71 int64_t Write(const void* buffer, int64_t num_bytes);
45 72
46 // ReadFully and WriteFully do attempt to transfer num_bytes to/from 73 // ReadFully and WriteFully do attempt to transfer num_bytes to/from
47 // the buffer. In the event of short accesses they will loop internally until 74 // the buffer. In the event of short accesses they will loop internally until
48 // the whole buffer has been transferred or an error occurs. If an error 75 // the whole buffer has been transferred or an error occurs. If an error
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 112
86 static bool Exists(const char* name); 113 static bool Exists(const char* name);
87 static bool Create(const char* name); 114 static bool Create(const char* name);
88 static bool Delete(const char* name); 115 static bool Delete(const char* name);
89 static bool IsAbsolutePath(const char* pathname); 116 static bool IsAbsolutePath(const char* pathname);
90 static char* GetCanonicalPath(const char* name); 117 static char* GetCanonicalPath(const char* name);
91 static const char* PathSeparator(); 118 static const char* PathSeparator();
92 static const char* StringEscapedPathSeparator(); 119 static const char* StringEscapedPathSeparator();
93 static StdioHandleType GetStdioHandleType(int fd); 120 static StdioHandleType GetStdioHandleType(int fd);
94 121
122 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode);
123
95 private: 124 private:
96 File(const char* name, FileHandle* handle) : name_(name), handle_(handle) { } 125 File(const char* name, FileHandle* handle) : name_(name), handle_(handle) { }
97 void Close(); 126 void Close();
98 bool IsClosed(); 127 bool IsClosed();
99 128
100 static const int kClosedFd = -1; 129 static const int kClosedFd = -1;
101 130
102 const char* name_; 131 const char* name_;
103 // FileHandle is an OS specific class which stores data about the file. 132 // FileHandle is an OS specific class which stores data about the file.
104 FileHandle* handle_; // OS specific handle for the file. 133 FileHandle* handle_; // OS specific handle for the file.
105 134
106 // DISALLOW_COPY_AND_ASSIGN(File). 135 // DISALLOW_COPY_AND_ASSIGN(File).
107 File(const File&); 136 File(const File&);
108 void operator=(const File&); 137 void operator=(const File&);
109 }; 138 };
110 139
111 #endif // BIN_FILE_H_ 140 #endif // BIN_FILE_H_
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/file.cc » ('j') | runtime/bin/file.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698