summaryrefslogtreecommitdiff
path: root/src/main/java/de/waldheinz/fs/FileSystem.java
blob: f84baaec0bae54336acb3bb8097f2cf772649c9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
 * Copyright (C) 2003-2009 JNode.org
 *               2009,2010 Matthias Treydte <mt@waldheinz.de>
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; If not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
package de.waldheinz.fs;

import java.io.IOException;

/**
 * The interface common to all file system implementations.
 *
 * @author Ewout Prangsma &lt;epr at jnode.org&gt;
 * @author Matthias Treydte &lt;waldheinz at gmail.com&gt;
 */
public interface FileSystem {
    
    /**
     * Gets the root entry of this filesystem. This is usually a directory, but
     * this is not required.
     * 
     * @return the file system's root entry
     * @throws IOException on read error
     */
    public FsDirectory getRoot() throws IOException;

    /**
     * Returns if this {@code FileSystem} is in read-only mode.
     *
     * @return if this {@code FileSystem} is read-only
     */
    public boolean isReadOnly();

    /**
     * Close this file system. After a close, all invocations of methods of
     * this file system or objects created by this file system will throw an
     * {@link IllegalStateException}.
     * 
     * @throws IOException on error closing the file system
     */
    public void close() throws IOException;
    
    /**
     * Returns {@code true} if this file system is closed. If the file system
     * is closed, no more operations may be performed on it.
     * 
     * @return if this file system is closed
     */
    public boolean isClosed();

    /**
     * The total size of this file system.
     *
     * @return if -1 this feature is unsupported
     * @throws IOException if an I/O error occurs
     */
    public long getTotalSpace() throws IOException;

    /**
     * The free space of this file system.
     *
     * @return if -1 this feature is unsupported
     * @throws IOException if an I/O error occurs
     */
    public long getFreeSpace() throws IOException;

    /**
     * The usable space of this file system.
     *
     * @return if -1 this feature is unsupported
     * @throws IOException if an I/O error occurs
     */
    public long getUsableSpace() throws IOException;

    /**
     * Flushes any modified file system structures to the underlying storage.
     *
     * @throws IOException
     */
    public void flush() throws IOException;
}