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

Unified Diff: utils/pub/io.dart

Issue 12092080: Validate packages against their SDK constraints. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise. Created 7 years, 11 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
« no previous file with comments | « utils/pub/hosted_source.dart ('k') | utils/pub/package.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/pub/io.dart
diff --git a/utils/pub/io.dart b/utils/pub/io.dart
index 8243a28190ad8bf2f88177c9f716baf275e05fbf..9dfcc9bbb47cf8ad4c83226073d4e0c15dd7effe 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -69,6 +69,7 @@ Future<bool> fileExists(file) {
(exists) => "File $path ${exists ? 'exists' : 'does not exist'}.");
}
+// TODO(rnystrom): Get rid of this and only use sync.
/// Reads the contents of the text file [file], which can either be a [String]
/// or a [File].
Future<String> readTextFile(file) {
@@ -85,6 +86,23 @@ Future<String> readTextFile(file) {
});
}
+/// Reads the contents of the text file [file], which can either be a [String]
+/// or a [File].
+String readTextFileSync(file) {
+ var path = _getPath(file);
+ log.io("Reading text file $path.");
+ var contents = new File(path).readAsStringSync(Encoding.UTF_8);
+
+ // Sanity check: don't spew a huge file.
+ if (contents.length < 1024 * 1024) {
+ log.fine("Read $path. Contents:\n$contents");
+ } else {
+ log.fine("Read ${contents.length} characters from $path.");
+ }
+
+ return contents;
+}
+
/// Reads the contents of the binary file [file], which can either be a [String]
/// or a [File].
List<int> readBinaryFile(file) {
@@ -313,6 +331,7 @@ Future<List<String>> listDir(dir,
return doList(_getDirectory(dir), new Set<String>());
}
+// TODO(rnystrom): Migrate everything over to the sync one and get rid of this.
/// Asynchronously determines if [dir], which can be a [String] directory path
/// or a [Directory], exists on the file system. Returns a [Future] that
/// completes with the result.
@@ -324,6 +343,11 @@ Future<bool> dirExists(dir) {
"${exists ? 'exists' : 'does not exist'}.");
}
+/// Determines if [dir], which can be a [String] directory path or a
+/// [Directory], exists on the file system. Returns a [Future] that completes
+/// with the result.
+bool dirExistsSync(dir) => _getDirectory(dir).existsSync();
+
/// "Cleans" [dir]. If that directory already exists, it will be deleted. Then a
/// new empty directory will be created. Returns a [Future] that completes when
/// the new clean directory is created.
« no previous file with comments | « utils/pub/hosted_source.dart ('k') | utils/pub/package.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698