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

Side by Side Diff: runtime/bin/file.cc

Issue 1193653002: Add file modes for opening a file write only (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Addressed review comments + fixed analyzer reported issues Created 5 years, 6 months 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "bin/file.h" 5 #include "bin/file.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/dartutils.h" 8 #include "bin/dartutils.h"
9 #include "bin/io_buffer.h" 9 #include "bin/io_buffer.h"
10 #include "bin/utils.h" 10 #include "bin/utils.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 remaining -= bytes_written; // Reduce the number of remaining bytes. 52 remaining -= bytes_written; // Reduce the number of remaining bytes.
53 current_buffer += bytes_written; // Move the buffer forward. 53 current_buffer += bytes_written; // Move the buffer forward.
54 } 54 }
55 return true; 55 return true;
56 } 56 }
57 57
58 58
59 File::FileOpenMode File::DartModeToFileMode(DartFileOpenMode mode) { 59 File::FileOpenMode File::DartModeToFileMode(DartFileOpenMode mode) {
60 ASSERT(mode == File::kDartRead || 60 ASSERT(mode == File::kDartRead ||
61 mode == File::kDartWrite || 61 mode == File::kDartWrite ||
62 mode == File::kDartAppend); 62 mode == File::kDartAppend ||
63 mode == File::kDartWriteOnly ||
64 mode == File::kDartWriteOnlyAppend);
63 if (mode == File::kDartWrite) { 65 if (mode == File::kDartWrite) {
64 return File::kWriteTruncate; 66 return File::kWriteTruncate;
65 } 67 }
66 if (mode == File::kDartAppend) { 68 if (mode == File::kDartAppend) {
67 return File::kWrite; 69 return File::kWrite;
68 } 70 }
71 if (mode == File::kDartWriteOnly) {
72 return File::kWriteOnlyTruncate;
73 }
74 if (mode == File::kDartWriteOnlyAppend) {
75 return File::kWriteOnly;
76 }
69 return File::kRead; 77 return File::kRead;
70 } 78 }
71 79
72 80
73 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) { 81 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) {
74 const char* filename = 82 const char* filename =
75 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 83 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
76 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); 84 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
77 File::DartFileOpenMode dart_file_mode = 85 File::DartFileOpenMode dart_file_mode =
78 static_cast<File::DartFileOpenMode>(mode); 86 static_cast<File::DartFileOpenMode>(mode);
(...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } 1256 }
1249 } else { 1257 } else {
1250 return CObject::FileClosedError(); 1258 return CObject::FileClosedError();
1251 } 1259 }
1252 } 1260 }
1253 return CObject::IllegalArgumentError(); 1261 return CObject::IllegalArgumentError();
1254 } 1262 }
1255 1263
1256 } // namespace bin 1264 } // namespace bin
1257 } // namespace dart 1265 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/file.h ('k') | runtime/bin/file_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698