Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/WinToNixPathRewrite.java @ 414:bb278ccf9866
Pull changes from smartgit3 branch
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 21 Mar 2012 20:51:12 +0100 |
| parents | 0f5696623512 |
| children | 9c9c442b5f2e |
comparison
equal
deleted
inserted
replaced
| 413:7f27122011c3 | 414:bb278ccf9866 |
|---|---|
| 1 /* | |
| 2 * Copyright (c) 2012 TMate Software Ltd | |
| 3 * | |
| 4 * This program is free software; you can redistribute it and/or modify | |
| 5 * it under the terms of the GNU General Public License as published by | |
| 6 * the Free Software Foundation; version 2 of the License. | |
| 7 * | |
| 8 * This program is distributed in the hope that it will be useful, | |
| 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 11 * GNU General Public License for more details. | |
| 12 * | |
| 13 * For information on how to redistribute this software under | |
| 14 * the terms of a license other than GNU General Public License | |
| 15 * contact TMate Software at support@hg4j.com | |
| 16 */ | |
| 17 package org.tmatesoft.hg.internal; | |
| 18 | |
| 19 import org.tmatesoft.hg.util.PathRewrite; | |
| 20 | |
| 21 /** | |
| 22 * Translate windows path separators to Unix/POSIX-style | |
| 23 * | |
| 24 * @author Artem Tikhomirov | |
| 25 * @author Tmate Software Ltd. | |
| 26 */ | |
| 27 public final class WinToNixPathRewrite implements PathRewrite { | |
| 28 public CharSequence rewrite(CharSequence p) { | |
| 29 // TODO handle . and .. (although unlikely to face them from GUI client) | |
| 30 String path = p.toString(); | |
| 31 path = path.replace('\\', '/').replace("//", "/"); | |
| 32 if (path.startsWith("/")) { | |
| 33 path = path.substring(1); | |
| 34 } | |
| 35 return path; | |
| 36 } | |
| 37 } |
