# HG changeset patch # User Artem Tikhomirov # Date 1370521271 -7200 # Node ID 170b6ecc890e476f38108067daa3dfffe9758013 # Parent e66788de0cf8cb83ca50f162d810eed43d56e874 Issue 46: Files with backslashes (legal on Linux) cause troubles diff -r e66788de0cf8 -r 170b6ecc890e src/org/tmatesoft/hg/util/Path.java --- 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);