Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dartino 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 /// File access APIs. Only supported when Dartino is running on a Posix platform . | 5 /// File access APIs. Only supported when Dartino is running on a Posix platform . |
| 6 /// | 6 /// |
| 7 /// Usage | 7 /// Usage |
| 8 /// ----- | 8 /// ----- |
| 9 /// ```dart | 9 /// ```dart |
| 10 /// import 'package:file/file.dart'; | 10 /// import 'package:file/file.dart'; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 throw new FileException("Failed to create temporary file from '$path'"); | 70 throw new FileException("Failed to create temporary file from '$path'"); |
| 71 } | 71 } |
| 72 return new File._(temp.path, fd); | 72 return new File._(temp.path, fd); |
| 73 } | 73 } |
| 74 | 74 |
| 75 File._(this.path, this._fd); | 75 File._(this.path, this._fd); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Return the file descriptor value for this file. | 78 * Return the file descriptor value for this file. |
| 79 * | 79 * |
| 80 * This is especially useful in conjunction with `dart:fletch.ffi`. However it | 80 * This is especially useful in conjunction with `dart:dartino.ffi`. However i t |
|
Søren Gjesse
2016/02/03 12:06:54
Long line.
ricow1
2016/02/03 12:29:18
Done.
| |
| 81 * should be used with care, as the `File` object assumes full control over th e | 81 * should be used with care, as the `File` object assumes full control over th e |
|
Søren Gjesse
2016/02/03 12:06:54
Ditto.
ricow1
2016/02/03 12:29:18
Done.
| |
| 82 * file descriptor. | 82 * file descriptor. |
| 83 */ | 83 */ |
| 84 int get fd => _fd; | 84 int get fd => _fd; |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Write [buffer] to the file. The file must have been opened with [WRITE] | 87 * Write [buffer] to the file. The file must have been opened with [WRITE] |
| 88 * permissions. | 88 * permissions. |
| 89 */ | 89 */ |
| 90 void write(ByteBuffer buffer) { | 90 void write(ByteBuffer buffer) { |
| 91 int result = sys.write(_fd, buffer, 0, buffer.lengthInBytes); | 91 int result = sys.write(_fd, buffer, 0, buffer.lengthInBytes); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 static bool existsAsFile(String path) => sys.access(path) == 0; | 185 static bool existsAsFile(String path) => sys.access(path) == 0; |
| 186 } | 186 } |
| 187 | 187 |
| 188 class FileException implements Exception { | 188 class FileException implements Exception { |
| 189 final String message; | 189 final String message; |
| 190 | 190 |
| 191 FileException(this.message); | 191 FileException(this.message); |
| 192 | 192 |
| 193 String toString() => "FileException: $message"; | 193 String toString() => "FileException: $message"; |
| 194 } | 194 } |
| OLD | NEW |