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

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

Issue 9630012: Error reporting on File in dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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;
11 #else 11 #else
12 #include <stdint.h> 12 #include <stdint.h>
13 #endif 13 #endif
14 14
15 #include <stdlib.h> 15 #include <stdlib.h>
16 #include <string.h> 16 #include <string.h>
17 #include <stdio.h> 17 #include <stdio.h>
18 #include <sys/types.h> 18 #include <sys/types.h>
19 19
20 #include "bin/builtin.h" 20 #include "bin/builtin.h"
21 #include "bin/dartutils.h" 21 #include "bin/dartutils.h"
22 #include "platform/globals.h" 22 #include "platform/globals.h"
23 #include "platform/thread.h" 23 #include "platform/thread.h"
24 24
25 // Forward declaration. 25 // Forward declaration.
26 class FileHandle; 26 class FileHandle;
27 27
28 class OSError {
Mads Ager (google) 2012/03/08 15:04:27 We should move this to some place more general.
Søren Gjesse 2012/03/08 22:50:53 Moved to utils.h, but maybe we should have platfor
29 public:
30 int errno_;
31 char* strerror_;
32 };
33
28 class File { 34 class File {
29 public: 35 public:
30 enum FileOpenMode { 36 enum FileOpenMode {
31 kRead = 0, 37 kRead = 0,
32 kWrite = 1, 38 kWrite = 1,
33 kTruncate = 1 << 2, 39 kTruncate = 1 << 2,
34 kWriteTruncate = kWrite | kTruncate 40 kWriteTruncate = kWrite | kTruncate
35 }; 41 };
36 42
37 // These values have to be kept in sync with the mode values of 43 // These values have to be kept in sync with the mode values of
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Flush contents of file. 110 // Flush contents of file.
105 void Flush(); 111 void Flush();
106 112
107 const char* name() const { return name_; } 113 const char* name() const { return name_; }
108 114
109 // Open the file with the given name. The file is always opened for 115 // 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 116 // reading. If mode contains kWrite the file is opened for both
111 // reading and writing. If mode contains kWrite and the file does 117 // 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 118 // not exist the file is created. The file is truncated to length 0 if
113 // mode contains kTruncate. 119 // mode contains kTruncate.
114 static File* Open(const char* name, FileOpenMode mode); 120 static File* Open(const char* name,
121 FileOpenMode mode,
122 OSError* os_error = NULL);
115 123
116 // Create a file object for the specified stdio file descriptor 124 // Create a file object for the specified stdio file descriptor
117 // (stdin, stout or stderr). 125 // (stdin, stout or stderr).
118 static File* OpenStdio(int fd); 126 static File* OpenStdio(int fd);
119 127
120 static bool Exists(const char* name); 128 static bool Exists(const char* name);
121 static bool Create(const char* name); 129 static bool Create(const char* name);
122 static bool Delete(const char* name); 130 static bool Delete(const char* name);
123 static bool IsAbsolutePath(const char* pathname); 131 static bool IsAbsolutePath(const char* pathname);
124 static char* GetCanonicalPath(const char* name); 132 static char* GetCanonicalPath(const char* name);
(...skipping 21 matching lines...) Expand all
146 File(const File&); 154 File(const File&);
147 void operator=(const File&); 155 void operator=(const File&);
148 156
149 static dart::Mutex mutex_; 157 static dart::Mutex mutex_;
150 static int service_ports_size_; 158 static int service_ports_size_;
151 static Dart_Port* service_ports_; 159 static Dart_Port* service_ports_;
152 static int service_ports_index_; 160 static int service_ports_index_;
153 }; 161 };
154 162
155 #endif // BIN_FILE_H_ 163 #endif // BIN_FILE_H_
OLDNEW
« no previous file with comments | « runtime/bin/directory_impl.dart ('k') | runtime/bin/file.cc » ('j') | runtime/bin/file_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698