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

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

Issue 2087723002: Fix canonicalization of relative paths, Dart_DefaultCanonicalizeUrl expects the base)url to end wit… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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/dartutils.h ('k') | runtime/bin/gen_snapshot.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/crypto.h" 7 #include "bin/crypto.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/extensions.h" 9 #include "bin/extensions.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message); 926 return NewDartExceptionWithMessage(kCoreLibURL, "_InternalError", message);
927 } 927 }
928 928
929 929
930 bool DartUtils::SetOriginalWorkingDirectory() { 930 bool DartUtils::SetOriginalWorkingDirectory() {
931 original_working_directory = Directory::CurrentNoScope(); 931 original_working_directory = Directory::CurrentNoScope();
932 return original_working_directory != NULL; 932 return original_working_directory != NULL;
933 } 933 }
934 934
935 935
936 Dart_Handle DartUtils::GetCanonicalizableWorkingDirectory() {
937 const char* str = DartUtils::original_working_directory;
938 intptr_t len = strlen(str);
939 if ((str[len] == '/') || (IsWindowsHost() && str[len] == '\\')) {
940 return Dart_NewStringFromCString(str);
941 }
942 char* new_str = reinterpret_cast<char*>(Dart_ScopeAllocate(len + 2));
943 snprintf(new_str, (len + 2), "%s%s", str, File::PathSeparator());
944 return Dart_NewStringFromCString(new_str);
945 }
946
947
936 // Statically allocated Dart_CObject instances for immutable 948 // Statically allocated Dart_CObject instances for immutable
937 // objects. As these will be used by different threads the use of 949 // objects. As these will be used by different threads the use of
938 // these depends on the fact that the marking internally in the 950 // these depends on the fact that the marking internally in the
939 // Dart_CObject structure is not marking simple value objects. 951 // Dart_CObject structure is not marking simple value objects.
940 Dart_CObject CObject::api_null_ = { Dart_CObject_kNull , { 0 } }; 952 Dart_CObject CObject::api_null_ = { Dart_CObject_kNull , { 0 } };
941 Dart_CObject CObject::api_true_ = { Dart_CObject_kBool , { true } }; 953 Dart_CObject CObject::api_true_ = { Dart_CObject_kBool , { true } };
942 Dart_CObject CObject::api_false_ = { Dart_CObject_kBool, { false } }; 954 Dart_CObject CObject::api_false_ = { Dart_CObject_kBool, { false } };
943 CObject CObject::null_ = CObject(&api_null_); 955 CObject CObject::null_ = CObject(&api_null_);
944 CObject CObject::true_ = CObject(&api_true_); 956 CObject CObject::true_ = CObject(&api_true_);
945 CObject CObject::false_ = CObject(&api_false_); 957 CObject CObject::false_ = CObject(&api_false_);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 new CObjectString(CObject::NewString(os_error->message())); 1249 new CObjectString(CObject::NewString(os_error->message()));
1238 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1250 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1239 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1251 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1240 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1252 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1241 result->SetAt(2, error_message); 1253 result->SetAt(2, error_message);
1242 return result; 1254 return result;
1243 } 1255 }
1244 1256
1245 } // namespace bin 1257 } // namespace bin
1246 } // namespace dart 1258 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698