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

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

Issue 2761673002: [dart:io][windows] Use WriteFile instead of _write (Closed)
Patch Set: Format stdio.dart Created 3 years, 8 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 #if !defined(DART_IO_DISABLED) 5 #if !defined(DART_IO_DISABLED)
6 6
7 #include "bin/file.h" 7 #include "bin/file.h"
8 8
9 #include "bin/builtin.h" 9 #include "bin/builtin.h"
10 #include "bin/dartutils.h" 10 #include "bin/dartutils.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 intptr_t file_pointer = 69 intptr_t file_pointer =
70 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1)); 70 DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
71 File* file = reinterpret_cast<File*>(file_pointer); 71 File* file = reinterpret_cast<File*>(file_pointer);
72 Dart_WeakPersistentHandle handle = Dart_NewWeakPersistentHandle( 72 Dart_WeakPersistentHandle handle = Dart_NewWeakPersistentHandle(
73 dart_this, reinterpret_cast<void*>(file), sizeof(*file), ReleaseFile); 73 dart_this, reinterpret_cast<void*>(file), sizeof(*file), ReleaseFile);
74 file->SetWeakHandle(handle); 74 file->SetWeakHandle(handle);
75 SetFile(dart_this, file_pointer); 75 SetFile(dart_this, file_pointer);
76 } 76 }
77 77
78 78
79 void FUNCTION_NAME(File_SetTranslation)(Dart_NativeArguments args) {
80 File* file = GetFile(args);
81 ASSERT(file != NULL);
82 int64_t translation;
83 Dart_Handle status = Dart_GetNativeIntegerArgument(args, 1, &translation);
84 if (Dart_IsError(status)) {
85 Dart_PropagateError(status);
86 }
87 if ((translation != File::kText) && (translation != File::kBinary)) {
88 Dart_ThrowException(DartUtils::NewDartArgumentError(
89 "The argument must be a FileTranslation mode"));
90 }
91 file->SetTranslation(static_cast<File::DartFileTranslation>(translation));
92 }
93
94
95 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) { 79 void FUNCTION_NAME(File_Open)(Dart_NativeArguments args) {
96 const char* filename = 80 const char* filename =
97 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 81 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
98 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); 82 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
99 File::DartFileOpenMode dart_file_mode = 83 File::DartFileOpenMode dart_file_mode =
100 static_cast<File::DartFileOpenMode>(mode); 84 static_cast<File::DartFileOpenMode>(mode);
101 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode); 85 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
102 // Check that the file exists before opening it only for 86 // Check that the file exists before opening it only for
103 // reading. This is to prevent the opening of directories as 87 // reading. This is to prevent the opening of directories as
104 // files. Directories can be opened for reading using the posix 88 // files. Directories can be opened for reading using the posix
(...skipping 1196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 return CObject::IllegalArgumentError(); 1285 return CObject::IllegalArgumentError();
1302 } 1286 }
1303 } 1287 }
1304 return CObject::IllegalArgumentError(); 1288 return CObject::IllegalArgumentError();
1305 } 1289 }
1306 1290
1307 } // namespace bin 1291 } // namespace bin
1308 } // namespace dart 1292 } // namespace dart
1309 1293
1310 #endif // !defined(DART_IO_DISABLED) 1294 #endif // !defined(DART_IO_DISABLED)
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