/*
* 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.
*
* 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.
*/
/* @test
@bug 4759207 4403166 4165006 4403166 6182812 6274272
@summary Test to see if win32 path length can be greater than 260
*/
public class MaxPathLength {
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
"areallylongfilenamethatsforsur";
private static boolean isWindows = false;
private static long totalSpace;
private static long freeSpace;
private static long usableSpace;
isWindows = true;
}
return; // We don't run this test on Solaris either.
// Some Solaris machines have very "slow" disk
// access performance which causes this one
// to timeout.
}
if (isWindows) {
}
for (int i = 4; i < 7; i++) {
testLongPath (i, name, false);
testLongPath (i, name, true);
name += "A";
}
}
// Testing below will not be run if "-extra" is not
return;
/* Testings below should not be run on a remote
dir that exists on a Solaris machine */
for (int i = 20; i < 21; i++) {
testLongPath (i, name, false);
testLongPath (i, name, true);
name += "A";
}
}
}
boolean tryAbsolute) throws Exception {
}
if (tryAbsolute) {
tPath = f.getCanonicalPath();
}
//for getCanonicalPath testing on win32
return;
}
if (!couldMakeTestDirectory) {
throw new RuntimeException ("Could not create test directory structure");
}
try {
if (tryAbsolute)
if (!dirFile.isDirectory())
throw new RuntimeException ("File.isDirectory() failed");
throw new RuntimeException ("File.getTotalSpace() failed");
throw new RuntimeException ("File.getFreeSpace() failed");
throw new RuntimeException ("File.getUsableSpace() failed");
}
if (!f.createNewFile()) {
throw new RuntimeException ("File.createNewFile() failed");
}
if (!f.exists())
throw new RuntimeException ("File.exists() failed");
if (!f.isFile())
throw new RuntimeException ("File.isFile() failed");
if (!f.canRead())
throw new RuntimeException ("File.canRead() failed");
if (!f.canWrite())
throw new RuntimeException ("File.canWrite() failed");
if (!f.delete())
throw new RuntimeException ("File.delete() failed");
if (f.length() != 1)
throw new RuntimeException ("File.length() failed");
if (!f.setLastModified(time))
throw new RuntimeException ("File.setLastModified() failed");
if (f.lastModified() == 0) {
throw new RuntimeException ("File.lastModified() failed");
}
throw new RuntimeException ("File.list() failed");
}
throw new RuntimeException ("File.listFiles() failed");
if (isWindows &&
throw new RuntimeException ("getCanonicalPath() failed");
/*there is a known issue that renameTo fails if
(1)the path is a UNC path and
(2)the path length is bigger than 1092
so don't stop if above are true
*/
throw new RuntimeException ("File.renameTo() failed for lenth="
}
return;
}
throw new RuntimeException ("Renamed file is not readable");
throw new RuntimeException ("Renamed file is not writable");
throw new RuntimeException ("Renamed file's size is not correct");
/* add a script to test these two if we got a regression later
if (!f.setReadOnly())
throw new RuntimeException ("File.setReadOnly() failed");
f.deleteOnExit();
*/
} finally {
// Clean up
for (int i = 0; i < max; i++) {
pathString = created[i];
// Only works with completex canonical paths
}
}
}
}