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

Unified Diff: pkg/analyzer/lib/file_system/physical_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/physical_file_system.dart
diff --git a/pkg/analyzer/lib/file_system/physical_file_system.dart b/pkg/analyzer/lib/file_system/physical_file_system.dart
index b190c1bf9a45cd6946163b89c2f89df94d814597..f3906be89b2ffff8c81dc929504dfe1bd9cfc848 100644
--- a/pkg/analyzer/lib/file_system/physical_file_system.dart
+++ b/pkg/analyzer/lib/file_system/physical_file_system.dart
@@ -150,6 +150,14 @@ class _PhysicalFile extends _PhysicalResource implements File {
io.File get _file => _entry as io.File;
@override
+ File copyTo(Folder parentFolder) {
+ parentFolder.create();
+ File destination = parentFolder.getChildAssumingFile(shortName);
+ destination.writeAsBytesSync(readAsBytesSync());
+ return destination;
+ }
+
+ @override
Source createSource([Uri uri]) {
return new FileSource(this, uri ?? pathContext.toUri(path));
}
@@ -246,6 +254,21 @@ class _PhysicalFolder extends _PhysicalResource 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() {
+ _directory.createSync(recursive: true);
+ }
+
+ @override
Resource getChild(String relPath) {
String canonicalPath = canonicalizePath(relPath);
return PhysicalResourceProvider.INSTANCE.getResource(canonicalPath);
« no previous file with comments | « pkg/analyzer/lib/file_system/memory_file_system.dart ('k') | pkg/analyzer/test/file_system/memory_file_system_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698