1 /* 2 * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. 3 * Copyright 2013 SAP AG. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 27 /* 28 * Portions Copyright (c) 2014 IBM Corporation 29 */ 30 31 package sun.nio.fs; 32 33 import java.io.IOException; 34 import java.nio.file.LinkOption; 35 import java.nio.file.Path; 36 import java.nio.file.attribute.BasicFileAttributes; 37 import java.nio.file.attribute.DosFileAttributeView; 38 import java.nio.file.attribute.DosFileAttributes; 39 import java.nio.file.attribute.FileAttributeView; 40 import java.nio.file.attribute.UserDefinedFileAttributeView; 41 42 /** 43 * AIX implementation of FileSystemProvider 44 */ 45 46 public class AixFileSystemProvider extends UnixFileSystemProvider { 47 public AixFileSystemProvider() { 48 super(); 49 } 50 51 @Override 52 AixFileSystem newFileSystem(String dir) { 53 return new AixFileSystem(this, dir); 54 } 55 56 /** 57 * @see sun.nio.fs.UnixFileSystemProvider#getFileStore(sun.nio.fs.UnixPath) 58 */ 59 @Override 60 AixFileStore getFileStore(UnixPath path) throws IOException { 61 return new AixFileStore(path); 62 } 63 64 @Override 65 @SuppressWarnings("unchecked") 66 public <V extends FileAttributeView> V getFileAttributeView(Path obj, 67 Class<V> type, 68 LinkOption... options) 69 { 70 if (type == DosFileAttributeView.class) { 71 return (V) new AixDosFileAttributeView(UnixPath.toUnixPath(obj), 72 Util.followLinks(options)); 73 } 74 if (type == UserDefinedFileAttributeView.class) { 75 return (V) new AixUserDefinedFileAttributeView(UnixPath.toUnixPath(obj), 76 Util.followLinks(options)); 77 } 78 return super.getFileAttributeView(obj, type, options); 79 } 80 81 @Override 82 public DynamicFileAttributeView getFileAttributeView(Path obj, 83 String name, 84 LinkOption... options) 85 { 86 if (name.equals("dos")) { 87 return new AixDosFileAttributeView(UnixPath.toUnixPath(obj), 88 Util.followLinks(options)); 89 } 90 if (name.equals("user")) { 91 return new AixUserDefinedFileAttributeView(UnixPath.toUnixPath(obj), 92 Util.followLinks(options)); 93 } 94 return super.getFileAttributeView(obj, name, options); 95 } 96 97 @Override 98 @SuppressWarnings("unchecked") 99 public <A extends BasicFileAttributes> A readAttributes(Path file, 100 Class<A> type, 101 LinkOption... options) 102 throws IOException 103 { 104 if (type == DosFileAttributes.class) { 105 DosFileAttributeView view = 106 getFileAttributeView(file, DosFileAttributeView.class, options); 107 return (A) view.readAttributes(); 108 } else { 109 return super.readAttributes(file, type, options); 110 } 111 } 112 }