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

Unified Diff: sdk/lib/io/directory_impl.dart

Issue 3007703002: [dart:io] Namespaces for file IO (Closed)
Patch Set: Remove namespace_unsupported.cc Created 3 years, 4 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 | « sdk/lib/_internal/js_runtime/lib/io_patch.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/directory_impl.dart
diff --git a/sdk/lib/io/directory_impl.dart b/sdk/lib/io/directory_impl.dart
index 9b43b8e962333d61d0cce020810bc611267fe0cf..2f231969012b5bdc76cbb5621e0fa91b1fd34c8e 100644
--- a/sdk/lib/io/directory_impl.dart
+++ b/sdk/lib/io/directory_impl.dart
@@ -14,19 +14,24 @@ class _Directory extends FileSystemEntity implements Directory {
}
}
- external static _current();
- external static _setCurrent(path);
- external static _createTemp(String path);
- external static String _systemTemp();
- external static _exists(String path);
- external static _create(String path);
- external static _deleteNative(String path, bool recursive);
- external static _rename(String path, String newPath);
- external static void _fillWithDirectoryListing(List<FileSystemEntity> list,
- String path, bool recursive, bool followLinks);
+ external static _current(_Namespace namespace);
+ external static _setCurrent(_Namespace namespace, path);
+ external static _createTemp(_Namespace namespace, String path);
+ external static String _systemTemp(_Namespace namespace);
+ external static _exists(_Namespace namespace, String path);
+ external static _create(_Namespace namespace, String path);
+ external static _deleteNative(
+ _Namespace namespace, String path, bool recursive);
+ external static _rename(_Namespace namespace, String path, String newPath);
+ external static void _fillWithDirectoryListing(
+ _Namespace namespace,
+ List<FileSystemEntity> list,
+ String path,
+ bool recursive,
+ bool followLinks);
static Directory get current {
- var result = _current();
+ var result = _current(_Namespace._namespace);
if (result is OSError) {
throw new FileSystemException(
"Getting current working directory failed", "", result);
@@ -34,9 +39,11 @@ class _Directory extends FileSystemEntity implements Directory {
return new _Directory(result);
}
+ // TODO(zra): Provide a flag that an embedder can set to make attempts to set
+ // the working directory for the whole process fail.
static void set current(path) {
if (path is Directory) path = path.path;
- var result = _setCurrent(path);
+ var result = _setCurrent(_Namespace._namespace, path);
if (result is ArgumentError) throw result;
if (result is OSError) {
throw new FileSystemException(
@@ -49,7 +56,8 @@ class _Directory extends FileSystemEntity implements Directory {
}
Future<bool> exists() {
- return _IOService._dispatch(_DIRECTORY_EXISTS, [path]).then((response) {
+ return _File._dispatchWithNamespace(_DIRECTORY_EXISTS, [null, path]).then(
+ (response) {
if (_isErrorResponse(response)) {
throw _exceptionOrErrorFromResponse(response, "Exists failed");
}
@@ -58,7 +66,7 @@ class _Directory extends FileSystemEntity implements Directory {
}
bool existsSync() {
- var result = _exists(path);
+ var result = _exists(_Namespace._namespace, path);
if (result is OSError) {
throw new FileSystemException("Exists failed", path, result);
}
@@ -80,7 +88,8 @@ class _Directory extends FileSystemEntity implements Directory {
}
});
} else {
- return _IOService._dispatch(_DIRECTORY_CREATE, [path]).then((response) {
+ return _File._dispatchWithNamespace(_DIRECTORY_CREATE, [null, path]).then(
+ (response) {
if (_isErrorResponse(response)) {
throw _exceptionOrErrorFromResponse(response, "Creation failed");
}
@@ -96,13 +105,14 @@ class _Directory extends FileSystemEntity implements Directory {
parent.createSync(recursive: true);
}
}
- var result = _create(path);
+ var result = _create(_Namespace._namespace, path);
if (result is OSError) {
throw new FileSystemException("Creation failed", path, result);
}
}
- static Directory get systemTemp => new Directory(_systemTemp());
+ static Directory get systemTemp =>
+ new Directory(_systemTemp(_Namespace._namespace));
Future<Directory> createTemp([String prefix]) {
if (prefix == null) prefix = '';
@@ -116,8 +126,8 @@ class _Directory extends FileSystemEntity implements Directory {
} else {
fullPrefix = "$path${Platform.pathSeparator}$prefix";
}
- return _IOService
- ._dispatch(_DIRECTORY_CREATE_TEMP, [fullPrefix]).then((response) {
+ return _File._dispatchWithNamespace(
+ _DIRECTORY_CREATE_TEMP, [null, fullPrefix]).then((response) {
if (_isErrorResponse(response)) {
throw _exceptionOrErrorFromResponse(
response, "Creation of temporary directory failed");
@@ -138,7 +148,7 @@ class _Directory extends FileSystemEntity implements Directory {
} else {
fullPrefix = "$path${Platform.pathSeparator}$prefix";
}
- var result = _createTemp(fullPrefix);
+ var result = _createTemp(_Namespace._namespace, fullPrefix);
if (result is OSError) {
throw new FileSystemException(
"Creation of temporary directory failed", fullPrefix, result);
@@ -147,8 +157,8 @@ class _Directory extends FileSystemEntity implements Directory {
}
Future<Directory> _delete({bool recursive: false}) {
- return _IOService
- ._dispatch(_DIRECTORY_DELETE, [path, recursive]).then((response) {
+ return _File._dispatchWithNamespace(
+ _DIRECTORY_DELETE, [null, path, recursive]).then((response) {
if (_isErrorResponse(response)) {
throw _exceptionOrErrorFromResponse(response, "Deletion failed");
}
@@ -157,15 +167,15 @@ class _Directory extends FileSystemEntity implements Directory {
}
void _deleteSync({bool recursive: false}) {
- var result = _deleteNative(path, recursive);
+ var result = _deleteNative(_Namespace._namespace, path, recursive);
if (result is OSError) {
throw new FileSystemException("Deletion failed", path, result);
}
}
Future<Directory> rename(String newPath) {
- return _IOService
- ._dispatch(_DIRECTORY_RENAME, [path, newPath]).then((response) {
+ return _File._dispatchWithNamespace(
+ _DIRECTORY_RENAME, [null, path, newPath]).then((response) {
if (_isErrorResponse(response)) {
throw _exceptionOrErrorFromResponse(response, "Rename failed");
}
@@ -177,7 +187,7 @@ class _Directory extends FileSystemEntity implements Directory {
if (newPath is! String) {
throw new ArgumentError();
}
- var result = _rename(path, newPath);
+ var result = _rename(_Namespace._namespace, path, newPath);
if (result is OSError) {
throw new FileSystemException("Rename failed", path, result);
}
@@ -200,6 +210,7 @@ class _Directory extends FileSystemEntity implements Directory {
}
var result = <FileSystemEntity>[];
_fillWithDirectoryListing(
+ _Namespace._namespace,
result,
FileSystemEntity._ensureTrailingPathSeparators(path),
recursive,
@@ -261,6 +272,7 @@ class _AsyncDirectoryLister {
onListen: onListen, onResume: onResume, onCancel: onCancel, sync: true);
}
+ // WARNING:
// Calling this function will increase the reference count on the native
// object that implements the async directory lister operations. It should
// only be called to pass the pointer to the IO Service, which will decrement
@@ -272,8 +284,8 @@ class _AsyncDirectoryLister {
Stream<FileSystemEntity> get stream => controller.stream;
void onListen() {
- _IOService._dispatch(
- _DIRECTORY_LIST_START, [path, recursive, followLinks]).then((response) {
+ _File._dispatchWithNamespace(_DIRECTORY_LIST_START,
+ [null, path, recursive, followLinks]).then((response) {
if (response is int) {
_ops = new _AsyncDirectoryListerOps(response);
next();
« no previous file with comments | « sdk/lib/_internal/js_runtime/lib/io_patch.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698