| Index: sdk/lib/io/file_system_entity.dart
|
| diff --git a/sdk/lib/io/file_system_entity.dart b/sdk/lib/io/file_system_entity.dart
|
| index bbe8cd5975f0f2d47cad3aeafe22ef76f1e4ddb9..e13477b1c41e5b6c11e732e01977ccaa47d985b9 100644
|
| --- a/sdk/lib/io/file_system_entity.dart
|
| +++ b/sdk/lib/io/file_system_entity.dart
|
| @@ -4,6 +4,23 @@
|
|
|
| part of dart.io;
|
|
|
| +class FileSystemEntityType {
|
| + static const FILE = const FileSystemEntityType._internal(0);
|
| + static const DIRECTORY = const FileSystemEntityType._internal(1);
|
| + static const LINK = const FileSystemEntityType._internal(2);
|
| + static const NOT_FOUND = const FileSystemEntityType._internal(3);
|
| + static const _typeList = const [FileSystemEntityType.FILE,
|
| + FileSystemEntityType.DIRECTORY,
|
| + FileSystemEntityType.LINK,
|
| + FileSystemEntityType.NOT_FOUND];
|
| + const FileSystemEntityType._internal(int this._type);
|
| +
|
| + static FileSystemEntityType _lookup(int type) => _typeList[type];
|
| + String toString() => const ['FILE', 'DIRECTORY', 'LINK', 'NOT_FOUND'][_type];
|
| +
|
| + final int _type;
|
| +}
|
| +
|
| /**
|
| * A [FileSystemEntity] is a common super class for [File] and
|
| * [Directory] objects.
|
| @@ -16,4 +33,30 @@ part of dart.io;
|
| */
|
| abstract class FileSystemEntity {
|
| String get path;
|
| +
|
| + external static int _getType(String path, bool followLinks);
|
| +
|
| + static int _getTypeSync(String path, bool followLinks) {
|
| + var result = _getType(path, followLinks);
|
| + _throwIfError(result, 'Error getting type of FileSystemEntity');
|
| + return result;
|
| + }
|
| +
|
| + static FileSystemEntityType typeSync(String path, {bool followLinks: true})
|
| + => FileSystemEntityType._lookup(_getTypeSync(path, followLinks));
|
| +
|
| + static bool isLinkSync(String path) =>
|
| + (_getTypeSync(path, false) == FileSystemEntityType.LINK._type);
|
| +
|
| + static bool isFileSync(String path) =>
|
| + (_getTypeSync(path, true) == FileSystemEntityType.FILE._type);
|
| +
|
| + static bool isDirectorySync(String path) =>
|
| + (_getTypeSync(path, true) == FileSystemEntityType.DIRECTORY._type);
|
| +
|
| + static _throwIfError(Object result, String msg) {
|
| + if (result is OSError) {
|
| + throw new FileIOException(msg, result);
|
| + }
|
| + }
|
| }
|
|
|