< prev index next >
src/java.base/windows/classes/java/io/WinNTFileSystem.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -23,10 +23,12 @@
* questions.
*/
package java.io;
+import java.io.File;
+import java.nio.file.Path;
import java.util.Locale;
import java.util.Properties;
import sun.security.action.GetPropertyAction;
/**
@@ -625,10 +627,31 @@
private native long getSpace0(File f, int t);
/* -- Basic infrastructure -- */
+ // Obtain maximum file component length from GetVolumeInformation which
+ // expects the path to be null or a root component ending in a backslash
+ private native long getNameMax0(String path);
+
+ public long getNameMax(String path) {
+ String s = null;
+ if (path != null) {
+ File f = new File(path);
+ if (f.isAbsolute()) {
+ Path root = f.toPath().getRoot();
+ if (root != null) {
+ s = root.toString();
+ if (!s.endsWith("\\")) {
+ s = s + "\\";
+ }
+ }
+ }
+ }
+ return getNameMax0(s);
+ }
+
@Override
public int compare(File f1, File f2) {
return f1.getPath().compareToIgnoreCase(f2.getPath());
}
< prev index next >