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

Unified Diff: dart/lib/compiler/implementation/filenames.dart

Issue 10123013: Make frog.py --leg work on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add link to MS blog post about Windows file names and URIs Created 8 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 side-by-side diff with in-line comments
Download patch
Index: dart/lib/compiler/implementation/filenames.dart
diff --git a/dart/lib/compiler/implementation/filenames.dart b/dart/lib/compiler/implementation/filenames.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0e43bca65da90f461e00f9a6bcc6d90e606daf53
--- /dev/null
+++ b/dart/lib/compiler/implementation/filenames.dart
@@ -0,0 +1,31 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#library('filenames');
+
+#import('dart:io');
+
+// TODO(ahe): This library should be replaced by a general
+// path-munging library.
+//
+// See also:
+// http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
+
+String nativeToUriPath(String filename) {
+ if (Platform.operatingSystem() != 'windows') return filename;
+ filename = filename.replaceAll('\\', '/');
+ if (filename.length > 2 && filename[1] == ':') {
+ filename = "/$filename";
+ }
+ return filename;
+}
+
+String uriPathToNative(String path) {
+ if (Platform.operatingSystem() != 'windows') return path;
+ if (path.length > 3 && path[0] == '/' && path[2] == ':') {
+ return path.substring(1);
+ } else {
+ return path;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698