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

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

Issue 1811643002: Add File.readAsBytesSync/writeAsBytesSync() methods. (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
« no previous file with comments | « no previous file | pkg/analyzer/lib/file_system/memory_file_system.dart » ('j') | 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) 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.file_system; 5 library analyzer.file_system.file_system;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:analyzer/src/util/absolute_path.dart'; 10 import 'package:analyzer/src/util/absolute_path.dart';
(...skipping 14 matching lines...) Expand all
25 * Throws [FileSystemException] if the file does not exist. 25 * Throws [FileSystemException] if the file does not exist.
26 */ 26 */
27 int get modificationStamp; 27 int get modificationStamp;
28 28
29 /** 29 /**
30 * Create a new [Source] instance that serves this file. 30 * Create a new [Source] instance that serves this file.
31 */ 31 */
32 Source createSource([Uri uri]); 32 Source createSource([Uri uri]);
33 33
34 /** 34 /**
35 * Synchronously read the entire file contents as a list of bytes.
36 * Throws a [FileSystemException] if the operation fails.
37 */
38 List<int> readAsBytesSync();
39
40 /**
35 * Synchronously read the entire file contents as a [String]. 41 * Synchronously read the entire file contents as a [String].
36 * Throws [FileSystemException] if the file does not exist. 42 * Throws [FileSystemException] if the file does not exist.
37 */ 43 */
38 String readAsStringSync(); 44 String readAsStringSync();
45
46 /**
47 * Synchronously write a list of bytes to the file.
48 *
49 * Throws a [FileSystemException] if the operation fails.
50 */
51 void writeAsBytesSync(List<int> bytes);
39 } 52 }
40 53
41 /** 54 /**
42 * Base class for all file system exceptions. 55 * Base class for all file system exceptions.
43 */ 56 */
44 class FileSystemException implements Exception { 57 class FileSystemException implements Exception {
45 final String path; 58 final String path;
46 final String message; 59 final String message;
47 60
48 FileSystemException(this.path, this.message); 61 FileSystemException(this.path, this.message);
49 62
50 @override 63 @override
51 String toString() => 'FileSystemException(path=$path; message=$message)'; 64 String toString() => 'FileSystemException(path=$path; message=$message)';
52 } 65 }
53 66
54 /** 67 /**
55 * [Folder]s are [Resource]s which may contain files and/or other folders. 68 * [Folder]s are [Resource]s which may contain files and/or other folders.
56 */ 69 */
57 abstract class Folder implements Resource { 70 abstract class Folder implements Resource {
58 /** 71 /**
59 * Watch for changes to the files inside this folder (and in any nested 72 * Watch for changes to the files inside this folder (and in any nested
60 * folders, including folders reachable via links). 73 * folders, including folders reachable via links).
61 */ 74 */
62 Stream<WatchEvent> get changes; 75 Stream<WatchEvent> get changes;
63 76
64 /** 77 /**
65 * If the path [path] is a relative path, convert it to an absolute path 78 * If the path [path] is a relative path, convert it to an absolute path
66 * by interpreting it relative to this folder. If it is already an aboslute 79 * by interpreting it relative to this folder. If it is already an absolute
67 * path, then don't change it. 80 * path, then don't change it.
68 * 81 *
69 * However, regardless of whether [path] is relative or absolute, normalize 82 * However, regardless of whether [path] is relative or absolute, normalize
70 * it by removing path components of the form '.' or '..'. 83 * it by removing path components of the form '.' or '..'.
71 */ 84 */
72 String canonicalizePath(String path); 85 String canonicalizePath(String path);
73 86
74 /** 87 /**
75 * Return `true` if absolute [path] references a resource in this folder. 88 * Return `true` if absolute [path] references a resource in this folder.
76 */ 89 */
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 215
203 @override 216 @override
204 Uri restoreAbsolute(Source source) => 217 Uri restoreAbsolute(Source source) =>
205 _provider.pathContext.toUri(source.fullName); 218 _provider.pathContext.toUri(source.fullName);
206 219
207 /** 220 /**
208 * Return `true` if the given [uri] is a `file` URI. 221 * Return `true` if the given [uri] is a `file` URI.
209 */ 222 */
210 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME; 223 static bool _isFileUri(Uri uri) => uri.scheme == _FILE_SCHEME;
211 } 224 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/file_system/memory_file_system.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698