FileStore.java revision 1319
893N/A * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved. 893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 893N/A * This code is free software; you can redistribute it and/or modify it 893N/A * under the terms of the GNU General Public License version 2 only, as 893N/A * published by the Free Software Foundation. Sun designates this 893N/A * particular file as subject to the "Classpath" exception as provided 893N/A * by Sun in the LICENSE file that accompanied this code. 893N/A * This code is distributed in the hope that it will be useful, but WITHOUT 893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 893N/A * version 2 for more details (a copy is included in the LICENSE file that 893N/A * accompanied this code). 893N/A * You should have received a copy of the GNU General Public License version 893N/A * 2 along with this work; if not, write to the Free Software Foundation, 893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 893N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 893N/A * CA 95054 USA or visit www.sun.com if you need additional information or 893N/A * Storage for files. A {@code FileStore} represents a storage pool, device, 893N/A * partition, volume, concrete file system or other implementation specific means 893N/A * of file storage. The {@code FileStore} for where a file is stored is obtained 1319N/A * by invoking the {@link Path#getFileStore getFileStore} method, or all file 893N/A * stores can be enumerated by invoking the {@link FileSystem#getFileStores 893N/A * getFileStores} method. 893N/A * <p> In addition to the methods defined by this class, a file store may support 893N/A * one or more {@link FileStoreAttributeView FileStoreAttributeView} classes 893N/A * that provide a read-only or updatable view of a set of file store attributes. 893N/A * File stores associated with the default provider support the {@link 893N/A * FileStoreSpaceAttributeView} to read the space related attributes of the 893N/A * Initializes a new instance of this class. 893N/A * Returns the name of this file store. The format of the name is highly 893N/A * implementation specific. It will typically be the name of the storage 893N/A * <p> The string returned by this method may differ from the string 893N/A * returned by the {@link Object#toString() toString} method. 908N/A * @return the name of this file store 893N/A * Returns the <em>type</em> of this file store. The format of the string 893N/A * returned by this method is highly implementation specific. It may 893N/A * indicate, for example, the format used or if the file store is local 908N/A * @return a string representing the type of this file store 893N/A * Tells whether this file store is read-only. A file store is read-only if 893N/A * it does not support write operations or other changes to files. Any 893N/A * attempt to create a file, open an existing file for writing etc. causes 893N/A * an {@code IOException} to be thrown. 893N/A * @return {@code true} if, and only if, this file store is read-only 893N/A * Tells whether or not this file store supports the file attributes 893N/A * identified by the given file attribute view. 893N/A * <p> Invoking this method to test if the file store supports {@link 893N/A * BasicFileAttributeView} will always return {@code true}. In the case of 893N/A * the default provider, this method cannot guarantee to give the correct 893N/A * result when the file store is not a local storage device. The reasons for 893N/A * this are implementation specific and therefore unspecified. 908N/A * the file attribute view type 893N/A * @return {@code true} if, and only if, the file attribute view is 893N/A * Tells whether or not this file store supports the file attributes 893N/A * identified by the given file attribute view. 893N/A * <p> Invoking this method to test if the file store supports {@link 893N/A * BasicFileAttributeView}, identified by the name "{@code basic}" will 893N/A * always return {@code true}. In the case of the default provider, this 893N/A * method cannot guarantee to give the correct result when the file store is 893N/A * not a local storage device. The reasons for this are implementation 893N/A * specific and therefore unspecified. 908N/A * the {@link FileAttributeView#name name} of file attribute view 893N/A * @return {@code true} if, and only if, the file attribute view is 893N/A * Returns a {@code FileStoreAttributeView} of the given type. 893N/A * <p> This method is intended to be used where the file store attribute 893N/A * view defines type-safe methods to read or update the file store attributes. 893N/A * The {@code type} parameter is the type of the attribute view required and 893N/A * the method returns an instance of that type if supported. 893N/A * <p> For {@code FileStore} objects created by the default provider, then 893N/A * the file stores support the {@link FileStoreSpaceAttributeView} that 893N/A * provides access to space attributes. In that case invoking this method 893N/A * with a parameter value of {@code FileStoreSpaceAttributeView.class} will 893N/A * always return an instance of that class. 908N/A * the {@code Class} object corresponding to the attribute view 908N/A * @return a file store attribute view of the specified type or 893N/A * {@code null} if the attribute view is not available 1319N/A * Reads the value of a file store attribute. 1319N/A * <p> The {@code attribute} parameter identifies the attribute to be read 1319N/A * <i>view-name</i><b>:</b><i>attribute-name</i> 1319N/A * where the character {@code ':'} stands for itself. 1319N/A * <p> <i>view-name</i> is the {@link FileStoreAttributeView#name name} of 1319N/A * a {@link FileStore AttributeView} that identifies a set of file attributes. 1319N/A * <i>attribute-name</i> is the name of the attribute. 893N/A * <p> For {@code FileStore} objects created by the default provider, then 893N/A * the file stores support the {@link FileStoreSpaceAttributeView} that 1319N/A * provides access to space attributes. 1319N/A * <p> <b>Usage Example:</b> 1319N/A * Suppose we want to know if ZFS compression is enabled (assuming the "zfs" 1319N/A * boolean compression = (Boolean)fs.getAttribute("zfs:compression"); 1319N/A * @return the attribute value; {@code null} may be a valid valid for some 1319N/A * @throws UnsupportedOperationException 1319N/A * if the attribute view is not available or it does not support