/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A parser of Windows path strings
*/
class WindowsPathParser {
private WindowsPathParser() { }
/**
* The result of a parse operation
*/
static class Result {
}
/**
* The path type
*/
return type;
}
/**
* The root component
*/
return root;
}
/**
* The normalized path (includes root)
*/
return path;
}
}
/**
* Parses the given input as a Windows path
*/
}
/**
* Parses the given input as a Windows path where it is known that the
* path is already normalized.
*/
}
/**
* Parses the given input as a Windows path.
*
* @param requireToNormalize
* Indicates if the path requires to be normalized
*/
int off = 0;
if (len > 1) {
char c = 0;
int next = 2;
// UNC: We keep the first two slash, collapse all the
// following, then take the hostname and share name out,
// meanwhile collapsing all the redundant slashes.
} else {
char c2;
// avoid concatenation when root is "D:\"
if (c2 == '\\') {
} else {
}
off = 3;
} else {
off = 2;
}
}
}
}
if (off == 0) {
root = "\\";
} else {
}
}
if (requireToNormalize) {
} else {
}
}
/**
* Remove redundant slashes from the rest of the path, forcing all slashes
* into the preferred slash.
*/
char lastC = 0;
if (isSlash(c)) {
if (lastC == ' ')
throw new InvalidPathException(path,
off - 1);
} else {
if (isInvalidPathChar(c))
throw new InvalidPathException(path,
"Illegal char <" + c + ">",
off);
lastC = c;
off++;
}
}
if (lastC == ' ')
throw new InvalidPathException(path,
off - 1);
}
}
private static final boolean isSlash(char c) {
return (c == '\\') || (c == '/');
}
return off;
}
char c;
if (isInvalidPathChar(c))
throw new InvalidPathException(path,
"Illegal character [" + c + "] in path",
off);
off++;
}
return off;
}
private static final boolean isLetter(char c) {
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
}
// Reserved characters for window path name
}
}