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

Unified Diff: runtime/bin/file_impl.dart

Issue 8437056: Implemented File create API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | « runtime/bin/file.dart ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index 5e9f224def70a1676312b82e359f7c518ed406bc..5429943f04cddb9190e212abbeb18ccbca6c6b87 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -301,6 +301,17 @@ class _FlushOperation extends _FileOperation {
}
+class _CreateOperation extends _FileOperation {
+ _CreateOperation(String this._name);
+
+ void execute(ReceivePort port) {
+ _replyPort.send(_File._create(_name), port.toSendPort());
+ }
+
+ String _name;
+}
+
+
class _ExitOperation extends _FileOperation {
void execute(ReceivePort port) {
port.close();
@@ -390,6 +401,7 @@ class _File implements File {
static int _position(int id) native "File_Position";
static int _length(int id) native "File_Length";
static int _flush(int id) native "File_Flush";
+ static bool _create(String name) native "File_Create";
static int _checkReadWriteListArguments(int length, int offset, int bytes) {
if (offset < 0) return offset;
@@ -416,7 +428,16 @@ class _File implements File {
void create() {
_asyncUsed = true;
- throw "Unimplemented";
+ var handler = (_createHandler != null) ? _createHandler : () => null;
+ var handleCreateResult = (created, ignored) {
+ if (created) {
+ handler();
+ } else if (_errorHandler != null) {
+ _errorHandler("Cannot create file: $_name");
+ }
+ };
+ var operation = new _CreateOperation(_name);
+ _scheduler.enqueue(operation, handleCreateResult);
}
void createSync() {
@@ -424,7 +445,10 @@ class _File implements File {
throw new FileIOException(
"Mixed use of synchronous and asynchronous API");
}
- throw "Unimplemented";
+ bool created = _create(_name);
+ if (!created) {
+ throw new FileIOException("Cannot create file: $_name");
+ }
}
void open([bool writable = false]) {
« no previous file with comments | « runtime/bin/file.dart ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698