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

Side by Side 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 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.memory_file_system; 5 library analyzer.file_system.memory_file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert'; 9 import 'dart:convert';
10 import 'dart:core'; 10 import 'dart:core';
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 @override 319 @override
320 int get modificationStamp { 320 int get modificationStamp {
321 int stamp = _provider._pathToTimestamp[path]; 321 int stamp = _provider._pathToTimestamp[path];
322 if (stamp == null) { 322 if (stamp == null) {
323 throw new FileSystemException(path, "File does not exist"); 323 throw new FileSystemException(path, "File does not exist");
324 } 324 }
325 return stamp; 325 return stamp;
326 } 326 }
327 327
328 @override 328 @override
329 File copyTo(Folder parentFolder) {
330 throw new FileSystemException(path, 'File could not be copied');
331 }
332
333 @override
329 Source createSource([Uri uri]) { 334 Source createSource([Uri uri]) {
330 throw new FileSystemException(path, 'File could not be read'); 335 throw new FileSystemException(path, 'File could not be read');
331 } 336 }
332 337
333 @override 338 @override
334 void delete() { 339 void delete() {
335 throw new FileSystemException(path, 'File could not be deleted'); 340 throw new FileSystemException(path, 'File could not be deleted');
336 } 341 }
337 342
338 @override 343 @override
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 @override 394 @override
390 int get modificationStamp { 395 int get modificationStamp {
391 int stamp = _provider._pathToTimestamp[path]; 396 int stamp = _provider._pathToTimestamp[path];
392 if (stamp == null) { 397 if (stamp == null) {
393 throw new FileSystemException(path, 'File "$path" does not exist.'); 398 throw new FileSystemException(path, 'File "$path" does not exist.');
394 } 399 }
395 return stamp; 400 return stamp;
396 } 401 }
397 402
398 @override 403 @override
404 File copyTo(Folder parentFolder) {
405 parentFolder.create();
406 File destination = parentFolder.getChildAssumingFile(shortName);
407 destination.writeAsBytesSync(readAsBytesSync());
408 return destination;
409 }
410
411 @override
399 Source createSource([Uri uri]) { 412 Source createSource([Uri uri]) {
400 uri ??= _provider.pathContext.toUri(path); 413 uri ??= _provider.pathContext.toUri(path);
401 return new FileSource(this, uri); 414 return new FileSource(this, uri);
402 } 415 }
403 416
404 @override 417 @override
405 void delete() { 418 void delete() {
406 _provider.deleteFile(path); 419 _provider.deleteFile(path);
407 } 420 }
408 421
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 childPath = _provider.pathContext.normalize(childPath); 478 childPath = _provider.pathContext.normalize(childPath);
466 return childPath; 479 return childPath;
467 } 480 }
468 481
469 @override 482 @override
470 bool contains(String path) { 483 bool contains(String path) {
471 return _provider.pathContext.isWithin(this.path, path); 484 return _provider.pathContext.isWithin(this.path, path);
472 } 485 }
473 486
474 @override 487 @override
488 Folder copyTo(Folder parentFolder) {
489 Folder destination = parentFolder.getChildAssumingFolder(shortName);
490 destination.create();
491 for (Resource child in getChildren()) {
492 child.copyTo(destination);
493 }
494 return destination;
495 }
496
497 @override
498 void create() {
499 _provider.newFolder(path);
500 }
501
502 @override
475 void delete() { 503 void delete() {
476 _provider.deleteFolder(path); 504 _provider.deleteFolder(path);
477 } 505 }
478 506
479 @override 507 @override
480 Resource getChild(String relPath) { 508 Resource getChild(String relPath) {
481 String childPath = canonicalizePath(relPath); 509 String childPath = canonicalizePath(relPath);
482 _MemoryResource resource = _provider._pathToResource[childPath]; 510 _MemoryResource resource = _provider._pathToResource[childPath];
483 if (resource == null) { 511 if (resource == null) {
484 resource = new _MemoryFile(_provider, childPath); 512 resource = new _MemoryFile(_provider, childPath);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 608 }
581 return path == other.path; 609 return path == other.path;
582 } 610 }
583 611
584 @override 612 @override
585 String toString() => path; 613 String toString() => path;
586 614
587 @override 615 @override
588 Uri toUri() => _provider.pathContext.toUri(path); 616 Uri toUri() => _provider.pathContext.toUri(path);
589 } 617 }
OLDNEW
« 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