1 /*
2  * Copyright (C) 2003-2009 JNode.org
3  *               2009,2010 Matthias Treydte <mt@waldheinz.de>
4  *
5  * This library is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU Lesser General Public License as published
7  * by the Free Software Foundation; either version 2.1 of the License, or
8  * (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13  * License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this library; If not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package de.waldheinz.fs;
21 
22 import java.io.IOException;
23 
24 /**
25  * The interface common to all file system implementations.
26  *
27  * @author Ewout Prangsma &lt;epr at jnode.org&gt;
28  * @author Matthias Treydte &lt;waldheinz at gmail.com&gt;
29  */
30 public interface FileSystem {
31 
32     /**
33      * Gets the root entry of this filesystem. This is usually a directory, but
34      * this is not required.
35      *
36      * @return the file system's root entry
37      * @throws IOException on read error
38      */
getRoot()39     public FsDirectory getRoot() throws IOException;
40 
41     /**
42      * Returns if this {@code FileSystem} is in read-only mode.
43      *
44      * @return if this {@code FileSystem} is read-only
45      */
isReadOnly()46     public boolean isReadOnly();
47 
48     /**
49      * Close this file system. After a close, all invocations of methods of
50      * this file system or objects created by this file system will throw an
51      * {@link IllegalStateException}.
52      *
53      * @throws IOException on error closing the file system
54      */
close()55     public void close() throws IOException;
56 
57     /**
58      * Returns {@code true} if this file system is closed. If the file system
59      * is closed, no more operations may be performed on it.
60      *
61      * @return if this file system is closed
62      */
isClosed()63     public boolean isClosed();
64 
65     /**
66      * The total size of this file system.
67      *
68      * @return if -1 this feature is unsupported
69      * @throws IOException if an I/O error occurs
70      */
getTotalSpace()71     public long getTotalSpace() throws IOException;
72 
73     /**
74      * The free space of this file system.
75      *
76      * @return if -1 this feature is unsupported
77      * @throws IOException if an I/O error occurs
78      */
getFreeSpace()79     public long getFreeSpace() throws IOException;
80 
81     /**
82      * The usable space of this file system.
83      *
84      * @return if -1 this feature is unsupported
85      * @throws IOException if an I/O error occurs
86      */
getUsableSpace()87     public long getUsableSpace() throws IOException;
88 
89     /**
90      * Flushes any modified file system structures to the underlying storage.
91      *
92      * @throws IOException
93      */
flush()94     public void flush() throws IOException;
95 }
96