2362N/A * Copyright (c) 1998, 2000, 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. 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 0N/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. 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 0N/A @summary Common definitions for general exhaustive pathname tests 0N/A @author Mark Reinhold 0N/A /* Generate a filename unique to this run */ 0N/A * Find a file in the given subdirectory, or descend into further 0N/A * subdirectories, if any, if no file is found here. Return null if no 0N/A * file can be found anywhere beneath the given subdirectory. 0N/A * @param dir Directory at which we started 0N/A * @param subdir Subdirectory that we're exploring 0N/A * @param dl Listing of subdirectory 0N/A * Construct a string that names a file in the given directory. If create 0N/A * is true, then create a file if none is found, and throw an exception if 0N/A * that is not possible; otherwise, return null if no file can be found. 0N/A * Construct a string that names a subdirectory of the given directory. 0N/A * If create is true, then create a subdirectory if none is found, and 0N/A * throw an exception if that is not possible; otherwise, return null if 0N/A * no subdirectory can be found. 0N/A /* Heuristic to avoid scanning huge directories */ 0N/A /** Construct a string that does not name a file in the given directory */ 0N/A for (
int i =
0; i <
1024; i++) {
0N/A /** Ensure that the named file does not exist */ 0N/A /** Tell whether the given character is a "slash" on this platform */ 0N/A * Trim trailing slashes from the given string, but leave singleton slashes 0N/A * alone (they denote root directories) 0N/A if (n ==
0)
return s;
0N/A if ((n >=
1) && s.
charAt(n -
1) ==
':')
break;
0N/A /** Concatenate two paths, trimming slashes as needed */ 0N/A /** Hash table of input pathnames, used to detect duplicates */ 0N/A * Check the given pathname. Its canonical pathname should be the given 0N/A * answer. If the path names a file that exists and is readable, then 0N/A * FileInputStream and RandomAccessFile should both be able to open it. 0N/A * The following three mutually-recursive methods generate and check a tree 0N/A * of filenames of arbitrary depth. Each method has (at least) these 0N/A * int depth Remaining tree depth 0N/A * boolean create Controls whether test files and directories 0N/A * will be created as needed 0N/A * String ans Expected answer for the check method (above) 0N/A * String ask Input pathname to be passed to the check method 0N/A /** Check a single slash case, plus its children */ 0N/A /** Check slash cases for the given ask string */ 0N/A /** Check name cases for the given ask string */ 0N/A /* Win32 resolves \\foo\bar\.. to \\foo\bar */ 0N/A // Fix for 4237875. We must ensure that we are sufficiently 0N/A // deep in the path hierarchy to test parents this high up