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

Side by Side Diff: pkg/analyzer/lib/file_system/physical_file_system.dart

Issue 1808213004: Add File.renameSync() to virtual file system. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analyzer.file_system.physical_file_system; 5 library analyzer.file_system.physical_file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:core' hide Resource; 8 import 'dart:core' hide Resource;
9 import 'dart:io' as io; 9 import 'dart:io' as io;
10 10
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 133
134 @override 134 @override
135 void writeAsBytesSync(List<int> bytes) { 135 void writeAsBytesSync(List<int> bytes) {
136 try { 136 try {
137 io.File file = _entry as io.File; 137 io.File file = _entry as io.File;
138 file.writeAsBytesSync(bytes); 138 file.writeAsBytesSync(bytes);
139 } on io.FileSystemException catch (exception) { 139 } on io.FileSystemException catch (exception) {
140 throw new FileSystemException(exception.path, exception.message); 140 throw new FileSystemException(exception.path, exception.message);
141 } 141 }
142 } 142 }
143
144 @override
145 Resource renameSync(String newPath) {
146 try {
147 io.File file = _entry as io.File;
148 io.File newFile = file.renameSync(newPath);
149 return new _PhysicalFile(newFile);
150 } on io.FileSystemException catch (exception) {
151 throw new FileSystemException(exception.path, exception.message);
152 }
153 }
143 } 154 }
144 155
145 /** 156 /**
146 * A `dart:io` based implementation of [Folder]. 157 * A `dart:io` based implementation of [Folder].
147 */ 158 */
148 class _PhysicalFolder extends _PhysicalResource implements Folder { 159 class _PhysicalFolder extends _PhysicalResource implements Folder {
149 _PhysicalFolder(io.Directory directory) : super(directory); 160 _PhysicalFolder(io.Directory directory) : super(directory);
150 161
151 @override 162 @override
152 Stream<WatchEvent> get changes => new DirectoryWatcher(_entry.path).events; 163 Stream<WatchEvent> get changes => new DirectoryWatcher(_entry.path).events;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 bool operator ==(other) { 251 bool operator ==(other) {
241 if (runtimeType != other.runtimeType) { 252 if (runtimeType != other.runtimeType) {
242 return false; 253 return false;
243 } 254 }
244 return path == other.path; 255 return path == other.path;
245 } 256 }
246 257
247 @override 258 @override
248 String toString() => path; 259 String toString() => path;
249 } 260 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698