Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/java/nio/file/attribute/DosFileAttributeView.java
38918 views
/*1* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package java.nio.file.attribute;2627import java.io.IOException;2829/**30* A file attribute view that provides a view of the legacy "DOS" file attributes.31* These attributes are supported by file systems such as the File Allocation32* Table (FAT) format commonly used in <em>consumer devices</em>.33*34* <p> A {@code DosFileAttributeView} is a {@link BasicFileAttributeView} that35* additionally supports access to the set of DOS attribute flags that are used36* to indicate if the file is read-only, hidden, a system file, or archived.37*38* <p> Where dynamic access to file attributes is required, the attributes39* supported by this attribute view are as defined by {@code40* BasicFileAttributeView}, and in addition, the following attributes are41* supported:42* <blockquote>43* <table border="1" cellpadding="8" summary="Supported attributes">44* <tr>45* <th> Name </th>46* <th> Type </th>47* </tr>48* <tr>49* <td> readonly </td>50* <td> {@link Boolean} </td>51* </tr>52* <tr>53* <td> hidden </td>54* <td> {@link Boolean} </td>55* </tr>56* <tr>57* <td> system </td>58* <td> {@link Boolean} </td>59* </tr>60* <tr>61* <td> archive </td>62* <td> {@link Boolean} </td>63* </tr>64* </table>65* </blockquote>66*67* <p> The {@link java.nio.file.Files#getAttribute getAttribute} method may68* be used to read any of these attributes, or any of the attributes defined by69* {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes70* readAttributes()} method.71*72* <p> The {@link java.nio.file.Files#setAttribute setAttribute} method may73* be used to update the file's last modified time, last access time or create74* time attributes as defined by {@link BasicFileAttributeView}. It may also be75* used to update the DOS attributes as if by invoking the {@link #setReadOnly76* setReadOnly}, {@link #setHidden setHidden}, {@link #setSystem setSystem}, and77* {@link #setArchive setArchive} methods respectively.78*79* @since 1.780*/8182public interface DosFileAttributeView83extends BasicFileAttributeView84{85/**86* Returns the name of the attribute view. Attribute views of this type87* have the name {@code "dos"}.88*/89@Override90String name();9192/**93* @throws IOException {@inheritDoc}94* @throws SecurityException {@inheritDoc}95*/96@Override97DosFileAttributes readAttributes() throws IOException;9899/**100* Updates the value of the read-only attribute.101*102* <p> It is implementation specific if the attribute can be updated as an103* atomic operation with respect to other file system operations. An104* implementation may, for example, require to read the existing value of105* the DOS attribute in order to update this attribute.106*107* @param value108* the new value of the attribute109*110* @throws IOException111* if an I/O error occurs112* @throws SecurityException113* In the case of the default, and a security manager is installed,114* its {@link SecurityManager#checkWrite(String) checkWrite} method115* is invoked to check write access to the file116*/117void setReadOnly(boolean value) throws IOException;118119/**120* Updates the value of the hidden attribute.121*122* <p> It is implementation specific if the attribute can be updated as an123* atomic operation with respect to other file system operations. An124* implementation may, for example, require to read the existing value of125* the DOS attribute in order to update this attribute.126*127* @param value128* the new value of the attribute129*130* @throws IOException131* if an I/O error occurs132* @throws SecurityException133* In the case of the default, and a security manager is installed,134* its {@link SecurityManager#checkWrite(String) checkWrite} method135* is invoked to check write access to the file136*/137void setHidden(boolean value) throws IOException;138139/**140* Updates the value of the system attribute.141*142* <p> It is implementation specific if the attribute can be updated as an143* atomic operation with respect to other file system operations. An144* implementation may, for example, require to read the existing value of145* the DOS attribute in order to update this attribute.146*147* @param value148* the new value of the attribute149*150* @throws IOException151* if an I/O error occurs152* @throws SecurityException153* In the case of the default, and a security manager is installed,154* its {@link SecurityManager#checkWrite(String) checkWrite} method155* is invoked to check write access to the file156*/157void setSystem(boolean value) throws IOException;158159/**160* Updates the value of the archive attribute.161*162* <p> It is implementation specific if the attribute can be updated as an163* atomic operation with respect to other file system operations. An164* implementation may, for example, require to read the existing value of165* the DOS attribute in order to update this attribute.166*167* @param value168* the new value of the attribute169*170* @throws IOException171* if an I/O error occurs172* @throws SecurityException173* In the case of the default, and a security manager is installed,174* its {@link SecurityManager#checkWrite(String) checkWrite} method175* is invoked to check write access to the file176*/177void setArchive(boolean value) throws IOException;178}179180181