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

Side by Side Diff: sdk/lib/io/link.dart

Issue 24596003: Clean up IOService implementation to be shared between patched and non-patched code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « sdk/lib/io/iolib_sources.gypi ('k') | sdk/lib/io/secure_socket.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 part of dart.io; 5 part of dart.io;
6 6
7 /** 7 /**
8 * [Link] objects are references to filesystem links. 8 * [Link] objects are references to filesystem links.
9 * 9 *
10 */ 10 */
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 Link get absolute => new Link(_absolutePath); 142 Link get absolute => new Link(_absolutePath);
143 143
144 Future<FileStat> stat() => FileStat.stat(path); 144 Future<FileStat> stat() => FileStat.stat(path);
145 145
146 FileStat statSync() => FileStat.statSync(path); 146 FileStat statSync() => FileStat.statSync(path);
147 147
148 Future<Link> create(String target) { 148 Future<Link> create(String target) {
149 if (Platform.operatingSystem == 'windows') { 149 if (Platform.operatingSystem == 'windows') {
150 target = _makeWindowsLinkTarget(target); 150 target = _makeWindowsLinkTarget(target);
151 } 151 }
152 return IOService.dispatch(FILE_CREATE_LINK, [path, target]) 152 return _IOService.dispatch(_FILE_CREATE_LINK, [path, target])
153 .then((response) { 153 .then((response) {
154 if (_isErrorResponse(response)) { 154 if (_isErrorResponse(response)) {
155 throw _exceptionFromResponse( 155 throw _exceptionFromResponse(
156 response, "Cannot create link to target '$target'", path); 156 response, "Cannot create link to target '$target'", path);
157 } 157 }
158 return this; 158 return this;
159 }); 159 });
160 } 160 }
161 161
162 void createSync(String target) { 162 void createSync(String target) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 // Atomically changing a link can be done by creating the new link, with 196 // Atomically changing a link can be done by creating the new link, with
197 // a different name, and using the rename() posix call to move it to 197 // a different name, and using the rename() posix call to move it to
198 // the old name atomically. 198 // the old name atomically.
199 return delete().then((_) => create(target)); 199 return delete().then((_) => create(target));
200 } 200 }
201 201
202 Future<Link> _delete({bool recursive: false}) { 202 Future<Link> _delete({bool recursive: false}) {
203 if (recursive) { 203 if (recursive) {
204 return new Directory(path).delete(recursive: true).then((_) => this); 204 return new Directory(path).delete(recursive: true).then((_) => this);
205 } 205 }
206 return IOService.dispatch(FILE_DELETE_LINK, [path]).then((response) { 206 return _IOService.dispatch(_FILE_DELETE_LINK, [path]).then((response) {
207 if (_isErrorResponse(response)) { 207 if (_isErrorResponse(response)) {
208 throw _exceptionFromResponse(response, "Cannot delete link", path); 208 throw _exceptionFromResponse(response, "Cannot delete link", path);
209 } 209 }
210 return this; 210 return this;
211 }); 211 });
212 } 212 }
213 213
214 void _deleteSync({bool recursive: false}) { 214 void _deleteSync({bool recursive: false}) {
215 if (recursive) { 215 if (recursive) {
216 return new Directory(path).deleteSync(recursive: true); 216 return new Directory(path).deleteSync(recursive: true);
217 } 217 }
218 var result = _File._deleteLinkNative(path); 218 var result = _File._deleteLinkNative(path);
219 throwIfError(result, "Cannot delete link", path); 219 throwIfError(result, "Cannot delete link", path);
220 } 220 }
221 221
222 Future<Link> rename(String newPath) { 222 Future<Link> rename(String newPath) {
223 return IOService.dispatch(FILE_RENAME_LINK, [path, newPath]) 223 return _IOService.dispatch(_FILE_RENAME_LINK, [path, newPath])
224 .then((response) { 224 .then((response) {
225 if (_isErrorResponse(response)) { 225 if (_isErrorResponse(response)) {
226 throw _exceptionFromResponse( 226 throw _exceptionFromResponse(
227 response, "Cannot rename link to '$newPath'", path); 227 response, "Cannot rename link to '$newPath'", path);
228 } 228 }
229 return new Link(newPath); 229 return new Link(newPath);
230 }); 230 });
231 } 231 }
232 232
233 Link renameSync(String newPath) { 233 Link renameSync(String newPath) {
234 var result = _File._renameLink(path, newPath); 234 var result = _File._renameLink(path, newPath);
235 throwIfError(result, "Cannot rename link '$path' to '$newPath'"); 235 throwIfError(result, "Cannot rename link '$path' to '$newPath'");
236 return new Link(newPath); 236 return new Link(newPath);
237 } 237 }
238 238
239 Future<String> target() { 239 Future<String> target() {
240 return IOService.dispatch(FILE_LINK_TARGET, [path]).then((response) { 240 return _IOService.dispatch(_FILE_LINK_TARGET, [path]).then((response) {
241 if (_isErrorResponse(response)) { 241 if (_isErrorResponse(response)) {
242 throw _exceptionFromResponse( 242 throw _exceptionFromResponse(
243 response, "Cannot get target of link", path); 243 response, "Cannot get target of link", path);
244 } 244 }
245 return response; 245 return response;
246 }); 246 });
247 } 247 }
248 248
249 String targetSync() { 249 String targetSync() {
250 var result = _File._linkTarget(path); 250 var result = _File._linkTarget(path);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 if (path != null) { 298 if (path != null) {
299 sb.write(", path = $path"); 299 sb.write(", path = $path");
300 } 300 }
301 } 301 }
302 return sb.toString(); 302 return sb.toString();
303 } 303 }
304 final String message; 304 final String message;
305 final String path; 305 final String path;
306 final OSError osError; 306 final OSError osError;
307 } 307 }
OLDNEW
« no previous file with comments | « sdk/lib/io/iolib_sources.gypi ('k') | sdk/lib/io/secure_socket.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698