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

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

Issue 9839053: Add error handling to random access file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r5810 Created 8 years, 9 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
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/file.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Returns a negative value if position cannot be determined. 95 // Returns a negative value if position cannot be determined.
96 off_t Position(); 96 off_t Position();
97 97
98 // Set the byte position in the file. 98 // Set the byte position in the file.
99 bool SetPosition(int64_t position); 99 bool SetPosition(int64_t position);
100 100
101 // Truncate (or extend) the file to the given length in bytes. 101 // Truncate (or extend) the file to the given length in bytes.
102 bool Truncate(int64_t length); 102 bool Truncate(int64_t length);
103 103
104 // Flush contents of file. 104 // Flush contents of file.
105 void Flush(); 105 bool Flush();
106
107 // Returns whether the file has been closed.
108 bool IsClosed();
106 109
107 const char* name() const { return name_; } 110 const char* name() const { return name_; }
108 111
109 // Open the file with the given name. The file is always opened for 112 // Open the file with the given name. The file is always opened for
110 // reading. If mode contains kWrite the file is opened for both 113 // reading. If mode contains kWrite the file is opened for both
111 // reading and writing. If mode contains kWrite and the file does 114 // reading and writing. If mode contains kWrite and the file does
112 // not exist the file is created. The file is truncated to length 0 if 115 // not exist the file is created. The file is truncated to length 0 if
113 // mode contains kTruncate. 116 // mode contains kTruncate.
114 static File* Open(const char* name, FileOpenMode mode); 117 static File* Open(const char* name, FileOpenMode mode);
115 118
(...skipping 11 matching lines...) Expand all
127 static const char* StringEscapedPathSeparator(); 130 static const char* StringEscapedPathSeparator();
128 static StdioHandleType GetStdioHandleType(int fd); 131 static StdioHandleType GetStdioHandleType(int fd);
129 132
130 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode); 133 static FileOpenMode DartModeToFileMode(DartFileOpenMode mode);
131 134
132 static Dart_Port GetServicePort(); 135 static Dart_Port GetServicePort();
133 136
134 private: 137 private:
135 File(const char* name, FileHandle* handle) : name_(name), handle_(handle) { } 138 File(const char* name, FileHandle* handle) : name_(name), handle_(handle) { }
136 void Close(); 139 void Close();
137 bool IsClosed();
138 140
139 static const int kClosedFd = -1; 141 static const int kClosedFd = -1;
140 142
141 const char* name_; 143 const char* name_;
142 // FileHandle is an OS specific class which stores data about the file. 144 // FileHandle is an OS specific class which stores data about the file.
143 FileHandle* handle_; // OS specific handle for the file. 145 FileHandle* handle_; // OS specific handle for the file.
144 146
145 // DISALLOW_COPY_AND_ASSIGN(File). 147 // DISALLOW_COPY_AND_ASSIGN(File).
146 File(const File&); 148 File(const File&);
147 void operator=(const File&); 149 void operator=(const File&);
148 150
149 static dart::Mutex mutex_; 151 static dart::Mutex mutex_;
150 static int service_ports_size_; 152 static int service_ports_size_;
151 static Dart_Port* service_ports_; 153 static Dart_Port* service_ports_;
152 static int service_ports_index_; 154 static int service_ports_index_;
153 }; 155 };
154 156
155 #endif // BIN_FILE_H_ 157 #endif // BIN_FILE_H_
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.cc ('k') | runtime/bin/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698