src/java.base/aix/classes/sun/nio/fs/AixFileSystemProvider.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright 2013 SAP AG. 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
@@ -22,13 +22,24 @@
* 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.
*/
+/*
+ * Portions Copyright (c) 2014 IBM Corporation
+ */
+
package sun.nio.fs;
import java.io.IOException;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.nio.file.attribute.DosFileAttributeView;
+import java.nio.file.attribute.DosFileAttributes;
+import java.nio.file.attribute.FileAttributeView;
+import java.nio.file.attribute.UserDefinedFileAttributeView;
/**
* AIX implementation of FileSystemProvider
*/
@@ -47,6 +58,55 @@
*/
@Override
AixFileStore getFileStore(UnixPath path) throws IOException {
return new AixFileStore(path);
}
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <V extends FileAttributeView> V getFileAttributeView(Path obj,
+ Class<V> type,
+ LinkOption... options)
+ {
+ if (type == DosFileAttributeView.class) {
+ return (V) new AixDosFileAttributeView(UnixPath.toUnixPath(obj),
+ Util.followLinks(options));
+ }
+ if (type == UserDefinedFileAttributeView.class) {
+ return (V) new AixUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
+ Util.followLinks(options));
+ }
+ return super.getFileAttributeView(obj, type, options);
+ }
+
+ @Override
+ public DynamicFileAttributeView getFileAttributeView(Path obj,
+ String name,
+ LinkOption... options)
+ {
+ if (name.equals("dos")) {
+ return new AixDosFileAttributeView(UnixPath.toUnixPath(obj),
+ Util.followLinks(options));
+ }
+ if (name.equals("user")) {
+ return new AixUserDefinedFileAttributeView(UnixPath.toUnixPath(obj),
+ Util.followLinks(options));
+ }
+ return super.getFileAttributeView(obj, name, options);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <A extends BasicFileAttributes> A readAttributes(Path file,
+ Class<A> type,
+ LinkOption... options)
+ throws IOException
+ {
+ if (type == DosFileAttributes.class) {
+ DosFileAttributeView view =
+ getFileAttributeView(file, DosFileAttributeView.class, options);
+ return (A) view.readAttributes();
+ } else {
+ return super.readAttributes(file, type, options);
+ }
+ }
}