/** * @deprecated Use {@link java.nio.file.Files#readAttributes} with * {@link java.nio.file.attribute.DosFileAttributes} and reflective calls to * WindowsFileAttributes if necessary. */ @Deprecated public static int getWin32FileAttributes(File file) throws IOException { // allow lookup of paths longer than MAX_PATH // http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx String canonicalPath = file.getCanonicalPath(); String path; if(canonicalPath.length() < 260) { // path is short, use as-is path = canonicalPath; } else if(canonicalPath.startsWith("\\\\")) { // network share // \\server\share --> \\?\UNC\server\share path = "\\\\?\\UNC\\" + canonicalPath.substring(2); } else { // prefix, canonical path should be normalized and absolute so this should work. path = "\\\\?\\" + canonicalPath; } return Kernel32.INSTANCE.GetFileAttributesW(new WString(path)); }
public static int getWin32FileAttributes(File file) throws IOException { // allow lookup of paths longer than MAX_PATH // http://msdn.microsoft.com/en-us/library/aa365247(v=VS.85).aspx String canonicalPath = file.getCanonicalPath(); String path; if(canonicalPath.length() < 260) { // path is short, use as-is path = canonicalPath; } else if(canonicalPath.startsWith("\\\\")) { // network share // \\server\share --> \\?\UNC\server\share path = "\\\\?\\UNC\\" + canonicalPath.substring(2); } else { // prefix, canonical path should be normalized and absolute so this should work. path = "\\\\?\\" + canonicalPath; } return Kernel32.INSTANCE.GetFileAttributesW(new WString(path)); }