/*
* 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.
*/
/**
* Windows implementation of Path
*/
// The maximum path that does not require long path prefix. On Windows
// the maximum path is 260 minus 1 (NUL) but for directories it is 260
// minus 12 minus 1 (to allow for the creation of a 8.3 file in the
// directory).
// Maximum extended-length path
// FIXME - eliminate this reference to reduce space
// path type
// root component (may be empty)
// normalized path
// the path to use in Win32 calls. This differs from path for relative
// paths and has a long path prefix for all paths longer than MAX_PATH.
// offsets into name components (computed lazily)
// computed hash code (computed lazily, no need to be volatile)
private int hash;
/**
* Initializes a new instance of this class.
*/
{
}
/**
* Creates a Path by parsing the given path.
*/
}
/**
* Creates a Path from a given path that is known to be normalized.
*/
{
try {
return new WindowsPath(fs,
} else {
return new WindowsPathWithAttributes(fs,
attrs);
}
} catch (InvalidPathException x) {
throw new AssertionError(x.getMessage());
}
}
/**
* Creates a WindowsPath from a given path that is known to be normalized.
*/
{
}
/**
* file tree traveral)
*/
private static class WindowsPathWithAttributes
extends WindowsPath implements BasicFileAttributesHolder
{
{
}
}
public void invalidate() {
}
}
// use this message when throwing exceptions
return path;
}
// use this path for permission checks
return path;
}
// use this path for Win32 calls
// This method will prefix long paths with \\?\ or \\?\UNC as required.
// short absolute paths can be used directly
return path;
// return cached values if available
// Win32 path already available
return resolved;
}
// resolve against default directory
resolved = getAbsolutePath();
// Long paths need to have "." and ".." removed and be prefixed with
// "\\?\". Note that it is okay to remove ".." even when it follows
throw new WindowsException("Cannot access file with path exceeding "
+ MAX_LONG_PATH + " characters");
}
}
// cache the resolved path (except drive relative paths as the working
// directory on removal media devices can change during the lifetime
// of the VM)
synchronized (path) {
}
}
return resolved;
}
// return this path resolved against the file system's default directory
if (isAbsolute())
return path;
// Relative path ("foo" for example)
if (isEmpty())
return defaultDirectory;
return defaultDirectory + path;
} else {
}
}
// Directory relative path ("\foo" for example)
}
// Drive relative path ("C:foo" for example).
// relative to default directory
} else {
}
return result;
} else {
// relative to some other drive
try {
throw new WindowsException("");
} catch (WindowsException x) {
throw new WindowsException("Unable to get working directory of drive '" +
}
} else {
}
return result;
}
}
// returns true if same drive letter
}
// Add long path prefix to path if required
} else {
}
}
return path;
}
return fs;
}
// -- Path operations --
private boolean isEmpty() {
}
}
// represents empty path
if (len == 0)
return this;
// represents root component only
return null;
else
off++;
}
// represents root component only
return null;
return getRoot();
else
return new WindowsPath(getFileSystem(),
type,
root,
}
return null;
}
// package-private
return type;
}
// package-private
boolean isUnc() {
}
boolean needsSlashWhenResolving() {
return false;
}
public boolean isAbsolute() {
}
throw new NullPointerException();
if (!(path instanceof WindowsPath)) {
throw new ProviderMismatchException();
}
return (WindowsPath)path;
}
return emptyPath();
// can only relativize paths of the same type
throw new IllegalArgumentException("'other' is different type of Path");
// can only relativize paths if root component matches
throw new IllegalArgumentException("'other' has different root");
int bn = this.getNameCount();
// skip matching names
int i = 0;
while (i < n) {
break;
i++;
}
// append ..\ for remaining names in the base
for (int j=i; j<bn; j++) {
}
// append remaining names in child
for (int j=i; j<cn; j++) {
}
// drop trailing slash in result
}
final int count = getNameCount();
return this;
// multiple passes to eliminate all occurences of "." and "name/.."
int prevRemaining;
do {
int prevName = -1;
for (int i=0; i<count; i++) {
if (ignore[i])
continue;
// not "." or ".."
prevName = i;
continue;
}
// "." or something else
// ignore "."
ignore[i] = true;
remaining--;
} else {
prevName = i;
}
continue;
}
// not ".."
prevName = i;
continue;
}
// ".." found
if (prevName >= 0) {
// name/<ignored>/.. found so mark name and ".." to be
// ignored
ignore[i] = true;
prevName = -1;
} else {
// Cases:
// C:\<ignored>\..
// \\server\\share\<ignored>\..
// \<ignored>..
boolean hasPrevious = false;
for (int j=0; j<i; j++) {
if (!ignore[j]) {
hasPrevious = true;
break;
}
}
if (!hasPrevious) {
// all proceeding names are ignored
ignore[i] = true;
remaining--;
}
}
}
}
} while (prevRemaining > remaining);
// no redundant names
return this;
// corner case - all names removed
if (remaining == 0) {
}
// re-constitute the path from the remaining names.
for (int i=0; i<count; i++) {
if (!ignore[i]) {
}
}
// drop trailing slash in result
}
return this;
if (other.isAbsolute())
return other;
case RELATIVE: {
} else {
}
}
case DIRECTORY_RELATIVE: {
} else {
}
}
case DRIVE_RELATIVE: {
return other;
// if different roots then return other
return other;
// same roots
} else {
}
}
default:
throw new AssertionError();
}
}
// generate offset array
private void initOffsets() {
if (isEmpty()) {
// empty path considered to have one name element
} else {
off++;
} else {
}
}
}
synchronized (this) {
}
}
}
public int getNameCount() {
initOffsets();
}
initOffsets();
}
initOffsets();
throw new IllegalArgumentException();
}
initOffsets();
if (beginIndex < 0)
throw new IllegalArgumentException();
throw new IllegalArgumentException();
throw new IllegalArgumentException();
if (beginIndex >= endIndex)
throw new IllegalArgumentException();
for (int i = beginIndex; i < endIndex; i++) {
if (i != (endIndex-1))
}
}
return false;
// if this path has a root component the given path's root must match
return false;
}
// empty path starts with itself
return this.isEmpty();
// roots match so compare elements
int thisCount = getNameCount();
if (otherCount <= thisCount) {
while (--otherCount >= 0) {
// FIXME: should compare in uppercase
return false;
}
return true;
}
return false;
}
return false;
// other path is longer
return false;
}
// empty path ends in itself
return this.isEmpty();
}
int thisCount = this.getNameCount();
// given path has more elements that this path
if (otherCount > thisCount) {
return false;
}
// compare roots
if (otherCount < thisCount)
return false;
// FIXME: should compare in uppercase
return false;
}
// match last 'otherCount' elements
while (--otherCount >= 0) {
// FIXME: should compare in uppercase
return false;
}
return true;
}
throw new NullPointerException();
for (int i = 0; i < min; i++) {
}
}
}
}
}
return false;
}
public int hashCode() {
// OK if two or more threads compute hash
int h = hash;
if (h == 0) {
}
hash = h;
}
return h;
}
return path;
}
// -- file operations --
// package-private
throws WindowsException
{
int flags = FILE_FLAG_BACKUP_SEMANTICS;
return CreateFile(getPathForWin32Calls(),
0L,
flags);
}
void checkRead() {
}
}
void checkWrite() {
}
}
void checkDelete() {
}
}
return WindowsUriSupport.toUri(this);
}
if (isAbsolute())
return this;
// permission check as per spec
}
try {
} catch (WindowsException x) {
}
}
checkRead();
}
throws IOException
{
throw new NullPointerException();
if (!(watcher instanceof WindowsWatchService))
throw new ProviderMismatchException();
// When a security manager is set then we need to make a defensive
// copy of the modifiers and check for the Windows specific FILE_TREE
// modifier. When the modifier is present then check that permission
// has been granted recursively.
boolean watchSubtree = false;
if (ml > 0) {
int i=0;
while (i < ml) {
watchSubtree = true;
break;
}
}
}
String s = getPathForPermissionCheck();
if (watchSubtree)
}
}
}