Path: blob/master/src/java.base/share/classes/java/nio/file/attribute/DosFileAttributeView.java
41161 views
/*1* Copyright (c) 2007, 2017, 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 class="striped">44* <caption style="display:none">Supported attributes</caption>45* <thead>46* <tr>47* <th scope="col"> Name </th>48* <th scope="col"> Type </th>49* </tr>50* </thead>51* <tbody>52* <tr>53* <th scope="row"> readonly </th>54* <td> {@link Boolean} </td>55* </tr>56* <tr>57* <th scope="row"> hidden </th>58* <td> {@link Boolean} </td>59* </tr>60* <tr>61* <th scope="row"> system </th>62* <td> {@link Boolean} </td>63* </tr>64* <tr>65* <th scope="row"> archive </th>66* <td> {@link Boolean} </td>67* </tr>68* </tbody>69* </table>70* </blockquote>71*72* <p> The {@link java.nio.file.Files#getAttribute getAttribute} method may73* be used to read any of these attributes, or any of the attributes defined by74* {@link BasicFileAttributeView} as if by invoking the {@link #readAttributes75* readAttributes()} method.76*77* <p> The {@link java.nio.file.Files#setAttribute setAttribute} method may78* be used to update the file's last modified time, last access time or create79* time attributes as defined by {@link BasicFileAttributeView}. It may also be80* used to update the DOS attributes as if by invoking the {@link #setReadOnly81* setReadOnly}, {@link #setHidden setHidden}, {@link #setSystem setSystem}, and82* {@link #setArchive setArchive} methods respectively.83*84* @since 1.785*/8687public interface DosFileAttributeView88extends BasicFileAttributeView89{90/**91* Returns the name of the attribute view. Attribute views of this type92* have the name {@code "dos"}.93*/94@Override95String name();9697/**98* @throws IOException {@inheritDoc}99* @throws SecurityException {@inheritDoc}100*/101@Override102DosFileAttributes readAttributes() throws IOException;103104/**105* Updates the value of the read-only attribute.106*107* <p> It is implementation specific if the attribute can be updated as an108* atomic operation with respect to other file system operations. An109* implementation may, for example, require to read the existing value of110* the DOS attribute in order to update this attribute.111*112* @param value113* the new value of the attribute114*115* @throws IOException116* if an I/O error occurs117* @throws SecurityException118* In the case of the default, and a security manager is installed,119* its {@link SecurityManager#checkWrite(String) checkWrite} method120* is invoked to check write access to the file121*/122void setReadOnly(boolean value) throws IOException;123124/**125* Updates the value of the hidden attribute.126*127* <p> It is implementation specific if the attribute can be updated as an128* atomic operation with respect to other file system operations. An129* implementation may, for example, require to read the existing value of130* the DOS attribute in order to update this attribute.131*132* @param value133* the new value of the attribute134*135* @throws IOException136* if an I/O error occurs137* @throws SecurityException138* In the case of the default, and a security manager is installed,139* its {@link SecurityManager#checkWrite(String) checkWrite} method140* is invoked to check write access to the file141*/142void setHidden(boolean value) throws IOException;143144/**145* Updates the value of the system attribute.146*147* <p> It is implementation specific if the attribute can be updated as an148* atomic operation with respect to other file system operations. An149* implementation may, for example, require to read the existing value of150* the DOS attribute in order to update this attribute.151*152* @param value153* the new value of the attribute154*155* @throws IOException156* if an I/O error occurs157* @throws SecurityException158* In the case of the default, and a security manager is installed,159* its {@link SecurityManager#checkWrite(String) checkWrite} method160* is invoked to check write access to the file161*/162void setSystem(boolean value) throws IOException;163164/**165* Updates the value of the archive attribute.166*167* <p> It is implementation specific if the attribute can be updated as an168* atomic operation with respect to other file system operations. An169* implementation may, for example, require to read the existing value of170* the DOS attribute in order to update this attribute.171*172* @param value173* the new value of the attribute174*175* @throws IOException176* if an I/O error occurs177* @throws SecurityException178* In the case of the default, and a security manager is installed,179* its {@link SecurityManager#checkWrite(String) checkWrite} method180* is invoked to check write access to the file181*/182void setArchive(boolean value) throws IOException;183}184185186