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

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

Issue 17848003: dart:io | Add rename to Link (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix again Created 7 years, 6 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/file_impl.dart ('k') | tests/standalone/io/link_async_test.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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 /** 75 /**
76 * Synchronously deletes the link. This does not delete, or otherwise 76 * Synchronously deletes the link. This does not delete, or otherwise
77 * affect, the target of the link. It also works on broken links, but if 77 * affect, the target of the link. It also works on broken links, but if
78 * the link does not exist or is not actually a link, it throws a 78 * the link does not exist or is not actually a link, it throws a
79 * LinkException. 79 * LinkException.
80 */ 80 */
81 void deleteSync(); 81 void deleteSync();
82 82
83 /** 83 /**
84 * Renames this link. Returns a `Future<Link>` that completes
85 * with a [Link] instance for the renamed link.
86 *
87 * If [newPath] identifies an existing link, that link is
88 * replaced. If [newPath] identifies an existing file or directory,
89 * the operation fails and the future completes with an exception.
90 */
91 Future<Link> rename(String newPath);
92
93 /**
94 * Synchronously renames this link. Returns a [Link]
95 * instance for the renamed link.
96 *
97 * If [newPath] identifies an existing link, that link is
98 * replaced. If [newPath] identifies an existing file or directory
99 * the operation fails and an exception is thrown.
100 */
101 Link renameSync(String newPath);
102
103 /**
84 * Gets the target of the link. Returns a future that completes with 104 * Gets the target of the link. Returns a future that completes with
85 * the path to the target. 105 * the path to the target.
86 * 106 *
87 * If the returned target is a relative path, it is relative to the 107 * If the returned target is a relative path, it is relative to the
88 * directory containing the link. 108 * directory containing the link.
89 * 109 *
90 * If the link does not exist, or is not a link, the future completes with 110 * If the link does not exist, or is not a link, the future completes with
91 * a LinkException. 111 * a LinkException.
92 */ 112 */
93 Future<String> target(); 113 Future<String> target();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 208 }
189 return this; 209 return this;
190 }); 210 });
191 } 211 }
192 212
193 void deleteSync() { 213 void deleteSync() {
194 var result = _File._deleteLink(path); 214 var result = _File._deleteLink(path);
195 throwIfError(result, "Cannot delete link", path); 215 throwIfError(result, "Cannot delete link", path);
196 } 216 }
197 217
218 Future<Link> rename(String newPath) {
219 _ensureFileService();
220 List request = new List(3);
221 request[0] = _RENAME_LINK_REQUEST;
222 request[1] = path;
223 request[2] = newPath;
224 return _fileService.call(request).then((response) {
225 if (_isErrorResponse(response)) {
226 throw _exceptionFromResponse(
227 response, "Cannot rename link '$_path' to '$newPath'");
228 }
229 return new Link(newPath);
230 });
231 }
232
233 Link renameSync(String newPath) {
234 var result = _File._renameLink(path, newPath);
235 throwIfError(result, "Cannot rename link '$path' to '$newPath'");
236 return new Link(newPath);
237 }
238
198 Future<String> target() { 239 Future<String> target() {
199 _ensureFileService(); 240 _ensureFileService();
200 List request = new List(2); 241 List request = new List(2);
201 request[0] = _LINK_TARGET_REQUEST; 242 request[0] = _LINK_TARGET_REQUEST;
202 request[1] = path; 243 request[1] = path;
203 return _fileService.call(request).then((response) { 244 return _fileService.call(request).then((response) {
204 if (_isErrorResponse(response)) { 245 if (_isErrorResponse(response)) {
205 throw _exceptionFromResponse(response, 246 throw _exceptionFromResponse(response,
206 "Cannot get target of link '$path'"); 247 "Cannot get target of link '$path'");
207 } 248 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (path != null) { 308 if (path != null) {
268 sb.write(", path = $path"); 309 sb.write(", path = $path");
269 } 310 }
270 } 311 }
271 return sb.toString(); 312 return sb.toString();
272 } 313 }
273 final String message; 314 final String message;
274 final String path; 315 final String path;
275 final OSError osError; 316 final OSError osError;
276 } 317 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | tests/standalone/io/link_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698