diff options
author | herrick <none@none> | 2009-07-06 14:10:31 -0400 |
---|---|---|
committer | herrick <none@none> | 2009-07-06 14:10:31 -0400 |
commit | 8bcc43937cf4ef75514c8339e9aa61304aceb6f1 (patch) | |
tree | 3248382dfe0d1ec398392317a2fea748bd71ce2a /src/windows | |
parent | 92639748cc5f99420936b8e98e22b4a4a8476b5f (diff) | |
parent | 409972b51ec9205fd74f05a2c59744353b9fe7a6 (diff) |
Merge
Diffstat (limited to 'src/windows')
10 files changed, 150 insertions, 287 deletions
diff --git a/src/windows/classes/sun/nio/fs/WindowsConstants.java b/src/windows/classes/sun/nio/fs/WindowsConstants.java index f2619ac80..077a4893b 100644 --- a/src/windows/classes/sun/nio/fs/WindowsConstants.java +++ b/src/windows/classes/sun/nio/fs/WindowsConstants.java @@ -93,6 +93,7 @@ class WindowsConstants { public static final int ERROR_NOT_SAME_DEVICE = 17; public static final int ERROR_NOT_READY = 21; public static final int ERROR_FILE_EXISTS = 80; + public static final int ERROR_INVALID_PARAMATER = 87; public static final int ERROR_DISK_FULL = 112; public static final int ERROR_INSUFFICIENT_BUFFER = 122; public static final int ERROR_INVALID_LEVEL = 124; diff --git a/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java b/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java index fa0b14834..df7734891 100644 --- a/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java +++ b/src/windows/classes/sun/nio/fs/WindowsDirectoryStream.java @@ -152,11 +152,13 @@ class WindowsDirectoryStream } Path entry = WindowsPath .createFromNormalizedPath(dir.getFileSystem(), s, attrs); - if (filter.accept(entry)) { - return entry; - } else { - return null; + try { + if (filter.accept(entry)) + return entry; + } catch (IOException ioe) { + throwAsConcurrentModificationException(ioe); } + return null; } // reads next directory entry @@ -244,7 +246,7 @@ class WindowsDirectoryStream prevEntry = null; } try { - entry.delete(true); + entry.delete(); } catch (IOException ioe) { throwAsConcurrentModificationException(ioe); } catch (SecurityException se) { diff --git a/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java b/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java index 39c34a10e..5af9876f3 100644 --- a/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java +++ b/src/windows/classes/sun/nio/fs/WindowsFileAttributeViews.java @@ -28,7 +28,6 @@ package sun.nio.fs; import java.nio.file.attribute.*; import java.util.*; -import java.util.concurrent.TimeUnit; import java.io.IOException; import static sun.nio.fs.WindowsNativeDispatcher.*; @@ -56,9 +55,24 @@ class WindowsFileAttributeViews { } /** + * Adjusts a Windows time for the FAT epoch. + */ + private long adjustForFatEpoch(long time) { + // 1/1/1980 in Windows Time + final long FAT_EPOCH = 119600064000000000L; + if (time != -1L && time < FAT_EPOCH) { + return FAT_EPOCH; + } else { + return time; + } + } + + /** * Parameter values in Windows times. */ - void setFileTimes(long createTime, long lastAccessTime, long lastWriteTime) + void setFileTimes(long createTime, + long lastAccessTime, + long lastWriteTime) throws IOException { long handle = -1L; @@ -76,24 +90,43 @@ class WindowsFileAttributeViews { x.rethrowAsIOException(file); } - // update attributes + // update times try { - SetFileTime(handle, createTime, lastAccessTime, lastWriteTime); + SetFileTime(handle, + createTime, + lastAccessTime, + lastWriteTime); } catch (WindowsException x) { - x.rethrowAsIOException(file); + // If ERROR_INVALID_PARAMATER is returned and the volume is + // FAT then adjust to the FAT epoch and retry. + if (followLinks && x.lastError() == ERROR_INVALID_PARAMATER) { + try { + if (WindowsFileStore.create(file).type().equals("FAT")) { + SetFileTime(handle, + adjustForFatEpoch(createTime), + adjustForFatEpoch(lastAccessTime), + adjustForFatEpoch(lastWriteTime)); + // retry succeeded + x = null; + } + } catch (SecurityException ignore) { + } catch (WindowsException ignore) { + } catch (IOException ignore) { + // ignore exceptions to let original exception be thrown + } + } + if (x != null) + x.rethrowAsIOException(file); } finally { CloseHandle(handle); } } @Override - public void setTimes(Long lastModifiedTime, - Long lastAccessTime, - Long createTime, - TimeUnit unit) throws IOException + public void setTimes(FileTime lastModifiedTime, + FileTime lastAccessTime, + FileTime createTime) throws IOException { - file.checkWrite(); - // if all null then do nothing if (lastModifiedTime == null && lastAccessTime == null && createTime == null) @@ -102,42 +135,17 @@ class WindowsFileAttributeViews { return; } - // null => no change - // -1 => change to current time - long now = System.currentTimeMillis(); - long modTime = 0L, accTime = 0L, crTime = 0L; - if (lastModifiedTime != null) { - if (lastModifiedTime < 0L) { - if (lastModifiedTime != -1L) - throw new IllegalArgumentException(); - modTime = now; - } else { - modTime = TimeUnit.MILLISECONDS.convert(lastModifiedTime, unit); - } - modTime = WindowsFileAttributes.toWindowsTime(modTime); - } - if (lastAccessTime != null) { - if (lastAccessTime < 0L) { - if (lastAccessTime != -1L) - throw new IllegalArgumentException(); - accTime = now; - } else { - accTime = TimeUnit.MILLISECONDS.convert(lastAccessTime, unit); - } - accTime = WindowsFileAttributes.toWindowsTime(accTime); - } - if (createTime != null) { - if (createTime < 0L) { - if (createTime != -1L) - throw new IllegalArgumentException(); - crTime = now; - } else { - crTime = TimeUnit.MILLISECONDS.convert(createTime, unit); - } - crTime = WindowsFileAttributes.toWindowsTime(crTime); - } + // permission check + file.checkWrite(); - setFileTimes(crTime, accTime, modTime); + // update times + long t1 = (createTime == null) ? -1L : + WindowsFileAttributes.toWindowsTime(createTime); + long t2 = (lastAccessTime == null) ? -1L : + WindowsFileAttributes.toWindowsTime(lastAccessTime); + long t3 = (lastModifiedTime == null) ? -1L : + WindowsFileAttributes.toWindowsTime(lastModifiedTime); + setFileTimes(t1, t2, t3); } } @@ -197,10 +205,10 @@ class WindowsFileAttributeViews { } @Override - public Map<String,?> readAttributes(String first, String[] rest) + public Map<String,?> readAttributes(String[] attributes) throws IOException { - AttributesBuilder builder = AttributesBuilder.create(first, rest); + AttributesBuilder builder = AttributesBuilder.create(attributes); WindowsFileAttributes attrs = readAttributes(); addBasicAttributesToBuilder(attrs, builder); if (builder.match(READONLY_NAME)) @@ -286,11 +294,11 @@ class WindowsFileAttributeViews { } } - static BasicFileAttributeView createBasicView(WindowsPath file, boolean followLinks) { + static Basic createBasicView(WindowsPath file, boolean followLinks) { return new Basic(file, followLinks); } - static WindowsFileAttributeViews.Dos createDosView(WindowsPath file, boolean followLinks) { + static Dos createDosView(WindowsPath file, boolean followLinks) { return new Dos(file, followLinks); } } diff --git a/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java b/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java index ce053cf90..f930eab98 100644 --- a/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java +++ b/src/windows/classes/sun/nio/fs/WindowsFileAttributes.java @@ -65,7 +65,6 @@ class WindowsFileAttributes private static final short OFFSETOF_FILE_INFORMATION_VOLSERIALNUM = 28; private static final short OFFSETOF_FILE_INFORMATION_SIZEHIGH = 32; private static final short OFFSETOF_FILE_INFORMATION_SIZELOW = 36; - private static final short OFFSETOF_FILE_INFORMATION_NUMLINKS = 40; private static final short OFFSETOF_FILE_INFORMATION_INDEXHIGH = 44; private static final short OFFSETOF_FILE_INFORMATION_INDEXLOW = 48; @@ -110,6 +109,9 @@ class WindowsFileAttributes private static final short OFFSETOF_FIND_DATA_SIZELOW = 32; private static final short OFFSETOF_FIND_DATA_RESERVED0 = 36; + // used to adjust values between Windows and java epoch + private static final long WINDOWS_EPOCH_IN_MICROSECONDS = -11644473600000000L; + // indicates if accurate metadata is required (interesting on NTFS only) private static final boolean ensureAccurateMetadata; static { @@ -128,29 +130,33 @@ class WindowsFileAttributes private final int reparseTag; // additional attributes when using GetFileInformationByHandle - private final int linkCount; private final int volSerialNumber; private final int fileIndexHigh; private final int fileIndexLow; /** * Convert 64-bit value representing the number of 100-nanosecond intervals - * since January 1, 1601 to java time. + * since January 1, 1601 to a FileTime. */ - private static long toJavaTime(long time) { - time /= 10000L; - time -= 11644473600000L; - return time; + static FileTime toFileTime(long time) { + // 100ns -> us + time /= 10L; + // adjust to java epoch + time += WINDOWS_EPOCH_IN_MICROSECONDS; + return FileTime.from(time, TimeUnit.MICROSECONDS); } /** - * Convert java time to 64-bit value representing the number of 100-nanosecond + * Convert FileTime to 64-bit value representing the number of 100-nanosecond * intervals since January 1, 1601. */ - static long toWindowsTime(long time) { - time += 11644473600000L; - time *= 10000L; - return time; + static long toWindowsTime(FileTime time) { + long value = time.to(TimeUnit.MICROSECONDS); + // adjust to Windows epoch+= 11644473600000000L; + value -= WINDOWS_EPOCH_IN_MICROSECONDS; + // us -> 100ns + value *= 10L; + return value; } /** @@ -162,7 +168,6 @@ class WindowsFileAttributes long lastWriteTime, long size, int reparseTag, - int linkCount, int volSerialNumber, int fileIndexHigh, int fileIndexLow) @@ -173,7 +178,6 @@ class WindowsFileAttributes this.lastWriteTime = lastWriteTime; this.size = size; this.reparseTag = reparseTag; - this.linkCount = linkCount; this.volSerialNumber = volSerialNumber; this.fileIndexHigh = fileIndexHigh; this.fileIndexLow = fileIndexLow; @@ -184,15 +188,11 @@ class WindowsFileAttributes */ private static WindowsFileAttributes fromFileInformation(long address, int reparseTag) { int fileAttrs = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_ATTRIBUTES); - long creationTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_CREATETIME)); - long lastAccessTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTACCESSTIME)); - long lastWriteTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTWRITETIME)); + long creationTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_CREATETIME); + long lastAccessTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTACCESSTIME); + long lastWriteTime = unsafe.getLong(address + OFFSETOF_FILE_INFORMATION_LASTWRITETIME); long size = ((long)(unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_SIZEHIGH)) << 32) + (unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_SIZELOW) & 0xFFFFFFFFL); - int linkCount = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_NUMLINKS); int volSerialNumber = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_VOLSERIALNUM); int fileIndexHigh = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_INDEXHIGH); int fileIndexLow = unsafe.getInt(address + OFFSETOF_FILE_INFORMATION_INDEXLOW); @@ -202,7 +202,6 @@ class WindowsFileAttributes lastWriteTime, size, reparseTag, - linkCount, volSerialNumber, fileIndexHigh, fileIndexLow); @@ -213,12 +212,9 @@ class WindowsFileAttributes */ private static WindowsFileAttributes fromFileAttributeData(long address, int reparseTag) { int fileAttrs = unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_ATTRIBUTES); - long creationTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_CREATETIME)); - long lastAccessTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTACCESSTIME)); - long lastWriteTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTWRITETIME)); + long creationTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_CREATETIME); + long lastAccessTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTACCESSTIME); + long lastWriteTime = unsafe.getLong(address + OFFSETOF_FILE_ATTRIBUTE_DATA_LASTWRITETIME); long size = ((long)(unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_SIZEHIGH)) << 32) + (unsafe.getInt(address + OFFSETOF_FILE_ATTRIBUTE_DATA_SIZELOW) & 0xFFFFFFFFL); return new WindowsFileAttributes(fileAttrs, @@ -227,7 +223,6 @@ class WindowsFileAttributes lastWriteTime, size, reparseTag, - 1, // linkCount 0, // volSerialNumber 0, // fileIndexHigh 0); // fileIndexLow @@ -246,12 +241,9 @@ class WindowsFileAttributes */ static WindowsFileAttributes fromFindData(long address) { int fileAttrs = unsafe.getInt(address + OFFSETOF_FIND_DATA_ATTRIBUTES); - long creationTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FIND_DATA_CREATETIME)); - long lastAccessTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTACCESSTIME)); - long lastWriteTime = - toJavaTime(unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTWRITETIME)); + long creationTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_CREATETIME); + long lastAccessTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTACCESSTIME); + long lastWriteTime = unsafe.getLong(address + OFFSETOF_FIND_DATA_LASTWRITETIME); long size = ((long)(unsafe.getInt(address + OFFSETOF_FIND_DATA_SIZEHIGH)) << 32) + (unsafe.getInt(address + OFFSETOF_FIND_DATA_SIZELOW) & 0xFFFFFFFFL); int reparseTag = ((fileAttrs & FILE_ATTRIBUTE_REPARSE_POINT) != 0) ? @@ -262,7 +254,6 @@ class WindowsFileAttributes lastWriteTime, size, reparseTag, - 1, // linkCount 0, // volSerialNumber 0, // fileIndexHigh 0); // fileIndexLow @@ -375,28 +366,18 @@ class WindowsFileAttributes } @Override - public long lastModifiedTime() { - return (lastWriteTime >= 0L) ? lastWriteTime : 0L; - } - - @Override - public long lastAccessTime() { - return (lastAccessTime >= 0L) ? lastAccessTime : 0L; - } - - @Override - public long creationTime() { - return (creationTime >= 0L) ? creationTime : 0L; + public FileTime lastModifiedTime() { + return toFileTime(lastWriteTime); } @Override - public TimeUnit resolution() { - return TimeUnit.MILLISECONDS; + public FileTime lastAccessTime() { + return toFileTime(lastAccessTime); } @Override - public int linkCount() { - return linkCount; + public FileTime creationTime() { + return toFileTime(creationTime); } @Override diff --git a/src/windows/classes/sun/nio/fs/WindowsFileStore.java b/src/windows/classes/sun/nio/fs/WindowsFileStore.java index 5d3a0af25..a906b54e0 100644 --- a/src/windows/classes/sun/nio/fs/WindowsFileStore.java +++ b/src/windows/classes/sun/nio/fs/WindowsFileStore.java @@ -27,7 +27,6 @@ package sun.nio.fs; import java.nio.file.*; import java.nio.file.attribute.*; -import java.util.*; import java.io.IOException; import static sun.nio.fs.WindowsConstants.*; @@ -120,23 +119,40 @@ class WindowsFileStore @Override @SuppressWarnings("unchecked") - public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> view) { - if (view == FileStoreSpaceAttributeView.class) + public <V extends FileStoreAttributeView> V getFileStoreAttributeView(Class<V> type) { + if (type == null) + throw new NullPointerException(); + if (type == FileStoreSpaceAttributeView.class) return (V) new WindowsFileStoreAttributeView(this); return (V) null; } @Override - public FileStoreAttributeView getFileStoreAttributeView(String name) { - if (name.equals("space")) - return new WindowsFileStoreAttributeView(this); - if (name.equals("volume")) - return new VolumeFileStoreAttributeView(this); - return null; + public Object getAttribute(String attribute) throws IOException { + // standard + if (attribute.equals("space:totalSpace")) + return new WindowsFileStoreAttributeView(this) + .readAttributes().totalSpace(); + if (attribute.equals("space:usableSpace")) + return new WindowsFileStoreAttributeView(this) + .readAttributes().usableSpace(); + if (attribute.equals("space:unallocatedSpace")) + return new WindowsFileStoreAttributeView(this) + .readAttributes().unallocatedSpace(); + // windows specific for testing purposes + if (attribute.equals("volume:vsn")) + return volInfo.volumeSerialNumber(); + if (attribute.equals("volume:isRemovable")) + return volType == DRIVE_REMOVABLE; + if (attribute.equals("volume:isCdrom")) + return volType == DRIVE_CDROM; + throw new UnsupportedOperationException("'" + attribute + "' not recognized"); } @Override public boolean supportsFileAttributeView(Class<? extends FileAttributeView> type) { + if (type == null) + throw new NullPointerException(); if (type == BasicFileAttributeView.class) return true; if (type == AclFileAttributeView.class || type == FileOwnerAttributeView.class) @@ -154,7 +170,7 @@ class WindowsFileStore return supportsFileAttributeView(AclFileAttributeView.class); if (name.equals("owner")) return supportsFileAttributeView(FileOwnerAttributeView.class); - if (name.equals("xattr")) + if (name.equals("user")) return supportsFileAttributeView(UserDefinedFileAttributeView.class); return false; } @@ -188,7 +204,7 @@ class WindowsFileStore } static class WindowsFileStoreAttributeView - extends AbstractFileStoreSpaceAttributeView + implements FileStoreSpaceAttributeView { private final WindowsFileStore fs; @@ -197,6 +213,11 @@ class WindowsFileStore } @Override + public String name() { + return "space"; + } + + @Override public FileStoreSpaceAttributes readAttributes() throws IOException { @@ -225,113 +246,4 @@ class WindowsFileStore }; } } - - /** - * Windows-specific attribute view to allow access to volume information. - */ - static class VolumeFileStoreAttributeView - implements FileStoreAttributeView - { - private static final String VSN_NAME = "vsn"; - private static final String COMPRESSED_NAME = "compressed"; - private static final String REMOVABLE_NAME = "removable"; - private static final String CDROM_NAME = "cdrom"; - - private final WindowsFileStore fs; - - VolumeFileStoreAttributeView(WindowsFileStore fs) { - this.fs = fs; - } - - @Override - public String name() { - return "volume"; - } - - private int vsn() { - return fs.volumeInformation().volumeSerialNumber(); - } - - private boolean isCompressed() { - return (fs.volumeInformation().flags() & - FILE_VOLUME_IS_COMPRESSED) > 0; - } - - private boolean isRemovable() { - return fs.volumeType() == DRIVE_REMOVABLE; - } - - private boolean isCdrom() { - return fs.volumeType() == DRIVE_CDROM; - } - - @Override - public Object getAttribute(String attribute) throws IOException { - if (attribute.equals(VSN_NAME)) - return vsn(); - if (attribute.equals(COMPRESSED_NAME)) - return isCompressed(); - if (attribute.equals(REMOVABLE_NAME)) - return isRemovable(); - if (attribute.equals(CDROM_NAME)) - return isCdrom(); - return null; - } - - @Override - public void setAttribute(String attribute, Object value) - throws IOException - { - throw new UnsupportedOperationException(); - } - - @Override - public Map<String,?> readAttributes(String first, String... rest) - throws IOException - { - boolean all = false; - boolean vsn = false; - boolean compressed = false; - boolean removable = false; - boolean cdrom = false; - - if (first.equals(VSN_NAME)) vsn = true; - else if (first.equals(COMPRESSED_NAME)) compressed = true; - else if (first.equals(REMOVABLE_NAME)) removable = true; - else if (first.equals(CDROM_NAME)) cdrom = true; - else if (first.equals("*")) all = true; - - if (!all) { - for (String attribute: rest) { - if (attribute.equals("*")) { - all = true; - break; - } - if (attribute.equals(VSN_NAME)) { - vsn = true; - continue; - } - if (attribute.equals(COMPRESSED_NAME)) { - compressed = true; - continue; - } - if (attribute.equals(REMOVABLE_NAME)) { - removable = true; - continue; - } - } - } - - Map<String,Object> result = new HashMap<String,Object>(); - if (all || vsn) - result.put(VSN_NAME, vsn()); - if (all || compressed) - result.put(COMPRESSED_NAME, isCompressed()); - if (all || removable) - result.put(REMOVABLE_NAME, isRemovable()); - if (all || cdrom) - result.put(CDROM_NAME, isCdrom()); - return result; - } - } -} + } diff --git a/src/windows/classes/sun/nio/fs/WindowsFileSystem.java b/src/windows/classes/sun/nio/fs/WindowsFileSystem.java index e80c829f3..54712098b 100644 --- a/src/windows/classes/sun/nio/fs/WindowsFileSystem.java +++ b/src/windows/classes/sun/nio/fs/WindowsFileSystem.java @@ -63,7 +63,7 @@ class WindowsFileSystem PrivilegedAction<String> pa = new GetPropertyAction("os.version"); String osversion = AccessController.doPrivileged(pa); - String[] vers = osversion.split("\\.", 0); + String[] vers = Util.split(osversion, '.'); int major = Integer.parseInt(vers[0]); int minor = Integer.parseInt(vers[1]); @@ -227,7 +227,7 @@ class WindowsFileSystem // supported views private static final Set<String> supportedFileAttributeViews = Collections - .unmodifiableSet(new HashSet<String>(Arrays.asList("basic", "dos", "acl", "owner", "xattr"))); + .unmodifiableSet(new HashSet<String>(Arrays.asList("basic", "dos", "acl", "owner", "user"))); @Override public Set<String> supportedFileAttributeViews() { diff --git a/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java b/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java index 516275dfe..9ad848189 100644 --- a/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java +++ b/src/windows/classes/sun/nio/fs/WindowsLinkSupport.java @@ -76,7 +76,7 @@ class WindowsLinkSupport { if (!followLinks || !fs.supportsLinks()) return input.getPathForWin32Calls(); - // if file is a sym link then don't need final path + // if file is not a sym link then don't need final path if (!WindowsFileAttributes.get(input, false).isSymbolicLink()) { return input.getPathForWin32Calls(); } diff --git a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java index fafee20a4..a116bf811 100644 --- a/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java +++ b/src/windows/classes/sun/nio/fs/WindowsNativeDispatcher.java @@ -379,8 +379,11 @@ class WindowsNativeDispatcher { * CONST FILETIME *lpLastWriteTime * ) */ - static native void SetFileTime(long handle, long createTime, - long lastAccessTime, long lastWriteTime) throws WindowsException; + static native void SetFileTime(long handle, + long createTime, + long lastAccessTime, + long lastWriteTime) + throws WindowsException; /** * SetEndOfFile( diff --git a/src/windows/classes/sun/nio/fs/WindowsPath.java b/src/windows/classes/sun/nio/fs/WindowsPath.java index 2fda59d2b..029431faa 100644 --- a/src/windows/classes/sun/nio/fs/WindowsPath.java +++ b/src/windows/classes/sun/nio/fs/WindowsPath.java @@ -27,7 +27,6 @@ package sun.nio.fs; import java.nio.file.*; import java.nio.file.attribute.*; -import java.nio.file.spi.AbstractPath; import java.nio.channels.*; import java.io.*; import java.net.URI; @@ -166,6 +165,8 @@ class WindowsPath extends AbstractPath { public void invalidate() { ref.clear(); } + + // no need to override equals/hashCode. } // use this message when throwing exceptions @@ -948,7 +949,7 @@ class WindowsPath extends AbstractPath { } @Override - public void delete(boolean failIfNotExists) throws IOException { + void implDelete(boolean failIfNotExists) throws IOException { checkDelete(); WindowsFileAttributes attrs = null; @@ -1040,7 +1041,7 @@ class WindowsPath extends AbstractPath { } @Override - public FileAttributeView getFileAttributeView(String name, LinkOption... options) { + public DynamicFileAttributeView getFileAttributeView(String name, LinkOption... options) { boolean followLinks = followLinks(options); if (name.equals("basic")) return WindowsFileAttributeViews.createBasicView(this, followLinks); @@ -1051,7 +1052,7 @@ class WindowsPath extends AbstractPath { if (name.equals("owner")) return new FileOwnerAttributeViewImpl( new WindowsAclFileAttributeView(this, followLinks)); - if (name.equals("xattr")) + if (name.equals("user")) return new WindowsUserDefinedFileAttributeView(this, followLinks); return null; } @@ -1073,22 +1074,6 @@ class WindowsPath extends AbstractPath { } @Override - public InputStream newInputStream()throws IOException { - try { - Set<OpenOption> options = Collections.emptySet(); - FileChannel fc = WindowsChannelFactory - .newFileChannel(getPathForWin32Calls(), - getPathForPermissionCheck(), - options, - 0L); - return Channels.newInputStream(fc); - } catch (WindowsException x) { - x.rethrowAsIOException(this); - return null; // keep compiler happy - } - } - - @Override public SeekableByteChannel newByteChannel(Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException @@ -1110,36 +1095,7 @@ class WindowsPath extends AbstractPath { } @Override - public OutputStream newOutputStream(Set<? extends OpenOption> options, - FileAttribute<?>... attrs) - throws IOException - { - // need to copy options to add WRITE - Set<OpenOption> opts = new HashSet<OpenOption>(options); - if (opts.contains(StandardOpenOption.READ)) - throw new IllegalArgumentException("READ not allowed"); - opts.add(StandardOpenOption.WRITE); - - WindowsSecurityDescriptor sd = - WindowsSecurityDescriptor.fromAttribute(attrs); - FileChannel fc; - try { - fc = WindowsChannelFactory - .newFileChannel(getPathForWin32Calls(), - getPathForPermissionCheck(), - opts, - sd.address()); - return Channels.newOutputStream(fc); - } catch (WindowsException x) { - x.rethrowAsIOException(this); - return null; // keep compiler happy - } finally { - sd.release(); - } - } - - @Override - public boolean isSameFile(FileRef obj) throws IOException { + public boolean isSameFile(Path obj) throws IOException { if (this.equals(obj)) return true; if (!(obj instanceof WindowsPath)) // includes null check @@ -1216,7 +1172,7 @@ class WindowsPath extends AbstractPath { * creates a link with the resolved target for this case. */ if (target.type == WindowsPathType.DRIVE_RELATIVE) { - throw new IOException("Cannot create symbolic link to drive-relative target"); + throw new IOException("Cannot create symbolic link to working directory relative target"); } /* diff --git a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c index 45a364627..d5195c4f7 100644 --- a/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c +++ b/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c @@ -560,9 +560,9 @@ Java_sun_nio_fs_WindowsNativeDispatcher_SetFileTime(JNIEnv* env, jclass this, HANDLE h = (HANDLE)jlong_to_ptr(handle); if (SetFileTime(h, - (createTime == (jlong)0) ? NULL : (CONST FILETIME *)&createTime, - (lastAccessTime == (jlong)0) ? NULL : (CONST FILETIME *)&lastAccessTime, - (lastWriteTime == (jlong)0) ? NULL : (CONST FILETIME *)&lastWriteTime) == 0) + (createTime == (jlong)-1) ? NULL : (CONST FILETIME *)&createTime, + (lastAccessTime == (jlong)-1) ? NULL : (CONST FILETIME *)&lastAccessTime, + (lastWriteTime == (jlong)-1) ? NULL : (CONST FILETIME *)&lastWriteTime) == 0) { throwWindowsException(env, GetLastError()); } |