diff src/org/tmatesoft/hg/util/Path.java @ 639:49f0749307a0 smartgit-4.5

Issue 46: Files with backslashes (legal on Linux) cause troubles (grafted from 170b6ecc890e476f38108067daa3dfffe9758013)
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 06 Jun 2013 14:21:11 +0200
parents 072b5f3ed0c8
children 5d8798772cca
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/Path.java	Fri Jun 07 13:21:20 2013 +0200
+++ b/src/org/tmatesoft/hg/util/Path.java	Thu Jun 06 14:21:11 2013 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2012 TMate Software Ltd
+ * Copyright (c) 2011-2013 TMate Software Ltd
  *  
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -20,6 +20,8 @@
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 
+import org.tmatesoft.hg.internal.Internals;
+
 /**
  * Identify repository files (not String nor io.File). Convenient for pattern matching. Memory-friendly.
  * 
@@ -148,6 +150,12 @@
 		int slashLoc = p1Tail.indexOf('/');
 		return slashLoc == -1 || slashLoc == p1Tail.length() - 1;
 	}
+	
+	private static final boolean runningOnWindows;
+	
+	static {
+		runningOnWindows = Internals.runningOnWindows();
+	}
 
 	public static Path create(CharSequence path) {
 		if (path == null) {
@@ -158,7 +166,7 @@
 			return o;
 		}
 		String p = path.toString();
-		if (p.indexOf('\\') != -1) {
+		if (runningOnWindows && p.indexOf('\\') != -1) {
 			throw new IllegalArgumentException();
 		}
 		Path rv = new Path(p);