diff src/org/tmatesoft/hg/util/Path.java @ 634:170b6ecc890e

Issue 46: Files with backslashes (legal on Linux) cause troubles
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 06 Jun 2013 14:21:11 +0200
parents fedc54356091
children 5d8798772cca
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/Path.java	Thu May 30 16:14:46 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(String.format("Path '%s' contains illegal char at %d", p, p.indexOf('\\')));
 		}
 		Path rv = new Path(p);