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

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

Issue 12691002: dart:io | Add Link class, as sibling to File and Directory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of dart.io;
6
7 /**
8 * [Link] objects are references to filesystem links.
9 *
10 */
11 abstract class Link extends FileSystemEntity {
12 /**
13 * Create a Link object.
14 */
15 factory Link(String path) => new _Link(path);
16
17 /**
18 * Create a Link object from a Path object.
19 */
20 factory Link.fromPath(Path path) => new _Link.fromPath(path);
21
22 /**
23 * Check if the link exists. Returns a
24 * [:Future<bool>:] that completes when the answer is known.
Søren Gjesse 2013/03/08 10:22:31 Maybe expand this comment to say that the existenc
Bill Hesse 2013/03/08 12:04:26 Done.
Bill Hesse 2013/03/08 12:04:26 Done.
25 */
26 Future<bool> exists();
27
28 /**
29 * Synchronously check if the link exists.
Søren Gjesse 2013/03/08 10:22:31 Ditto.
30 */
31 bool existsSync();
32
33 /**
34 * Create a symbolic link. Returns a [:Future<Link>:] that completes with
35 * the link when it has been created. If the link exists, the function
36 * will throw an exception on the future.
Søren Gjesse 2013/03/08 10:22:31 "the function will throw an exception on the futur
Bill Hesse 2013/03/08 12:04:26 Done.
Bill Hesse 2013/03/08 12:04:26 Done.
37 *
38 * On the Windows platform, this will only work with directories, and the
39 * target directory must exist. The link will be created as a Junction.
40 */
41 Future<Link> create(String target);
42
43 /**
44 * Synchronously create the link. Calling [createSync] on an existing link
45 * will throw an exception.
46 *
47 * On the Windows platform, this will only work with directories, and the
48 * target directory must exist. The link will be created as a Junction.
49 */
50 void createSync();
Anders Johnsen 2013/03/08 10:11:47 String target
Bill Hesse 2013/03/08 12:04:26 Done.
Bill Hesse 2013/03/08 12:04:26 Done.
51
52 /**
53 * Updates a symbolic link to point to a different target.
Søren Gjesse 2013/03/08 10:22:31 Maybe remove symbolic here, as in all other places
Bill Hesse 2013/03/08 12:04:26 Done.
54 * Returns a [:Future<Link>:] that completes with
55 * the link when it has been created. If the link does not exist,
56 * the function will throw an exception on the future.
Søren Gjesse 2013/03/08 10:22:31 As above change to "the future will complete with
Bill Hesse 2013/03/08 12:04:26 Done.
57 *
58 * On the Windows platform, this will only work with directories, and the
59 * target directory must exist.
60 */
61 Future<Link> update(String target);
62
63 /**
64 * Synchronously update the link. Calling [updateSync] on a non-existing link
65 * will throw an exception.
66 *
67 * On the Windows platform, this will only work with directories, and the
68 * target directory must exist.
69 */
70 void updateSync();
Anders Johnsen 2013/03/08 10:11:47 String target
71
72 /**
73 * Delete the link. Returns a [:Future<Link>:] that completes with
74 * the link when it has been deleted. This does not delete, or otherwise
75 * affect, the body of the link.
Søren Gjesse 2013/03/08 10:22:31 body -> target
76 */
77 Future<Link> delete();
78
79 /**
80 * Synchronously delete the link. This does not delete, or otherwise
81 * affect, the body of the link.
Søren Gjesse 2013/03/08 10:22:31 body -> target
82 */
83 void deleteSync();
84
85 /**
86 * Get a [Directory] object for the directory containing this
87 * link. Returns a [:Future<Directory>:] that completes with the
88 * directory.
89 */
90 Future<Directory> directory();
Søren Gjesse 2013/03/08 10:22:31 Do we need directory() when we have target()?
Bill Hesse 2013/03/08 12:04:26 Directory is just the parent directory of the link
91
92 /**
93 * Synchronously get a [Directory] object for the directory containing
94 * this link.
95 */
96 Directory directorySync();
97
98 /**
99 * Get the target of the link. Returns a [:Future<FileSystemEntity>:] that
100 * is either a File, Directory, or Link.
Søren Gjesse 2013/03/08 10:22:31 What happens if the link is broken?
Bill Hesse 2013/03/08 12:04:26 Returning a String instead.
101 */
102 Future<FileSystemEntity> target();
Anders Johnsen 2013/03/08 10:11:47 Imo, this should be String
Bill Hesse 2013/03/08 12:04:26 Done.
103
104 /**
105 * Synchronously get the target of the link. Returns a [FileSystemEntity] that
106 * is either a File, Directory, or Link.
107 */
108 int targetSync();
Anders Johnsen 2013/03/08 10:11:47 FileSystemEntity or String
Bill Hesse 2013/03/08 12:04:26 Done.
109
110 /**
111 * Get the canonical full path corresponding to the link path.
112 * Returns a [:Future<String>:] that completes with the path.
113 */
114 Future<String> fullPath();
115
116 /**
117 * Synchronously get the canonical full path corresponding to the link path.
118 */
119 String fullPathSync();
120
121 /**
122 * Get the path of the link.
123 */
124 String get path;
Søren Gjesse 2013/03/08 10:22:31 Isn't path already on FileSystemEntity?
Søren Gjesse 2013/03/08 10:22:31 Should we perhaps have String get targetPath or
Anders Johnsen 2013/03/08 10:27:09 Not if the link is broken. I'm all for having a he
Bill Hesse 2013/03/08 12:04:26 yES. Removed.
Bill Hesse 2013/03/08 12:04:26 .target() now returns a string.
125 }
126
127
128 class _Link extends FileSystemEntity {
129 /**
130 * Create a Link object.
131 */
132 _Link(String path) {
133 throw new UnimplementedError("Link not implemented");
134 }
135
136 /**
137 * Create a Link object from a Path object.
138 */
139 _Link.fromPath(Path path) {
140 throw new UnimplementedError("Link not implemented");
141 }
142 }
143
144
145 class LinkIOException implements Exception {
146 const LinkIOException([String this.message = "",
147 String this.path = "",
148 OSError this.osError = null]);
149 String toString() {
150 StringBuffer sb = new StringBuffer();
151 sb.write("LinkIOException");
152 if (!message.isEmpty) {
153 sb.write(": $message");
154 if (path != null) {
155 sb.write(", path = $path");
156 }
157 if (osError != null) {
158 sb.write(" ($osError)");
159 }
160 } else if (osError != null) {
161 sb.write(": $osError");
162 if (path != null) {
163 sb.write(", path = $path");
164 }
165 }
166 return sb.toString();
167 }
168 final String message;
169 final String path;
170 final OSError osError;
171 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698