8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.io;
27
28
29 /**
30 * Package-private abstract class for the local filesystem abstraction.
31 */
32
33 abstract class FileSystem {
34
35 /* -- Normalization and construction -- */
36
37 /**
38 * Return the local filesystem's name-separator character.
39 */
40 public abstract char getSeparator();
41
42 /**
43 * Return the local filesystem's path-separator character.
44 */
45 public abstract char getPathSeparator();
46
47 /**
81
82 /* -- Path operations -- */
83
84 /**
85 * Tell whether or not the given abstract pathname is absolute.
86 */
87 public abstract boolean isAbsolute(File f);
88
89 /**
90 * Resolve the given abstract pathname into absolute form. Invoked by the
91 * getAbsolutePath and getCanonicalPath methods in the File class.
92 */
93 public abstract String resolve(File f);
94
95 public abstract String canonicalize(String path) throws IOException;
96
97
98 /* -- Attribute accessors -- */
99
100 /* Constants for simple boolean attributes */
101 public static final int BA_EXISTS = 0x01;
102 public static final int BA_REGULAR = 0x02;
103 public static final int BA_DIRECTORY = 0x04;
104 public static final int BA_HIDDEN = 0x08;
105
106 /**
107 * Return the simple boolean attributes for the file or directory denoted
108 * by the given abstract pathname, or zero if it does not exist or some
109 * other I/O error occurs.
110 */
111 public abstract int getBooleanAttributes(File f);
112
113 public static final int ACCESS_READ = 0x04;
114 public static final int ACCESS_WRITE = 0x02;
115 public static final int ACCESS_EXECUTE = 0x01;
116
117 /**
118 * Check whether the file or directory denoted by the given abstract
119 * pathname may be accessed by this process. The second argument specifies
120 * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check.
121 * Return false if access is denied or an I/O error occurs
122 */
123 public abstract boolean checkAccess(File f, int access);
124 /**
125 * Set on or off the access permission (to owner only or to all) to the file
126 * or directory denoted by the given abstract pathname, based on the parameters
127 * enable, access and oweronly.
128 */
129 public abstract boolean setPermission(File f, int access, boolean enable, boolean owneronly);
130
131 /**
132 * Return the time at which the file or directory denoted by the given
133 * abstract pathname was last modified, or zero if it does not exist or
134 * some other I/O error occurs.
135 */
186 * operation succeeds.
187 */
188 public abstract boolean setLastModifiedTime(File f, long time);
189
190 /**
191 * Mark the file or directory denoted by the given abstract pathname as
192 * read-only, returning <code>true</code> if and only if the operation
193 * succeeds.
194 */
195 public abstract boolean setReadOnly(File f);
196
197
198 /* -- Filesystem interface -- */
199
200 /**
201 * List the available filesystem roots.
202 */
203 public abstract File[] listRoots();
204
205 /* -- Disk usage -- */
206 public static final int SPACE_TOTAL = 0;
207 public static final int SPACE_FREE = 1;
208 public static final int SPACE_USABLE = 2;
209
210 public abstract long getSpace(File f, int t);
211
212 /* -- Basic infrastructure -- */
213
214 /**
215 * Compare two abstract pathnames lexicographically.
216 */
217 public abstract int compare(File f1, File f2);
218
219 /**
220 * Compute the hash code of an abstract pathname.
221 */
222 public abstract int hashCode(File f);
223
224 // Flags for enabling/disabling performance optimizations for file
225 // name canonicalization
226 static boolean useCanonCaches = true;
227 static boolean useCanonPrefixCache = true;
228
|
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.io;
27
28 import java.lang.annotation.Native;
29
30 /**
31 * Package-private abstract class for the local filesystem abstraction.
32 */
33
34 abstract class FileSystem {
35
36 /* -- Normalization and construction -- */
37
38 /**
39 * Return the local filesystem's name-separator character.
40 */
41 public abstract char getSeparator();
42
43 /**
44 * Return the local filesystem's path-separator character.
45 */
46 public abstract char getPathSeparator();
47
48 /**
82
83 /* -- Path operations -- */
84
85 /**
86 * Tell whether or not the given abstract pathname is absolute.
87 */
88 public abstract boolean isAbsolute(File f);
89
90 /**
91 * Resolve the given abstract pathname into absolute form. Invoked by the
92 * getAbsolutePath and getCanonicalPath methods in the File class.
93 */
94 public abstract String resolve(File f);
95
96 public abstract String canonicalize(String path) throws IOException;
97
98
99 /* -- Attribute accessors -- */
100
101 /* Constants for simple boolean attributes */
102 @Native public static final int BA_EXISTS = 0x01;
103 @Native public static final int BA_REGULAR = 0x02;
104 @Native public static final int BA_DIRECTORY = 0x04;
105 @Native public static final int BA_HIDDEN = 0x08;
106
107 /**
108 * Return the simple boolean attributes for the file or directory denoted
109 * by the given abstract pathname, or zero if it does not exist or some
110 * other I/O error occurs.
111 */
112 public abstract int getBooleanAttributes(File f);
113
114 @Native public static final int ACCESS_READ = 0x04;
115 @Native public static final int ACCESS_WRITE = 0x02;
116 @Native public static final int ACCESS_EXECUTE = 0x01;
117
118 /**
119 * Check whether the file or directory denoted by the given abstract
120 * pathname may be accessed by this process. The second argument specifies
121 * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check.
122 * Return false if access is denied or an I/O error occurs
123 */
124 public abstract boolean checkAccess(File f, int access);
125 /**
126 * Set on or off the access permission (to owner only or to all) to the file
127 * or directory denoted by the given abstract pathname, based on the parameters
128 * enable, access and oweronly.
129 */
130 public abstract boolean setPermission(File f, int access, boolean enable, boolean owneronly);
131
132 /**
133 * Return the time at which the file or directory denoted by the given
134 * abstract pathname was last modified, or zero if it does not exist or
135 * some other I/O error occurs.
136 */
187 * operation succeeds.
188 */
189 public abstract boolean setLastModifiedTime(File f, long time);
190
191 /**
192 * Mark the file or directory denoted by the given abstract pathname as
193 * read-only, returning <code>true</code> if and only if the operation
194 * succeeds.
195 */
196 public abstract boolean setReadOnly(File f);
197
198
199 /* -- Filesystem interface -- */
200
201 /**
202 * List the available filesystem roots.
203 */
204 public abstract File[] listRoots();
205
206 /* -- Disk usage -- */
207 @Native public static final int SPACE_TOTAL = 0;
208 @Native public static final int SPACE_FREE = 1;
209 @Native public static final int SPACE_USABLE = 2;
210
211 public abstract long getSpace(File f, int t);
212
213 /* -- Basic infrastructure -- */
214
215 /**
216 * Compare two abstract pathnames lexicographically.
217 */
218 public abstract int compare(File f1, File f2);
219
220 /**
221 * Compute the hash code of an abstract pathname.
222 */
223 public abstract int hashCode(File f);
224
225 // Flags for enabling/disabling performance optimizations for file
226 // name canonicalization
227 static boolean useCanonCaches = true;
228 static boolean useCanonPrefixCache = true;
229
|