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

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

Issue 2439173002: [windows] Make most file_win.cc functions use malloc for string conversions. (Closed)
Patch Set: Fix typo Created 4 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 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 const char* filename = 85 const char* filename =
86 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0)); 86 DartUtils::GetStringValue(Dart_GetNativeArgument(args, 0));
87 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1)); 87 int64_t mode = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
88 File::DartFileOpenMode dart_file_mode = 88 File::DartFileOpenMode dart_file_mode =
89 static_cast<File::DartFileOpenMode>(mode); 89 static_cast<File::DartFileOpenMode>(mode);
90 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode); 90 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
91 // Check that the file exists before opening it only for 91 // Check that the file exists before opening it only for
92 // reading. This is to prevent the opening of directories as 92 // reading. This is to prevent the opening of directories as
93 // files. Directories can be opened for reading using the posix 93 // files. Directories can be opened for reading using the posix
94 // 'open' call. 94 // 'open' call.
95 File* file = File::ScopedOpen(filename, file_mode); 95 File* file = File::Open(filename, file_mode);
96 if (file != NULL) { 96 if (file != NULL) {
97 Dart_SetReturnValue(args, 97 Dart_SetReturnValue(args,
98 Dart_NewInteger(reinterpret_cast<intptr_t>(file))); 98 Dart_NewInteger(reinterpret_cast<intptr_t>(file)));
99 } else { 99 } else {
100 Dart_SetReturnValue(args, DartUtils::NewDartOSError()); 100 Dart_SetReturnValue(args, DartUtils::NewDartOSError());
101 } 101 }
102 } 102 }
103 103
104 104
105 void FUNCTION_NAME(File_Exists)(Dart_NativeArguments args) { 105 void FUNCTION_NAME(File_Exists)(Dart_NativeArguments args) {
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 CObject* File::OpenRequest(const CObjectArray& request) { 670 CObject* File::OpenRequest(const CObjectArray& request) {
671 File* file = NULL; 671 File* file = NULL;
672 if ((request.Length() == 2) && 672 if ((request.Length() == 2) &&
673 request[0]->IsString() && 673 request[0]->IsString() &&
674 request[1]->IsInt32()) { 674 request[1]->IsInt32()) {
675 CObjectString filename(request[0]); 675 CObjectString filename(request[0]);
676 CObjectInt32 mode(request[1]); 676 CObjectInt32 mode(request[1]);
677 File::DartFileOpenMode dart_file_mode = 677 File::DartFileOpenMode dart_file_mode =
678 static_cast<File::DartFileOpenMode>(mode.Value()); 678 static_cast<File::DartFileOpenMode>(mode.Value());
679 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode); 679 File::FileOpenMode file_mode = File::DartModeToFileMode(dart_file_mode);
680 file = File::ScopedOpen(filename.CString(), file_mode); 680 file = File::Open(filename.CString(), file_mode);
681 if (file != NULL) { 681 if (file != NULL) {
682 return new CObjectIntptr( 682 return new CObjectIntptr(
683 CObject::NewIntptr(reinterpret_cast<intptr_t>(file))); 683 CObject::NewIntptr(reinterpret_cast<intptr_t>(file)));
684 } else { 684 } else {
685 return CObject::NewOSError(); 685 return CObject::NewOSError();
686 } 686 }
687 } 687 }
688 return CObject::IllegalArgumentError(); 688 return CObject::IllegalArgumentError();
689 } 689 }
690 690
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 return CObject::IllegalArgumentError(); 1230 return CObject::IllegalArgumentError();
1231 } 1231 }
1232 } 1232 }
1233 return CObject::IllegalArgumentError(); 1233 return CObject::IllegalArgumentError();
1234 } 1234 }
1235 1235
1236 } // namespace bin 1236 } // namespace bin
1237 } // namespace dart 1237 } // namespace dart
1238 1238
1239 #endif // !defined(DART_IO_DISABLED) 1239 #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