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: utils/pub/io.dart

Issue 13771010: Fix recursive directory-deletion of top-level files/links. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Actually do the right thing. Created 7 years, 8 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 | « tests/standalone/io/file_system_delete_test.dart ('k') | 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
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 /// Helper functionality to make working with IO easier. 5 /// Helper functionality to make working with IO easier.
6 library io; 6 library io;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 /// Returns whether [dir] exists on the file system. This will return `true` for 182 /// Returns whether [dir] exists on the file system. This will return `true` for
183 /// a symlink only if that symlink is unbroken and points to a directory. 183 /// a symlink only if that symlink is unbroken and points to a directory.
184 bool dirExists(String dir) => new Directory(dir).existsSync(); 184 bool dirExists(String dir) => new Directory(dir).existsSync();
185 185
186 /// Deletes whatever's at [path], whether it's a file, directory, or symlink. If 186 /// Deletes whatever's at [path], whether it's a file, directory, or symlink. If
187 /// it's a directory, it will be deleted recursively. 187 /// it's a directory, it will be deleted recursively.
188 void deleteEntry(String path) { 188 void deleteEntry(String path) {
189 if (linkExists(path)) { 189 if (linkExists(path)) {
190 log.io("Deleting link $path."); 190 log.io("Deleting link $path.");
191 if (Platform.operatingSystem == 'windows') { 191 new Link(path).deleteSync();
192 // TODO(nweiz): remove this when issue 9278 is fixed.
193 new Directory(path).deleteSync();
194 } else {
195 new Link(path).deleteSync();
196 }
197 } else if (dirExists(path)) { 192 } else if (dirExists(path)) {
198 log.io("Deleting directory $path."); 193 log.io("Deleting directory $path.");
199 new Directory(path).deleteSync(recursive: true); 194 new Directory(path).deleteSync(recursive: true);
200 } else if (fileExists(path)) { 195 } else if (fileExists(path)) {
201 log.io("Deleting file $path."); 196 log.io("Deleting file $path.");
202 new File(path).deleteSync(); 197 new File(path).deleteSync();
203 } 198 }
204 } 199 }
205 200
206 /// "Cleans" [dir]. If that directory already exists, it will be deleted. Then a 201 /// "Cleans" [dir]. If that directory already exists, it will be deleted. Then a
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 const PubProcessResult(this.stdout, this.stderr, this.exitCode); 729 const PubProcessResult(this.stdout, this.stderr, this.exitCode);
735 730
736 bool get success => exitCode == 0; 731 bool get success => exitCode == 0;
737 } 732 }
738 733
739 /// Gets a [Uri] for [uri], which can either already be one, or be a [String]. 734 /// Gets a [Uri] for [uri], which can either already be one, or be a [String].
740 Uri _getUri(uri) { 735 Uri _getUri(uri) {
741 if (uri is Uri) return uri; 736 if (uri is Uri) return uri;
742 return Uri.parse(uri); 737 return Uri.parse(uri);
743 } 738 }
OLDNEW
« no previous file with comments | « tests/standalone/io/file_system_delete_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698