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

Side by Side Diff: runtime/bin/directory_impl.dart

Issue 11023003: Clean up file implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 2 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/common.dart ('k') | runtime/bin/file_impl.dart » ('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 5
6 class _Directory implements Directory { 6 class _Directory implements Directory {
7 static const CREATE_REQUEST = 0; 7 static const CREATE_REQUEST = 0;
8 static const DELETE_REQUEST = 1; 8 static const DELETE_REQUEST = 1;
9 static const EXISTS_REQUEST = 2; 9 static const EXISTS_REQUEST = 2;
10 static const CREATE_TEMP_REQUEST = 3; 10 static const CREATE_TEMP_REQUEST = 3;
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 return new Directory(newPath); 169 return new Directory(newPath);
170 } 170 }
171 171
172 DirectoryLister list([bool recursive = false]) { 172 DirectoryLister list([bool recursive = false]) {
173 return new _DirectoryLister(_path, recursive); 173 return new _DirectoryLister(_path, recursive);
174 } 174 }
175 175
176 String get path { return _path; } 176 String get path { return _path; }
177 177
178 bool _isErrorResponse(response) { 178 bool _isErrorResponse(response) {
179 return response is List && response[0] != _FileUtils.SUCCESS_RESPONSE; 179 return response is List && response[0] != _SUCCESS_RESPONSE;
180 } 180 }
181 181
182 Exception _exceptionFromResponse(response, String message) { 182 Exception _exceptionFromResponse(response, String message) {
183 assert(_isErrorResponse(response)); 183 assert(_isErrorResponse(response));
184 switch (response[_FileUtils.ERROR_RESPONSE_ERROR_TYPE]) { 184 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) {
185 case _FileUtils.ILLEGAL_ARGUMENT_RESPONSE: 185 case _ILLEGAL_ARGUMENT_RESPONSE:
186 return new ArgumentError(); 186 return new ArgumentError();
187 case _FileUtils.OSERROR_RESPONSE: 187 case _OSERROR_RESPONSE:
188 var err = new OSError(response[_FileUtils.OSERROR_RESPONSE_MESSAGE], 188 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE],
189 response[_FileUtils.OSERROR_RESPONSE_ERROR_CODE]); 189 response[_OSERROR_RESPONSE_ERROR_CODE]);
190 return new DirectoryIOException(message, _path, err); 190 return new DirectoryIOException(message, _path, err);
191 default: 191 default:
192 return new Exception("Unknown error"); 192 return new Exception("Unknown error");
193 } 193 }
194 } 194 }
195 195
196 void _ensureDirectoryService() { 196 void _ensureDirectoryService() {
197 if (_directoryService == null) { 197 if (_directoryService == null) {
198 _directoryService = _newServicePort(); 198 _directoryService = _newServicePort();
199 } 199 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 } 231 }
232 switch (message[RESPONSE_TYPE]) { 232 switch (message[RESPONSE_TYPE]) {
233 case LIST_DIRECTORY: 233 case LIST_DIRECTORY:
234 if (_onDir != null) _onDir(message[RESPONSE_PATH]); 234 if (_onDir != null) _onDir(message[RESPONSE_PATH]);
235 break; 235 break;
236 case LIST_FILE: 236 case LIST_FILE:
237 if (_onFile != null) _onFile(message[RESPONSE_PATH]); 237 if (_onFile != null) _onFile(message[RESPONSE_PATH]);
238 break; 238 break;
239 case LIST_ERROR: 239 case LIST_ERROR:
240 var errorType = 240 var errorType =
241 message[RESPONSE_ERROR][_FileUtils.ERROR_RESPONSE_ERROR_TYPE]; 241 message[RESPONSE_ERROR][_ERROR_RESPONSE_ERROR_TYPE];
242 if (errorType == _FileUtils.ILLEGAL_ARGUMENT_RESPONSE) { 242 if (errorType == _ILLEGAL_ARGUMENT_RESPONSE) {
243 _reportError(new ArgumentError()); 243 _reportError(new ArgumentError());
244 } else if (errorType == _FileUtils.OSERROR_RESPONSE) { 244 } else if (errorType == _OSERROR_RESPONSE) {
245 var responseError = message[RESPONSE_ERROR]; 245 var responseError = message[RESPONSE_ERROR];
246 var err = new OSError( 246 var err = new OSError(
247 responseError[_FileUtils.OSERROR_RESPONSE_MESSAGE], 247 responseError[_OSERROR_RESPONSE_MESSAGE],
248 responseError[_FileUtils.OSERROR_RESPONSE_ERROR_CODE]); 248 responseError[_OSERROR_RESPONSE_ERROR_CODE]);
249 var errorPath = message[RESPONSE_PATH]; 249 var errorPath = message[RESPONSE_PATH];
250 if (errorPath == null) errorPath = path; 250 if (errorPath == null) errorPath = path;
251 _reportError(new DirectoryIOException("Directory listing failed", 251 _reportError(new DirectoryIOException("Directory listing failed",
252 errorPath, 252 errorPath,
253 err)); 253 err));
254 } else { 254 } else {
255 _reportError(new DirectoryIOException("Internal error")); 255 _reportError(new DirectoryIOException("Internal error"));
256 } 256 }
257 break; 257 break;
258 case LIST_DONE: 258 case LIST_DONE:
(...skipping 26 matching lines...) Expand all
285 } else { 285 } else {
286 throw e; 286 throw e;
287 } 287 }
288 } 288 }
289 289
290 Function _onDir; 290 Function _onDir;
291 Function _onFile; 291 Function _onFile;
292 Function _onDone; 292 Function _onDone;
293 Function _onError; 293 Function _onError;
294 } 294 }
OLDNEW
« no previous file with comments | « runtime/bin/common.dart ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698