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