OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 | 5 |
6 // Used for holding error code and error message for failed OS system calls. | 6 // Used for holding error code and error message for failed OS system calls. |
7 class _OSStatus { | 7 class _OSStatus { |
8 int _errorCode; | 8 int _errorCode; |
9 String _errorMessage; | 9 String _errorMessage; |
10 } | 10 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 void createTemp(void callback()) { | 75 void createTemp(void callback()) { |
76 _ensureDirectoryService(); | 76 _ensureDirectoryService(); |
77 List request = new List(2); | 77 List request = new List(2); |
78 request[0] = kCreateTempRequest; | 78 request[0] = kCreateTempRequest; |
79 request[1] = _path; | 79 request[1] = _path; |
80 _directoryService.call(request).receive((result, replyTo) { | 80 _directoryService.call(request).receive((result, replyTo) { |
81 if (result is !List) { | 81 if (result is !List) { |
82 _path = result; | 82 _path = result; |
83 callback(); | 83 callback(); |
84 } else if (_onError != null) { | 84 } else if (_onError != null) { |
85 _onError("Could not create temporary directory [$_path]: " + | 85 _onError("Could not create temporary directory [$_path]: ${result[1]}"); |
86 "${result[1]}"); | |
87 } | 86 } |
88 }); | 87 }); |
89 } | 88 } |
90 | 89 |
91 void createTempSync() { | 90 void createTempSync() { |
92 var status = new _OSStatus(); | 91 var status = new _OSStatus(); |
93 var result = _createTemp(path, status); | 92 var result = _createTemp(path, status); |
94 if (result != null) { | 93 if (result != null) { |
95 _path = result; | 94 _path = result; |
96 } else { | 95 } else { |
97 throw new DirectoryException( | 96 throw new DirectoryException( |
98 "Could not create temporary directory [$_path]: " + | 97 "Could not create temporary directory [$_path]: " |
99 "${status._errorMessage}", | 98 "${status._errorMessage}", |
100 status._errorCode); | 99 status._errorCode); |
101 } | 100 } |
102 } | 101 } |
103 | 102 |
104 void _deleteHelper(bool recursive, String errorMsg, void callback()) { | 103 void _deleteHelper(bool recursive, String errorMsg, void callback()) { |
105 _ensureDirectoryService(); | 104 _ensureDirectoryService(); |
106 List request = new List(3); | 105 List request = new List(3); |
107 request[0] = kDeleteRequest; | 106 request[0] = kDeleteRequest; |
108 request[1] = _path; | 107 request[1] = _path; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 } | 201 } |
203 | 202 |
204 var _onDir; | 203 var _onDir; |
205 var _onFile; | 204 var _onFile; |
206 var _onDone; | 205 var _onDone; |
207 var _onError; | 206 var _onError; |
208 | 207 |
209 String _path; | 208 String _path; |
210 SendPort _directoryService; | 209 SendPort _directoryService; |
211 } | 210 } |
OLD | NEW |