Chromium Code Reviews| Index: runtime/bin/directory_impl.dart |
| diff --git a/runtime/bin/directory_impl.dart b/runtime/bin/directory_impl.dart |
| index 485dfadfcac5e6b83b22824b6f9ee4ff70552399..2644005e0cee3beae1a697c5d199c510decf2248 100644 |
| --- a/runtime/bin/directory_impl.dart |
| +++ b/runtime/bin/directory_impl.dart |
| @@ -29,6 +29,26 @@ class _DirectoryListingIsolate extends Isolate { |
| } |
| +class _DirectoryCreateTempIsolate extends Isolate { |
| + |
| + _DirectoryCreateTempIsolate() : super.heavy(); |
| + |
| + void main() { |
| + port.receive((path, replyTo) { |
| + if (path == '') path = '/tmp/darttmpdirXXXXXX'; |
|
Mads Ager (google)
2011/11/18 09:50:45
You should add a comment about this default behavi
Bill Hesse
2011/11/21 15:48:41
Moved to .cc file.
|
| + |
| + // Call function to get file name |
| + String result = _createTemp(path); |
| + var message = {'success': (result != ''), 'directoryName': result}; |
|
Mads Ager (google)
2011/11/18 09:50:45
Do this in the caller? Just do replyTo.send(_creat
Bill Hesse
2011/11/21 15:48:41
Done.
|
| + replyTo.send(message); |
| + port.close(); |
| + }); |
| + } |
| + |
| + String _createTemp(String template) native "Directory_CreateTemp"; |
| +} |
| + |
| + |
| class _Directory implements Directory { |
| _Directory(String this._path); |
| @@ -47,6 +67,24 @@ class _Directory implements Directory { |
| } |
| } |
| + void createTemp(void createdHandler(Directory tempDir)) { |
| + new _DirectoryCreateTempIsolate().spawn().then((port) { |
| + port.call(_path).receive((result, ignored) { |
| + if (result['success']) { |
| + // Create new Directory with returned file name. |
| + Directory tempDir = new Directory(result['directoryName']); |
| + tempDir.dirHandler = _dirHandler; |
|
Mads Ager (google)
2011/11/18 09:50:45
This is subtle, why do you transfer the handlers?
Bill Hesse
2011/11/21 15:48:41
All this is removed, and we do not create a new Di
|
| + tempDir.fileHandler = _fileHandler; |
| + tempDir.doneHandler = _doneHandler; |
| + tempDir.errorHandler = _errorHandler; |
| + createdHandler(tempDir); |
| + } else { |
| + // Report error |
| + } |
| + }); |
| + }); |
| + } |
| + |
| void deleteSync() { |
| if (!_delete(_path)) { |
| throw new DirectoryException("Directory deletion failed: $_path"); |