Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * A collection of helper io functions implemented using node.js. | 6 * A collection of helper io functions implemented using node.js. |
| 7 * | 7 * |
| 8 * Idea is to clone the node.js API as closely as possible while adding types. | 8 * Idea is to clone the node.js API as closely as possible while adding types. |
| 9 * Dart libraries on top of this will experiment with different APIs. | 9 * Dart libraries on top of this will experiment with different APIs. |
| 10 */ | 10 */ |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 83 void runInNewContext([Map sandbox]) native; | 83 void runInNewContext([Map sandbox]) native; |
| 84 } | 84 } |
| 85 | 85 |
| 86 class fs native "require('fs')" { | 86 class fs native "require('fs')" { |
| 87 static void writeFileSync(String outfile, String text) native; | 87 static void writeFileSync(String outfile, String text) native; |
| 88 | 88 |
| 89 static String readFileSync(String filename, [String encoding = 'utf8']) | 89 static String readFileSync(String filename, [String encoding = 'utf8']) |
| 90 native; | 90 native; |
| 91 | 91 |
| 92 static String realpathSync(String path) native; | 92 static String realpathSync(String path) native; |
| 93 | |
| 94 static void mkdirSync(String path, [num mode = 511 /* 077 octal */]) native; | |
| 95 static List<String> readdirSync(String path) native; | |
| 96 static void rmdirSync(String path) native; | |
| 97 static Stats statSync(String path) native; | |
| 98 static void unlinkSync(String path) native; | |
| 99 } | |
| 100 | |
| 101 class Stats native "fs.Stats" { | |
| 102 bool isFile() native; | |
|
Jacob
2011/11/16 19:59:30
should these be
bool get file() native;
bool get
jimhug
2011/11/17 16:59:44
This is a tough interop case and I'm unsure at whi
jacob314
2011/11/17 19:06:16
I agree that just reusing the node names and at mo
Bob Nystrom
2011/11/17 20:44:21
What Jim said. I was under the impression that thi
| |
| 103 bool isDirectory() native; | |
| 104 bool isBlockDevice() native; | |
| 105 bool isCharacterDevice() native; | |
| 106 bool isSymbolicLink() native; | |
| 107 bool isFIFO() native; | |
| 108 bool isSocket() native; | |
| 109 | |
| 110 // TODO(rnystrom): There are also the other fields we can add here if needed. | |
| 111 // See: http://nodejs.org/docs/v0.6.1/api/fs.html#fs.Stats. | |
| 93 } | 112 } |
| 94 | 113 |
| 95 class path native "require('path')" { | 114 class path native "require('path')" { |
| 96 static bool existsSync(String filename) native; | 115 static bool existsSync(String filename) native; |
| 97 static String dirname(String path) native; | 116 static String dirname(String path) native; |
| 98 static String basename(String path) native; | 117 static String basename(String path) native; |
| 99 static String extname(String path) native; | 118 static String extname(String path) native; |
| 100 static String normalize(String path) native; | 119 static String normalize(String path) native; |
| 101 // TODO(jimhug): Get the right signatures for normalizeArray and join | 120 // TODO(jimhug): Get the right signatures for normalizeArray and join |
| 102 } | 121 } |
| 103 | 122 |
| 104 class Readline native "require('readline')" { | 123 class Readline native "require('readline')" { |
| 105 static ReadlineInterface createInterface(input, output) native; | 124 static ReadlineInterface createInterface(input, output) native; |
| 106 } | 125 } |
| 107 | 126 |
| 108 class ReadlineInterface native "readline.Interface" { | 127 class ReadlineInterface native "readline.Interface" { |
| 109 void setPrompt(String prompt, [int length]) native; | 128 void setPrompt(String prompt, [int length]) native; |
| 110 void prompt() native; | 129 void prompt() native; |
| 111 void on(String event, Function callback) native; | 130 void on(String event, Function callback) native; |
| 112 } | 131 } |
| 113 | 132 |
| 114 interface TimeoutId {} | 133 interface TimeoutId {} |
| 115 | 134 |
| 116 TimeoutId setTimeout(Function callback, num delay, [arg]) native; | 135 TimeoutId setTimeout(Function callback, num delay, [arg]) native; |
| 117 clearTimeout(TimeoutId id) native; | 136 clearTimeout(TimeoutId id) native; |
| OLD | NEW |