UnixFileSystem.java revision 3261
0N/A * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 873N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * or visit www.oracle.com if you need additional information or have any 0N/A /* -- Normalization and construction -- */ 0N/A /* A normal Unix pathname contains no duplicate slashes and does not end 0N/A with a slash. It may be the empty string. */ 0N/A /* Normalize the given pathname, whose length is len, starting at the given 0N/A offset; everything before this offset is already normal. */ 0N/A if (n ==
0)
return "/";
0N/A for (
int i =
off; i < n; i++) {
0N/A /* Check that the given pathname is normal. If not, invoke the real 0N/A normalizer on the part of the pathname that requires normalization. 0N/A This way we iterate through the whole pathname string only once. */ 0N/A for (
int i =
0; i < n; i++) {
0N/A // "/foo/" --> "/foo", but "/" --> "/" 0N/A /* -- Path operations -- */ 0N/A // Caches for canonicalization results to improve startup performance. 0N/A // The first cache handles repeated canonicalizations of the same path 0N/A // name. The prefix cache handles repeated canonicalizations within the 0N/A // same directory, and must not create results differing from the true 0N/A // canonicalization algorithm in canonicalize_md.c. For this reason the 0N/A // prefix cache is conservative and is not used for complex path names. 0N/A // On Unix symlinks can jump anywhere in the file system, so we only 0N/A // treat prefixes in java.home as trusted and cacheable in the 0N/A // canonicalization algorithm 0N/A // Note that this can cause symlinks that should 0N/A // be resolved to a destination directory to be 0N/A // resolved to the directory they're contained in 0N/A // Hit only in prefix cache; full path is canonical 0N/A // Note that we don't allow a resolved symlink 0N/A // to elsewhere in java.home to pollute the 0N/A // prefix cache (java.home prefix cache could 0N/A // just as easily be a set at this point) 0N/A // Best-effort attempt to get parent of this path; used for 0N/A // optimization of filename canonicalization. This must return null for 0N/A // any cases where the code in canonicalize_md.c would throw an 0N/A // exception or otherwise deal with non-simple pathnames like handling 0N/A // of "." and "..". It may conservatively return null in other 0N/A // situations as well. Returning null will cause the underlying 0N/A // (expensive) canonicalization routine to be called. 0N/A // Punt on pathnames containing . and .. // Punt on pathnames containing . and .. // Punt on pathnames containing adjacent slashes /* -- Attribute accessors -- */ /* -- File operations -- */ // Keep canonicalization caches in sync after file deletion // and renaming operations. Could be more clever than this // not worth it since these entries expire after 30 seconds // Keep canonicalization caches in sync after file deletion // and renaming operations. Could be more clever than this // not worth it since these entries expire after 30 seconds /* -- Filesystem interface -- */ /* -- Basic infrastructure -- */ private static native void initIDs();