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

Unified Diff: utils/pub/io.dart

Issue 11638010: Convert /** comments to /// in pub. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 8 years 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/http.dart ('k') | utils/pub/lock_file.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 db049c4b3a0e3881bb66caa12277ac0262fea5bf..ab0b1efe892a198c497f6c59a7b4e7f3d53242eb 100644
--- a/utils/pub/io.dart
+++ b/utils/pub/io.dart
@@ -2,9 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/**
- * Helper functionality to make working with IO easier.
- */
+/// Helper functionality to make working with IO easier.
library io;
import 'dart:io';
@@ -23,11 +21,9 @@ String _gitCommandCache;
final NEWLINE_PATTERN = new RegExp("\r\n?|\n\r?");
-/**
- * Joins a number of path string parts into a single path. Handles
- * platform-specific path separators. Parts can be [String], [Directory], or
- * [File] objects.
- */
+/// Joins a number of path string parts into a single path. Handles
+/// platform-specific path separators. Parts can be [String], [Directory], or
+/// [File] objects.
String join(part1, [part2, part3, part4, part5, part6, part7, part8]) {
var parts = [part1, part2, part3, part4, part5, part6, part7, part8]
.map((part) => part == null ? null : _getPath(part));
@@ -57,11 +53,9 @@ bool isBeneath(entry, dir) {
/// Returns the path to [target] from [base].
String relativeTo(target, base) => path.relative(target, from: base);
-/**
- * Asynchronously determines if [path], which can be a [String] file path, a
- * [File], or a [Directory] exists on the file system. Returns a [Future] that
- * completes with the result.
- */
+/// Asynchronously determines if [path], which can be a [String] file path, a
+/// [File], or a [Directory] exists on the file system. Returns a [Future] that
+/// completes with the result.
Future<bool> exists(path) {
path = _getPath(path);
return Futures.wait([fileExists(path), dirExists(path)]).transform((results) {
@@ -69,11 +63,9 @@ Future<bool> exists(path) {
});
}
-/**
- * Asynchronously determines if [file], which can be a [String] file path or a
- * [File], exists on the file system. Returns a [Future] that completes with
- * the result.
- */
+/// Asynchronously determines if [file], which can be a [String] file path or a
+/// [File], exists on the file system. Returns a [Future] that completes with
+/// the result.
Future<bool> fileExists(file) {
var path = _getPath(file);
return log.ioAsync("Seeing if file $path exists.",
@@ -81,10 +73,8 @@ Future<bool> fileExists(file) {
(exists) => "File $path ${exists ? 'exists' : 'does not exist'}.");
}
-/**
- * Reads the contents of the text file [file], which can either be a [String] or
- * a [File].
- */
+/// Reads the contents of the text file [file], which can either be a [String]
+/// or a [File].
Future<String> readTextFile(file) {
var path = _getPath(file);
return log.ioAsync("Reading text file $path.",
@@ -99,12 +89,10 @@ Future<String> readTextFile(file) {
});
}
-/**
- * Creates [file] (which can either be a [String] or a [File]), and writes
- * [contents] to it. Completes when the file is written and closed.
- *
- * If [dontLogContents] is true, the contents of the file will never be logged.
- */
+/// Creates [file] (which can either be a [String] or a [File]), and writes
+/// [contents] to it. Completes when the file is written and closed.
+///
+/// If [dontLogContents] is true, the contents of the file will never be logged.
Future<File> writeTextFile(file, String contents, {dontLogContents: false}) {
var path = _getPath(file);
file = new File(path);
@@ -125,10 +113,8 @@ Future<File> writeTextFile(file, String contents, {dontLogContents: false}) {
});
}
-/**
- * Asynchronously deletes [file], which can be a [String] or a [File]. Returns a
- * [Future] that completes when the deletion is done.
- */
+/// Asynchronously deletes [file], which can be a [String] or a [File]. Returns
+/// a [Future] that completes when the deletion is done.
Future<File> deleteFile(file) {
var path = _getPath(file);
return log.ioAsync("delete file $path",
@@ -175,21 +161,17 @@ Future<File> createFileFromStream(InputStream stream, path) {
return completer.future;
}
-/**
- * Creates a directory [dir]. Returns a [Future] that completes when the
- * directory is created.
- */
+/// Creates a directory [dir]. Returns a [Future] that completes when the
+/// directory is created.
Future<Directory> createDir(dir) {
dir = _getDirectory(dir);
return log.ioAsync("create directory ${dir.path}",
dir.create());
}
-/**
- * Ensures that [path] and all its parent directories exist. If they don't
- * exist, creates them. Returns a [Future] that completes once all the
- * directories are created.
- */
+/// Ensures that [path] and all its parent directories exist. If they don't
+/// exist, creates them. Returns a [Future] that completes once all the
+/// directories are created.
Future<Directory> ensureDir(path) {
path = _getPath(path);
log.fine("Ensuring directory $path exists.");
@@ -222,22 +204,18 @@ Future<Directory> ensureDir(path) {
});
}
-/**
- * Creates a temp directory whose name will be based on [dir] with a unique
- * suffix appended to it. If [dir] is not provided, a temp directory will be
- * created in a platform-dependent temporary location. Returns a [Future] that
- * completes when the directory is created.
- */
+/// Creates a temp directory whose name will be based on [dir] with a unique
+/// suffix appended to it. If [dir] is not provided, a temp directory will be
+/// created in a platform-dependent temporary location. Returns a [Future] that
+/// completes when the directory is created.
Future<Directory> createTempDir([dir = '']) {
dir = _getDirectory(dir);
return log.ioAsync("create temp directory ${dir.path}",
dir.createTemp());
}
-/**
- * Asynchronously recursively deletes [dir], which can be a [String] or a
- * [Directory]. Returns a [Future] that completes when the deletion is done.
- */
+/// Asynchronously recursively deletes [dir], which can be a [String] or a
+/// [Directory]. Returns a [Future] that completes when the deletion is done.
Future<Directory> deleteDir(dir) {
dir = _getDirectory(dir);
@@ -315,11 +293,9 @@ Future<List<String>> listDir(dir,
return doList(_getDirectory(dir), new Set<String>());
}
-/**
- * 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.
- */
+/// 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.
Future<bool> dirExists(dir) {
dir = _getDirectory(dir);
return log.ioAsync("Seeing if directory ${dir.path} exists.",
@@ -328,11 +304,9 @@ Future<bool> dirExists(dir) {
"${exists ? 'exists' : 'does not exist'}.");
}
-/**
- * "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.
- */
+/// "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.
Future<Directory> cleanDir(dir) {
return dirExists(dir).chain((exists) {
if (exists) {
@@ -387,11 +361,9 @@ Future _attemptRetryable(Future callback()) {
return makeAttempt(null);
}
-/**
- * Creates a new symlink that creates an alias from [from] to [to], both of
- * which can be a [String], [File], or [Directory]. Returns a [Future] which
- * completes to the symlink file (i.e. [to]).
- */
+/// Creates a new symlink that creates an alias from [from] to [to], both of
+/// which can be a [String], [File], or [Directory]. Returns a [Future] which
+/// completes to the symlink file (i.e. [to]).
Future<File> createSymlink(from, to) {
from = _getPath(from);
to = _getPath(to);
@@ -417,13 +389,11 @@ Future<File> createSymlink(from, to) {
});
}
-/**
- * Creates a new symlink that creates an alias from the `lib` directory of
- * package [from] to [to], both of which can be a [String], [File], or
- * [Directory]. Returns a [Future] which completes to the symlink file (i.e.
- * [to]). If [from] does not have a `lib` directory, this shows a warning if
- * appropriate and then does nothing.
- */
+/// Creates a new symlink that creates an alias from the `lib` directory of
+/// package [from] to [to], both of which can be a [String], [File], or
+/// [Directory]. Returns a [Future] which completes to the symlink file (i.e.
+/// [to]). If [from] does not have a `lib` directory, this shows a warning if
+/// appropriate and then does nothing.
Future<File> createPackageSymlink(String name, from, to,
{bool isSelfLink: false}) {
// See if the package has a "lib" directory.
@@ -524,11 +494,9 @@ Future<String> readLine([StringInputStream stream]) {
return completer.future;
}
-/**
- * Takes all input from [source] and writes it to [sink].
- *
- * Returns a future that completes when [source] is closed.
- */
+/// Takes all input from [source] and writes it to [sink].
+///
+/// Returns a future that completes when [source] is closed.
Future pipeInputToInput(InputStream source, ListInputStream sink) {
var completer = new Completer();
source.onClosed = () {
@@ -552,9 +520,7 @@ Future pipeInputToInput(InputStream source, ListInputStream sink) {
return completer.future;
}
-/**
- * Buffers all input from an InputStream and returns it as a future.
- */
+/// Buffers all input from an InputStream and returns it as a future.
Future<List<int>> consumeInputStream(InputStream stream) {
if (stream.closed) return new Future.immediate(<int>[]);
@@ -694,16 +660,14 @@ Future _doProcess(Function fn, String executable, List<String> args, workingDir,
return fn(executable, args, options);
}
-/**
- * Wraps [input] to provide a timeout. If [input] completes before
- * [milliseconds] have passed, then the return value completes in the same way.
- * However, if [milliseconds] pass before [input] has completed, it completes
- * with a [TimeoutException] with [description] (which should be a fragment
- * describing the action that timed out).
- *
- * Note that timing out will not cancel the asynchronous operation behind
- * [input].
- */
+/// Wraps [input] to provide a timeout. If [input] completes before
+/// [milliseconds] have passed, then the return value completes in the same way.
+/// However, if [milliseconds] pass before [input] has completed, it completes
+/// with a [TimeoutException] with [description] (which should be a fragment
+/// describing the action that timed out).
+///
+/// Note that timing out will not cancel the asynchronous operation behind
+/// [input].
Future timeout(Future input, int milliseconds, String description) {
var completer = new Completer();
var timer = new Timer(milliseconds, (_) {
@@ -803,10 +767,8 @@ Future<bool> _tryGitCommand(String command) {
return completer.future;
}
-/**
- * Extracts a `.tar.gz` file from [stream] to [destination], which can be a
- * directory or a path. Returns whether or not the extraction was successful.
- */
+/// Extracts a `.tar.gz` file from [stream] to [destination], which can be a
+/// directory or a path. Returns whether or not the extraction was successful.
Future<bool> extractTarGz(InputStream stream, destination) {
destination = _getPath(destination);
@@ -972,9 +934,7 @@ InputStream createTarGz(List contents, {baseDir}) {
return stream;
}
-/**
- * Exception thrown when an operation times out.
- */
+/// Exception thrown when an operation times out.
class TimeoutException implements Exception {
final String message;
@@ -983,9 +943,7 @@ class TimeoutException implements Exception {
String toString() => message;
}
-/**
- * Contains the results of invoking a [Process] and waiting for it to complete.
- */
+/// Contains the results of invoking a [Process] and waiting for it to complete.
class PubProcessResult {
final List<String> stdout;
final List<String> stderr;
@@ -996,11 +954,9 @@ class PubProcessResult {
bool get success => exitCode == 0;
}
-/**
- * Gets the path string for [entry], which can either already be a path string,
- * or be a [File] or [Directory]. Allows working generically with "file-like"
- * objects.
- */
+/// Gets the path string for [entry], which can either already be a path string,
+/// or be a [File] or [Directory]. Allows working generically with "file-like"
+/// objects.
String _getPath(entry) {
if (entry is String) return entry;
if (entry is File) return entry.name;
@@ -1008,18 +964,14 @@ String _getPath(entry) {
throw 'Entry $entry is not a supported type.';
}
-/**
- * Gets a [Directory] for [entry], which can either already be one, or be a
- * [String].
- */
+/// Gets a [Directory] for [entry], which can either already be one, or be a
+/// [String].
Directory _getDirectory(entry) {
if (entry is Directory) return entry;
return new Directory(entry);
}
-/**
- * Gets a [Uri] for [uri], which can either already be one, or be a [String].
- */
+/// Gets a [Uri] for [uri], which can either already be one, or be a [String].
Uri _getUri(uri) {
if (uri is Uri) return uri;
return new Uri.fromString(uri);
« no previous file with comments | « utils/pub/http.dart ('k') | utils/pub/lock_file.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698