mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 21:20:36 +00:00
Remove the Path class from dart:io
The Path class in dart:io has been deprecated for some time now. It was scheduled to be removed on August 11th, so here it goes. dart:io still uses the Path class internally, but now it is private. I will trim it down to what is actually used in a follow-up change. R=ahe@google.com, devoncarew@google.com, whesse@google.com BUG=http://dartbug.com/11666 Review URL: https://codereview.chromium.org//23054008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@26181 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
bf154f76a6
commit
353428a918
|
@ -5,6 +5,7 @@
|
|||
library options;
|
||||
|
||||
import 'package:args/args.dart';
|
||||
import 'package:path/path.dart';
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
|
@ -153,8 +154,7 @@ class CommandLineOptions {
|
|||
|
||||
static String _getVersion() {
|
||||
try {
|
||||
Path path = new Path(Platform.script);
|
||||
Path versionPath = path.directoryPath.append('..').append('version');
|
||||
Path versionPath = join(dirname(Platform.script), '..', 'version');;
|
||||
File versionFile = new File.fromPath(versionPath);
|
||||
return versionFile.readAsStringSync().trim();
|
||||
} catch (_) {
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'dart:io';
|
|||
import 'dart:json' as JSON;
|
||||
|
||||
import 'package:mime/mime.dart';
|
||||
import "package:path/path.dart";
|
||||
|
||||
part 'src/http_body.dart';
|
||||
part 'src/http_body_impl.dart';
|
||||
|
|
|
@ -77,7 +77,7 @@ class _VirtualDirectory implements VirtualDirectory {
|
|||
}
|
||||
|
||||
void serveRequest(HttpRequest request) {
|
||||
_locateResource(new Path('.'), request.uri.pathSegments.iterator..moveNext())
|
||||
_locateResource('.', request.uri.pathSegments.iterator..moveNext())
|
||||
.then((entity) {
|
||||
if (entity == null) {
|
||||
_serveErrorPage(HttpStatus.NOT_FOUND, request);
|
||||
|
@ -101,39 +101,39 @@ class _VirtualDirectory implements VirtualDirectory {
|
|||
_errorCallback = callback;
|
||||
}
|
||||
|
||||
Future<FileSystemEntity> _locateResource(Path path,
|
||||
Future<FileSystemEntity> _locateResource(String path,
|
||||
Iterator<String> segments) {
|
||||
path = path.canonicalize();
|
||||
if (path.segments().first == "..") return new Future.value(null);
|
||||
Path fullPath() => new Path(root).join(path);
|
||||
return FileSystemEntity.type(fullPath().toNativePath(), followLinks: false)
|
||||
path = normalize(path);
|
||||
if (split(path).first == "..") return new Future.value(null);
|
||||
String fullPath() => join(root, path);
|
||||
return FileSystemEntity.type(fullPath(), followLinks: false)
|
||||
.then((type) {
|
||||
switch (type) {
|
||||
case FileSystemEntityType.FILE:
|
||||
if (segments.current == null) {
|
||||
return new File.fromPath(fullPath());
|
||||
return new File(fullPath());
|
||||
}
|
||||
break;
|
||||
|
||||
case FileSystemEntityType.DIRECTORY:
|
||||
if (segments.current == null) {
|
||||
if (allowDirectoryListing) {
|
||||
return new Directory.fromPath(fullPath());
|
||||
return new Directory(fullPath());
|
||||
}
|
||||
} else {
|
||||
if (_invalidPathRegExp.hasMatch(segments.current)) break;
|
||||
return _locateResource(path.append(segments.current),
|
||||
return _locateResource(join(path, segments.current),
|
||||
segments..moveNext());
|
||||
}
|
||||
break;
|
||||
|
||||
case FileSystemEntityType.LINK:
|
||||
if (followLinks) {
|
||||
return new Link.fromPath(fullPath()).target()
|
||||
return new Link(fullPath()).target()
|
||||
.then((target) {
|
||||
var targetPath = new Path(target).canonicalize();
|
||||
if (targetPath.isAbsolute) return null;
|
||||
targetPath = path.directoryPath.join(targetPath);
|
||||
String targetPath = normalize(target);
|
||||
if (isAbsolute(targetPath)) return null;
|
||||
targetPath = join(dirname(path), targetPath);
|
||||
return _locateResource(targetPath, segments);
|
||||
});
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ $server
|
|||
void add(String name, String modified, var size) {
|
||||
if (size == null) size = "-";
|
||||
if (modified == null) modified = "";
|
||||
var p = new Path(path).append(name).canonicalize().toString();
|
||||
var p = normalize(join(path, name));
|
||||
var entry =
|
||||
''' <tr>
|
||||
<td><a href="$p">$name</a></td>
|
||||
|
@ -272,11 +272,11 @@ $server
|
|||
// TODO(ajohnsen): Consider async dir listing.
|
||||
if (entity is File) {
|
||||
var stat = entity.statSync();
|
||||
add(new Path(entity.path).filename,
|
||||
add(basename(entity.path),
|
||||
stat.modified.toString(),
|
||||
stat.size);
|
||||
} else if (entity is Directory) {
|
||||
add(new Path(entity.path).filename + '/',
|
||||
add(basename(entity.path) + '/',
|
||||
entity.statSync().modified.toString(),
|
||||
null);
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ library utils;
|
|||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import "package:path/path.dart";
|
||||
|
||||
Future<int> getStatusCode(int port,
|
||||
String path,
|
||||
|
@ -57,8 +57,8 @@ const CERTIFICATE = "localhost_cert";
|
|||
|
||||
|
||||
setupSecure() {
|
||||
Path scriptDir = new Path(new Options().script).directoryPath;
|
||||
Path certificateDatabase = scriptDir.append('pkcert');
|
||||
SecureSocket.initialize(database: certificateDatabase.toNativePath(),
|
||||
String scriptDir = dirname(new Options().script);
|
||||
String certificateDatabase = join(scriptDir, 'pkcert');
|
||||
SecureSocket.initialize(database: certificateDatabase,
|
||||
password: 'dartdart');
|
||||
}
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import "package:unittest/unittest.dart";
|
||||
import "package:http_server/http_server.dart";
|
||||
import "package:path/path.dart";
|
||||
import "package:unittest/unittest.dart";
|
||||
|
||||
import 'utils.dart';
|
||||
|
||||
|
@ -296,7 +297,7 @@ void main() {
|
|||
test('relative-parent-link', () {
|
||||
expect(HttpServer.bind('localhost', 0).then((server) {
|
||||
var dir = new Directory('').createTempSync();
|
||||
var name = new Path(dir.path).filename;
|
||||
var name = basename(dir.path);
|
||||
var file = new File('${dir.path}/file')..createSync();
|
||||
var link = new Link('${dir.path}/dir3')
|
||||
..createSync('../$name/file');
|
||||
|
|
|
@ -2128,15 +2128,15 @@ class Dartdoc {
|
|||
write("# VERSION: ${new DateTime.now()}\n\n");
|
||||
write("NETWORK:\n*\n\n");
|
||||
write("CACHE:\n");
|
||||
var toCache = new Directory.fromPath(outputDir);
|
||||
var toCache = new Directory(outputDir);
|
||||
toCache.list(recursive: true).listen(
|
||||
(FileSystemEntity entity) {
|
||||
if (entity.isFile) {
|
||||
if (entity is File) {
|
||||
var filename = entity.path;
|
||||
if (filename.endsWith('appcache.manifest')) {
|
||||
return;
|
||||
}
|
||||
Path relativeFilePath = new Path(filename).relativeTo(outputDir);
|
||||
String relativeFilePath = path.relative(filename, from: outputDir);
|
||||
write("$relativeFilePath\n");
|
||||
}
|
||||
},
|
||||
|
|
|
@ -15,14 +15,6 @@ abstract class Directory implements FileSystemEntity {
|
|||
*/
|
||||
factory Directory(String path) => new _Directory(path);
|
||||
|
||||
/**
|
||||
* Creates a directory object from a Path object. The path is either
|
||||
* an absolute path, or it is a relative path which is interpreted
|
||||
* relative to the directory in which the Dart VM was started.
|
||||
*/
|
||||
@deprecated
|
||||
factory Directory.fromPath(Path path) => new _Directory.fromPath(path);
|
||||
|
||||
/**
|
||||
* Creates a directory object pointing to the current working
|
||||
* directory.
|
||||
|
|
|
@ -24,8 +24,6 @@ class _Directory implements Directory {
|
|||
}
|
||||
}
|
||||
|
||||
_Directory.fromPath(Path path) : this(path.toNativePath());
|
||||
|
||||
external static String _current();
|
||||
external static _setCurrent(path);
|
||||
external static _createTemp(String template);
|
||||
|
@ -98,11 +96,11 @@ class _Directory implements Directory {
|
|||
}
|
||||
|
||||
Future<Directory> createRecursively() {
|
||||
var path = new Path(this.path);
|
||||
var path = new _Path(this.path);
|
||||
var dirsToCreate = [];
|
||||
var terminator = path.isAbsolute ? '/' : '';
|
||||
while (path.toString() != terminator) {
|
||||
dirsToCreate.add(new Directory.fromPath(path));
|
||||
dirsToCreate.add(new Directory(path.toNativePath()));
|
||||
path = path.directoryPath;
|
||||
}
|
||||
return _computeExistingIndex(dirsToCreate).then((index) {
|
||||
|
@ -139,11 +137,11 @@ class _Directory implements Directory {
|
|||
}
|
||||
|
||||
void createRecursivelySync() {
|
||||
var path = new Path(this.path);
|
||||
var path = new _Path(this.path);
|
||||
var dirsToCreate = [];
|
||||
var terminator = path.isAbsolute ? '/' : '';
|
||||
while (path.toString() != terminator) {
|
||||
var dir = new Directory.fromPath(path);
|
||||
var dir = new Directory(path.toNativePath());
|
||||
if (dir.existsSync()) break;
|
||||
dirsToCreate.add(dir);
|
||||
path = path.directoryPath;
|
||||
|
|
|
@ -40,12 +40,6 @@ abstract class File implements FileSystemEntity {
|
|||
*/
|
||||
factory File(String path) => new _File(path);
|
||||
|
||||
/**
|
||||
* Create a File object from a Path object.
|
||||
*/
|
||||
@deprecated
|
||||
factory File.fromPath(Path path) => new _File.fromPath(path);
|
||||
|
||||
/**
|
||||
* Create the file. Returns a [:Future<File>:] that completes with
|
||||
* the file when it has been created.
|
||||
|
|
|
@ -246,9 +246,6 @@ class _File implements File {
|
|||
}
|
||||
}
|
||||
|
||||
// Constructor from Path for file.
|
||||
_File.fromPath(Path path) : this(path.toNativePath());
|
||||
|
||||
Future<bool> exists() {
|
||||
_ensureFileService();
|
||||
List request = new List(2);
|
||||
|
@ -346,8 +343,8 @@ class _File implements File {
|
|||
}
|
||||
|
||||
Directory get directory {
|
||||
Path path = new Path(this.path).directoryPath;
|
||||
return new Directory.fromPath(path);
|
||||
_Path path = new _Path(this.path).directoryPath;
|
||||
return new Directory(path.toNativePath());
|
||||
}
|
||||
|
||||
Future<RandomAccessFile> open({FileMode mode: FileMode.READ}) {
|
||||
|
|
|
@ -1590,8 +1590,8 @@ class _HttpClient implements HttpClient {
|
|||
scheme = previous.uri.scheme;
|
||||
}
|
||||
if (!uri.path.startsWith('/')) {
|
||||
var absolute = new Path.raw(previous.uri.path).directoryPath;
|
||||
absolute = absolute.join(new Path.raw(u.path));
|
||||
var absolute = new _Path.raw(previous.uri.path).directoryPath;
|
||||
absolute = absolute.join(new _Path.raw(u.path));
|
||||
path = absolute.canonicalize().toString();
|
||||
}
|
||||
replaceComponents(scheme: scheme, host: host, port: port, path: path);
|
||||
|
|
|
@ -14,12 +14,6 @@ abstract class Link implements FileSystemEntity {
|
|||
*/
|
||||
factory Link(String path) => new _Link(path);
|
||||
|
||||
/**
|
||||
* Creates a Link object from a Path object.
|
||||
*/
|
||||
@deprecated
|
||||
factory Link.fromPath(Path path) => new _Link.fromPath(path);
|
||||
|
||||
/**
|
||||
* Creates a symbolic link. Returns a [:Future<Link>:] that completes with
|
||||
* the link when it has been created. If the link exists,
|
||||
|
@ -144,8 +138,6 @@ class _Link extends FileSystemEntity implements Link {
|
|||
}
|
||||
|
||||
|
||||
_Link.fromPath(Path inputPath) : path = inputPath.toNativePath();
|
||||
|
||||
String toString() => "Link: '$path'";
|
||||
|
||||
Future<bool> exists() => FileSystemEntity.isLink(path);
|
||||
|
|
|
@ -16,7 +16,7 @@ part of dart.io;
|
|||
* August 2013.*
|
||||
*/
|
||||
@deprecated
|
||||
abstract class Path {
|
||||
abstract class _Path {
|
||||
/**
|
||||
* Creates a Path from a String that uses the native filesystem's conventions.
|
||||
*
|
||||
|
@ -26,7 +26,7 @@ abstract class Path {
|
|||
* If the path starts with a drive letter, like 'C:', a '/' is added
|
||||
* before the drive letter.
|
||||
*
|
||||
* new Path(r'c:\a\b').toString() == '/c:/a/b'
|
||||
* new _Path(r'c:\a\b').toString() == '/c:/a/b'
|
||||
*
|
||||
* A path starting with a drive letter is
|
||||
* treated specially. Backwards links ('..') cannot cancel the drive letter.
|
||||
|
@ -34,14 +34,14 @@ abstract class Path {
|
|||
* If the path is a share path this is recorded in the Path object and
|
||||
* maintained in operations on the Path object.
|
||||
*
|
||||
* var share = new Path(r'\\share\a\b\c');
|
||||
* var share = new _Path(r'\\share\a\b\c');
|
||||
* share.isWindowsShare == true
|
||||
* share.toString() == '/share/a/b/c'
|
||||
* share.toNativePath() == r'\\share\a\b\c'
|
||||
* share.append('final').isWindowsShare == true
|
||||
*/
|
||||
@deprecated
|
||||
factory Path(String source) => new _Path(source);
|
||||
factory _Path(String source) => new __Path(source);
|
||||
|
||||
/**
|
||||
* Creates a Path from the String [source]. [source] is used as-is, so if
|
||||
|
@ -49,7 +49,7 @@ abstract class Path {
|
|||
* behavior may not be as expected. Paths are immutable.
|
||||
*/
|
||||
@deprecated
|
||||
factory Path.raw(String source) => new _Path.raw(source);
|
||||
factory _Path.raw(String source) => new __Path.raw(source);
|
||||
|
||||
/**
|
||||
* Is this path the empty string?
|
||||
|
@ -86,7 +86,7 @@ abstract class Path {
|
|||
* and combining consecutive '/'s. Leading '..' segments
|
||||
* are kept on relative paths, and dropped from absolute paths.
|
||||
*/
|
||||
Path canonicalize();
|
||||
_Path canonicalize();
|
||||
|
||||
/**
|
||||
* Joins the relative path [further] to this path. Canonicalizes the
|
||||
|
@ -97,13 +97,13 @@ abstract class Path {
|
|||
* If [further] is an absolute path, an IllegalArgument exception is thrown.
|
||||
*
|
||||
* Examples:
|
||||
* `new Path('/a/b/c').join(new Path('d/e'))` returns the Path object
|
||||
* `new _Path('/a/b/c').join(new _Path('d/e'))` returns the Path object
|
||||
* containing `'a/b/c/d/e'`.
|
||||
*
|
||||
* `new Path('a/b/../c/').join(new Path('d/./e//')` returns the Path
|
||||
* `new _Path('a/b/../c/').join(new _Path('d/./e//')` returns the Path
|
||||
* containing `'a/c/d/e/'`.
|
||||
*
|
||||
* `new Path('a/b/c').join(new Path('d/../../e')` returns the Path
|
||||
* `new _Path('a/b/c').join(new _Path('d/../../e')` returns the Path
|
||||
* containing `'a/b/e'`.
|
||||
*
|
||||
* Note that the join operation does not drop the last segment of the
|
||||
|
@ -115,7 +115,7 @@ abstract class Path {
|
|||
* parent directories in the base, you can check whether
|
||||
* `further.canonicalize()` starts with '../' or equals '..'.
|
||||
*/
|
||||
Path join(Path further);
|
||||
_Path join(_Path further);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -129,7 +129,7 @@ abstract class Path {
|
|||
* path component of the base is dropped unless it ends with a slash,
|
||||
* call [: a.relativeTo(b.directoryPath) :] instead of [: a.relativeTo(b) :].
|
||||
*/
|
||||
Path relativeTo(Path base);
|
||||
_Path relativeTo(_Path base);
|
||||
|
||||
/**
|
||||
* Converts a path to a string using the native filesystem's conventions.
|
||||
|
@ -138,14 +138,14 @@ abstract class Path {
|
|||
* On Windows, converts '/'s to backwards slashes, and removes
|
||||
* the leading '/' if the path starts with a drive specification.
|
||||
* For most valid Windows paths, this should be the inverse of the
|
||||
* conversion that the constructor new Path() performs. If the path is
|
||||
* conversion that the constructor new _Path() performs. If the path is
|
||||
* a Windows share, restores the '\\' at the start of the path.
|
||||
*/
|
||||
String toNativePath();
|
||||
|
||||
/**
|
||||
* Returns the path as a string. If this path is constructed using
|
||||
* new Path.raw(), or new Path() on a non-Windows system, the
|
||||
* new _Path.raw(), or new _Path() on a non-Windows system, the
|
||||
* returned value is the original string argument to the constructor.
|
||||
*/
|
||||
String toString();
|
||||
|
@ -156,8 +156,8 @@ abstract class Path {
|
|||
* beginning does not create an empty segment before it, and a '/' at
|
||||
* the end does not create an empty segment after it.
|
||||
*
|
||||
* new Path('/a/b/c/d').segments() == ['a', 'b', 'c', d'];
|
||||
* new Path(' foo bar //../') == [' foo bar ', '', '..'];
|
||||
* new _Path('/a/b/c/d').segments() == ['a', 'b', 'c', d'];
|
||||
* new _Path(' foo bar //../') == [' foo bar ', '', '..'];
|
||||
*/
|
||||
List<String> segments();
|
||||
|
||||
|
@ -167,7 +167,7 @@ abstract class Path {
|
|||
* a '/'. The path is not canonicalized, and [finalSegment] may
|
||||
* contain '/'s.
|
||||
*/
|
||||
Path append(String finalSegment);
|
||||
_Path append(String finalSegment);
|
||||
|
||||
/**
|
||||
* Drops the final '/' and whatever follows it from this Path,
|
||||
|
@ -175,20 +175,20 @@ abstract class Path {
|
|||
* this Path is the first character, returns '/' instead of the empty string.
|
||||
* If there is no '/' in the Path, returns the empty string.
|
||||
*
|
||||
* new Path('../images/dot.gif').directoryPath == '../images'
|
||||
* new Path('/usr/geoffrey/www/').directoryPath == '/usr/geoffrey/www'
|
||||
* new Path('lost_file_old').directoryPath == ''
|
||||
* new Path('/src').directoryPath == '/'
|
||||
* Note: new Path('/D:/src').directoryPath == '/D:'
|
||||
* new _Path('../images/dot.gif').directoryPath == '../images'
|
||||
* new _Path('/usr/geoffrey/www/').directoryPath == '/usr/geoffrey/www'
|
||||
* new _Path('lost_file_old').directoryPath == ''
|
||||
* new _Path('/src').directoryPath == '/'
|
||||
* Note: new _Path('/D:/src').directoryPath == '/D:'
|
||||
*/
|
||||
Path get directoryPath;
|
||||
_Path get directoryPath;
|
||||
|
||||
/**
|
||||
* The part of the path after the last '/', or the entire path if
|
||||
* it contains no '/'.
|
||||
*
|
||||
* new Path('images/DSC_0027.jpg).filename == 'DSC_0027.jpg'
|
||||
* new Path('users/fred/').filename == ''
|
||||
* new _Path('images/DSC_0027.jpg).filename == 'DSC_0027.jpg'
|
||||
* new _Path('users/fred/').filename == ''
|
||||
*/
|
||||
String get filename;
|
||||
|
||||
|
@ -196,9 +196,9 @@ abstract class Path {
|
|||
* The part of [filename] before the last '.', or the entire filename if it
|
||||
* contains no '.'. If [filename] is '.' or '..' it is unchanged.
|
||||
*
|
||||
* new Path('/c:/My Documents/Heidi.txt').filenameWithoutExtension
|
||||
* new _Path('/c:/My Documents/Heidi.txt').filenameWithoutExtension
|
||||
* would return 'Heidi'.
|
||||
* new Path('not what I would call a path').filenameWithoutExtension
|
||||
* new _Path('not what I would call a path').filenameWithoutExtension
|
||||
* would return 'not what I would call a path'.
|
||||
*/
|
||||
String get filenameWithoutExtension;
|
||||
|
@ -207,8 +207,8 @@ abstract class Path {
|
|||
* The part of [filename] after the last '.', or '' if [filename]
|
||||
* contains no '.'. If [filename] is '.' or '..', returns ''.
|
||||
*
|
||||
* new Path('tiger.svg').extension == 'svg'
|
||||
* new Path('/src/dart/dart_secrets').extension == ''
|
||||
* new _Path('tiger.svg').extension == 'svg'
|
||||
* new _Path('/src/dart/dart_secrets').extension == ''
|
||||
*/
|
||||
String get extension;
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
|
||||
part of dart.io;
|
||||
|
||||
class _Path implements Path {
|
||||
class __Path implements _Path {
|
||||
final String _path;
|
||||
final bool isWindowsShare;
|
||||
|
||||
_Path(String source)
|
||||
__Path(String source)
|
||||
: _path = _clean(source), isWindowsShare = _isWindowsShare(source);
|
||||
|
||||
_Path.raw(String source) : _path = source, isWindowsShare = false;
|
||||
__Path.raw(String source) : _path = source, isWindowsShare = false;
|
||||
|
||||
_Path._internal(String this._path, bool this.isWindowsShare);
|
||||
__Path._internal(String this._path, bool this.isWindowsShare);
|
||||
|
||||
static String _clean(String source) {
|
||||
if (Platform.operatingSystem == 'windows') return _cleanWindows(source);
|
||||
|
@ -44,14 +44,14 @@ class _Path implements Path {
|
|||
|
||||
String toString() => _path;
|
||||
|
||||
Path relativeTo(Path base) {
|
||||
_Path relativeTo(_Path base) {
|
||||
// Returns a path "relative" such that
|
||||
// base.join(relative) == this.canonicalize.
|
||||
// Throws exception if an impossible case is reached.
|
||||
if (base.isAbsolute != isAbsolute ||
|
||||
base.isWindowsShare != isWindowsShare) {
|
||||
throw new ArgumentError(
|
||||
"Invalid case of Path.relativeTo(base):\n"
|
||||
"Invalid case of _Path.relativeTo(base):\n"
|
||||
" Path and base must both be relative, or both absolute.\n"
|
||||
" Arguments: $_path.relativeTo($base)");
|
||||
}
|
||||
|
@ -71,17 +71,17 @@ class _Path implements Path {
|
|||
if(basePath[1] != _path[1]) {
|
||||
// Replace the drive letter in basePath with that from _path.
|
||||
basePath = '/${_path[1]}:/${basePath.substring(4)}';
|
||||
base = new Path(basePath);
|
||||
base = new _Path(basePath);
|
||||
}
|
||||
} else {
|
||||
throw new ArgumentError(
|
||||
"Invalid case of Path.relativeTo(base):\n"
|
||||
"Invalid case of _Path.relativeTo(base):\n"
|
||||
" Base path and target path are on different Windows drives.\n"
|
||||
" Arguments: $_path.relativeTo($base)");
|
||||
}
|
||||
} else if (baseHasDrive != pathHasDrive) {
|
||||
throw new ArgumentError(
|
||||
"Invalid case of Path.relativeTo(base):\n"
|
||||
"Invalid case of _Path.relativeTo(base):\n"
|
||||
" Base path must start with a drive letter if and "
|
||||
"only if target path does.\n"
|
||||
" Arguments: $_path.relativeTo($base)");
|
||||
|
@ -89,7 +89,7 @@ class _Path implements Path {
|
|||
|
||||
}
|
||||
if (_path.startsWith(basePath)) {
|
||||
if (_path == basePath) return new Path('.');
|
||||
if (_path == basePath) return new _Path('.');
|
||||
// There must be a '/' at the end of the match, or immediately after.
|
||||
int matchEnd = basePath.length;
|
||||
if (_path[matchEnd - 1] == '/' || _path[matchEnd] == '/') {
|
||||
|
@ -97,7 +97,7 @@ class _Path implements Path {
|
|||
while (matchEnd < _path.length && _path[matchEnd] == '/') {
|
||||
matchEnd++;
|
||||
}
|
||||
return new Path(_path.substring(matchEnd)).canonicalize();
|
||||
return new _Path(_path.substring(matchEnd)).canonicalize();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ class _Path implements Path {
|
|||
|
||||
if (common < baseSegments.length && baseSegments[common] == '..') {
|
||||
throw new ArgumentError(
|
||||
"Invalid case of Path.relativeTo(base):\n"
|
||||
"Invalid case of _Path.relativeTo(base):\n"
|
||||
" Base path has more '..'s than path does.\n"
|
||||
" Arguments: $_path.relativeTo($base)");
|
||||
}
|
||||
|
@ -134,11 +134,11 @@ class _Path implements Path {
|
|||
if (hasTrailingSeparator) {
|
||||
segments.add('');
|
||||
}
|
||||
return new Path(segments.join('/'));
|
||||
return new _Path(segments.join('/'));
|
||||
}
|
||||
|
||||
|
||||
Path join(Path further) {
|
||||
_Path join(_Path further) {
|
||||
if (further.isAbsolute) {
|
||||
throw new ArgumentError(
|
||||
"Path.join called with absolute Path as argument.");
|
||||
|
@ -147,17 +147,17 @@ class _Path implements Path {
|
|||
return further.canonicalize();
|
||||
}
|
||||
if (hasTrailingSeparator) {
|
||||
var joined = new _Path._internal('$_path${further}', isWindowsShare);
|
||||
var joined = new __Path._internal('$_path${further}', isWindowsShare);
|
||||
return joined.canonicalize();
|
||||
}
|
||||
var joined = new _Path._internal('$_path/${further}', isWindowsShare);
|
||||
var joined = new __Path._internal('$_path/${further}', isWindowsShare);
|
||||
return joined.canonicalize();
|
||||
}
|
||||
|
||||
// Note: The URI RFC names for canonicalize, join, and relativeTo
|
||||
// are normalize, resolve, and relativize. But resolve and relativize
|
||||
// drop the last segment of the base path (the filename), on URIs.
|
||||
Path canonicalize() {
|
||||
_Path canonicalize() {
|
||||
if (isCanonical) return this;
|
||||
return makeCanonical();
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ class _Path implements Path {
|
|||
return !segs.any((s) => s == '' || s == '.' || s == '..');
|
||||
}
|
||||
|
||||
Path makeCanonical() {
|
||||
_Path makeCanonical() {
|
||||
bool isAbs = isAbsolute;
|
||||
List segs = segments();
|
||||
String drive;
|
||||
|
@ -242,7 +242,7 @@ class _Path implements Path {
|
|||
segmentsToJoin.add('');
|
||||
}
|
||||
}
|
||||
return new _Path._internal(segmentsToJoin.join('/'), isWindowsShare);
|
||||
return new __Path._internal(segmentsToJoin.join('/'), isWindowsShare);
|
||||
}
|
||||
|
||||
String toNativePath() {
|
||||
|
@ -271,13 +271,13 @@ class _Path implements Path {
|
|||
return result;
|
||||
}
|
||||
|
||||
Path append(String finalSegment) {
|
||||
_Path append(String finalSegment) {
|
||||
if (isEmpty) {
|
||||
return new _Path._internal(finalSegment, isWindowsShare);
|
||||
return new __Path._internal(finalSegment, isWindowsShare);
|
||||
} else if (hasTrailingSeparator) {
|
||||
return new _Path._internal('$_path$finalSegment', isWindowsShare);
|
||||
return new __Path._internal('$_path$finalSegment', isWindowsShare);
|
||||
} else {
|
||||
return new _Path._internal('$_path/$finalSegment', isWindowsShare);
|
||||
return new __Path._internal('$_path/$finalSegment', isWindowsShare);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -294,12 +294,12 @@ class _Path implements Path {
|
|||
return (pos < 0) ? '' : name.substring(pos + 1);
|
||||
}
|
||||
|
||||
Path get directoryPath {
|
||||
_Path get directoryPath {
|
||||
int pos = _path.lastIndexOf('/');
|
||||
if (pos < 0) return new Path('');
|
||||
if (pos < 0) return new _Path('');
|
||||
while (pos > 0 && _path[pos - 1] == '/') --pos;
|
||||
var dirPath = (pos > 0) ? _path.substring(0, pos) : '/';
|
||||
return new _Path._internal(dirPath, isWindowsShare);
|
||||
return new __Path._internal(dirPath, isWindowsShare);
|
||||
}
|
||||
|
||||
String get filename {
|
||||
|
|
|
@ -17,6 +17,7 @@ standalone/io/raw_secure_server_socket_argument_test: fail
|
|||
standalone/io/secure_socket_argument_test: fail
|
||||
standalone/io/stdout_bad_argument_test: fail
|
||||
standalone/io/skipping_dart2js_compilations_test: fail
|
||||
standalone/io/dependency_graph_test: fail # http/dartbug.com/12449
|
||||
standalone/io/url_encoding_test: fail
|
||||
standalone/io/web_socket_protocol_processor_test: fail
|
||||
standalone/io/test_runner_test: fail
|
||||
|
@ -45,6 +46,7 @@ standalone/io/raw_secure_server_socket_argument_test: fail
|
|||
standalone/io/secure_socket_argument_test: fail
|
||||
standalone/io/stdout_bad_argument_test: fail
|
||||
standalone/io/skipping_dart2js_compilations_test: fail
|
||||
standalone/io/dependency_graph_test: fail # http/dartbug.com/12449
|
||||
standalone/io/url_encoding_test: fail
|
||||
standalone/io/web_socket_protocol_processor_test: fail
|
||||
standalone/io/test_runner_test: fail
|
||||
|
|
|
@ -26,8 +26,8 @@ main() {
|
|||
String appendSlash(String path) => path.endsWith('/') ? path : '$path/';
|
||||
Uri cwd = new Uri(
|
||||
scheme: 'file',
|
||||
path: appendSlash(new Path(new File('.').fullPathSync()).toString()));
|
||||
Uri uri = cwd.resolve(new Path(Platform.script).toString());
|
||||
path: appendSlash(new File('.').fullPathSync()));
|
||||
Uri uri = cwd.resolve(Platform.script);
|
||||
testLibraryUri(new Class(), uri);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -7,6 +7,10 @@
|
|||
# listed in tests/lib/analyzer/analyze_tests.status without the "standalone"
|
||||
# prefix.
|
||||
|
||||
# The testing infrastructure is using the dart:io Path class.
|
||||
io/skipping_dart2js_compilations_test: Skip # http/dartbug.com/12449
|
||||
io/dependency_graph_test: Skip # http/dartbug.com/12449
|
||||
|
||||
package/invalid_uri_test: Fail, OK # Fails intentionally
|
||||
|
||||
[ $runtime == vm ]
|
||||
|
|
|
@ -104,7 +104,7 @@ class Source {
|
|||
}
|
||||
});
|
||||
|
||||
String srcPath = new Path(Uri.parse(url).path).toNativePath();
|
||||
String srcPath = Uri.parse(url).toFilePath();
|
||||
List lines = new File(srcPath).readAsLinesSync();
|
||||
for (int line = 1; line <= lines.length; line++) {
|
||||
String prefix = " ";
|
||||
|
|
|
@ -6,9 +6,9 @@ import 'dart:io';
|
|||
|
||||
Future<String> getVersion(var options, var rootPath) {
|
||||
var suffix = Platform.operatingSystem == 'windows' ? '.exe' : '';
|
||||
var printVersionScript =
|
||||
rootPath.append("tools").append("print_version.py").toNativePath();
|
||||
return Process.run("python$suffix", [printVersionScript]).then((result) {
|
||||
var printVersionScript = rootPath.resolve("tools/print_version.py");
|
||||
return Process.run("python$suffix",
|
||||
[printVersionScript.toFilePath()]).then((result) {
|
||||
if (result.exitCode != 0) {
|
||||
throw "Could not generate version";
|
||||
}
|
||||
|
@ -17,14 +17,13 @@ Future<String> getVersion(var options, var rootPath) {
|
|||
}
|
||||
|
||||
Future<String> getSnapshotGenerationFile(var options, var args, var rootPath) {
|
||||
var dart2js = rootPath.append(args["dart2js_main"]);
|
||||
var dartdoc = rootPath.append(args["dartdoc_main"]);
|
||||
|
||||
var dart2js = rootPath.resolve(args["dart2js_main"]);
|
||||
var dartdoc = rootPath.resolve(args["dartdoc_main"]);
|
||||
return getVersion(options, rootPath).then((version) {
|
||||
var snapshotGenerationText =
|
||||
"""
|
||||
import '${dart2js}' as dart2jsMain;
|
||||
import '${dartdoc}' as dartdocMain;
|
||||
import '${dart2js.toFilePath()}' as dart2jsMain;
|
||||
import '${dartdoc.toFilePath()}' as dartdocMain;
|
||||
import 'dart:io';
|
||||
|
||||
void main() {
|
||||
|
@ -86,9 +85,9 @@ void main() {
|
|||
if (!args.containsKey("output_dir")) throw "Please specify output_dir";
|
||||
if (!args.containsKey("package_root")) throw "Please specify package_root";
|
||||
|
||||
var scriptFile = new File(new File(options.script).fullPathSync());
|
||||
var path = new Path(scriptFile.directory.path);
|
||||
var rootPath = path.directoryPath.directoryPath;
|
||||
var scriptFile = new Uri.file(new File(options.script).fullPathSync());
|
||||
var path = scriptFile.resolve(".");
|
||||
var rootPath = path.resolve("../..");
|
||||
getSnapshotGenerationFile(options, args, rootPath).then((result) {
|
||||
var wrapper = "${args['output_dir']}/utils_wrapper.dart";
|
||||
writeSnapshotFile(wrapper, result);
|
||||
|
|
Loading…
Reference in a new issue