Debian Codegraph @

src/uk/me/parabola/imgfmt/fs/FileSystem.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2006 Steve Ratcliffe
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 *
14 * Author: Steve Ratcliffe
15 * Create date: 26-Nov-2006
16 */
17 package uk.me.parabola.imgfmt.fs;
18
19 import java.io.Closeable;
20 import java.io.FileNotFoundException;
21 import java.io.IOException;
22 import java.util.List;
23
24 import uk.me.parabola.imgfmt.FileExistsException;
25 import uk.me.parabola.imgfmt.FileSystemParam;
26
27
28 /**
29 * File system operations.
30 *
31 * @author Steve Ratcliffe
32 */
33 public interface FileSystem extends Closeable {
34
35 /**
36 * Create a new file it must not already exist.
37 * @param name The file name.
38 * @return A directory entry for the new file.
39 * @throws FileExistsException If the file already exists.
40 */
41 public ImgChannel create(String name) throws FileExistsException;
42
43 /**
44 * Open a file. The returned file object can be used to read and write the
45 * underlying file.
46 *
47 * @param name The file name to open.
48 * @param mode Either "r" for read access, "w" for write access or "rw"
49 * for both read and write.
50 * @return A file descriptor.
51 * @throws FileNotFoundException When the file does not exist.
52 */
53 public ImgChannel open(String name, String mode)
54 throws FileNotFoundException;
55
56 /**
57 * Lookup the file and return a directory entry for it.
58 *
59 * @param name The filename to look up.
60 * @return A directory entry.
61 * @throws IOException If an error occurs reading the directory.
62 */
63 public DirectoryEntry lookup(String name) throws IOException;
64
65 /**
66 * List all the files in the directory.
67 * @return A List of directory entries.
68 */
69 public List<DirectoryEntry> list() ;
70
71 /**
72 * Get the filesystem / archive parameters. Things that are stored in
73 * the header.
74 *
75 * @return The filesystem parameters.
76 */
77 public FileSystemParam fsparam();
78
79 /**
80 * Sync with the underlying file. All unwritten data is written out to
81 * the underlying file.
82 * @throws IOException If an error occurs during the write.
83 */
84 public void sync() throws IOException;
85
86 /**
87 * Close the filesystem. Any saved data is flushed out. It is better
88 * to explicitly sync the data out first, to be sure that it has worked.
89 */
90 void close();
91 }