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

Unified Diff: pkg/analyzer/lib/file_system/memory_file_system.dart

Issue 2733053002: Add support for copying directory structures (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/file_system/memory_file_system.dart
diff --git a/pkg/analyzer/lib/file_system/memory_file_system.dart b/pkg/analyzer/lib/file_system/memory_file_system.dart
index 3cab6ee8995aed9cfaed5d5a10d6a66cc98174a8..6e7ab642e104bd94fd18f642df1b0a51759f54a6 100644
--- a/pkg/analyzer/lib/file_system/memory_file_system.dart
+++ b/pkg/analyzer/lib/file_system/memory_file_system.dart
@@ -326,6 +326,11 @@ class _MemoryDummyLink extends _MemoryResource implements File {
}
@override
+ File copyTo(Folder parentFolder) {
+ throw new FileSystemException(path, 'File could not be copied');
+ }
+
+ @override
Source createSource([Uri uri]) {
throw new FileSystemException(path, 'File could not be read');
}
@@ -396,6 +401,14 @@ class _MemoryFile extends _MemoryResource implements File {
}
@override
+ File copyTo(Folder parentFolder) {
+ parentFolder.create();
+ File destination = parentFolder.getChildAssumingFile(shortName);
+ destination.writeAsBytesSync(readAsBytesSync());
+ return destination;
+ }
+
+ @override
Source createSource([Uri uri]) {
uri ??= _provider.pathContext.toUri(path);
return new FileSource(this, uri);
@@ -472,6 +485,21 @@ class _MemoryFolder extends _MemoryResource implements Folder {
}
@override
+ Folder copyTo(Folder parentFolder) {
+ Folder destination = parentFolder.getChildAssumingFolder(shortName);
+ destination.create();
+ for (Resource child in getChildren()) {
+ child.copyTo(destination);
+ }
+ return destination;
+ }
+
+ @override
+ void create() {
+ _provider.newFolder(path);
+ }
+
+ @override
void delete() {
_provider.deleteFolder(path);
}
« no previous file with comments | « pkg/analyzer/lib/file_system/file_system.dart ('k') | pkg/analyzer/lib/file_system/physical_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698