3909N/A * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. 893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 893N/A * This code is free software; you can redistribute it and/or modify it 893N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 893N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 893N/A * This code is distributed in the hope that it will be useful, but WITHOUT 893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 893N/A * version 2 for more details (a copy is included in the LICENSE file that 893N/A * accompanied this code). 893N/A * You should have received a copy of the GNU General Public License version 893N/A * 2 along with this work; if not, write to the Free Software Foundation, 893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 893N/A * Windows implementation of Path 893N/A // The maximum path that does not require long path prefix. On Windows 893N/A // the maximum path is 260 minus 1 (NUL) but for directories it is 260 893N/A // minus 12 minus 1 (to allow for the creation of a 8.3 file in the 893N/A // Maximum extended-length path 893N/A // FIXME - eliminate this reference to reduce space 893N/A // root component (may be empty) 893N/A // the path to use in Win32 calls. This differs from path for relative 893N/A // paths and has a long path prefix for all paths longer than MAX_PATH. 893N/A // offsets into name components (computed lazily) 893N/A // computed hash code (computed lazily, no need to be volatile) 893N/A * Initializes a new instance of this class. 907N/A * Creates a Path by parsing the given path. 907N/A * Creates a Path from a given path that is known to be normalized. 907N/A * Creates a WindowsPath from a given path that is known to be normalized. 893N/A // use this message when throwing exceptions 893N/A // use this path for permission checks 893N/A // use this path for Win32 calls 893N/A // This method will prefix long paths with \\?\ or \\?\UNC as required. 893N/A // short absolute paths can be used directly 893N/A // return cached values if available 893N/A // Win32 path already available 893N/A // resolve against default directory 893N/A // Long paths need to have "." and ".." removed and be prefixed with 893N/A // "\\?\". Note that it is okay to remove ".." even when it follows 893N/A // a link - for example, it is okay for foo/link/../bar to be changed 893N/A // will access foo/bar anyway (which differs to Unix systems) 893N/A // cache the resolved path (except drive relative paths as the working 893N/A // directory on removal media devices can change during the lifetime 893N/A // return this path resolved against the file system's default directory 893N/A // Relative path ("foo" for example) 893N/A // Directory relative path ("\foo" for example) 893N/A // Drive relative path ("C:foo" for example). 893N/A // relative to default directory 893N/A // relative to some other drive 893N/A // returns true if same drive letter 893N/A // Add long path prefix to path if required 893N/A // -- Path operations -- 893N/A // represents root component only 893N/A // represents root component only 893N/A // can only relativize paths of the same type 893N/A // can only relativize paths if root component matches 893N/A // append ..\ for remaining names in the base 893N/A // append remaining names in child 893N/A // drop trailing slash in result 893N/A // multiple passes to eliminate all occurences of "." and "name/.." 893N/A // "." or something else 893N/A // name/<ignored>/.. found so mark name and ".." to be 893N/A // \\server\\share\<ignored>\.. 893N/A for (
int j=
0; j<i; j++) {
893N/A // all proceeding names are ignored 893N/A // corner case - all names removed 893N/A // re-constitute the path from the remaining names. 893N/A // drop trailing slash in result 893N/A // if different roots then return other 893N/A // generate offset array 3471N/A // empty path considered to have one name element 893N/A // if this path has a root component the given path's root must match 3471N/A // empty path starts with itself 893N/A // roots match so compare elements 893N/A // FIXME: should compare in uppercase 893N/A // other path is longer 3471N/A // empty path ends in itself 893N/A // given path has more elements that this path 893N/A // FIXME: should compare in uppercase 893N/A // match last 'otherCount' elements 893N/A // FIXME: should compare in uppercase 893N/A // OK if two or more threads compute hash 893N/A // -- file operations -- 893N/A // permission check as per spec 893N/A // When a security manager is set then we need to make a defensive 893N/A // copy of the modifiers and check for the Windows specific FILE_TREE 893N/A // modifier. When the modifier is present then check that permission 893N/A // has been granted recursively.