History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/java/io/FileSystem.java (1 of 18352 files). Show all

Unified · Split

java/pkg/java/io/FileSystem.java+252−0
@@ -0,0 +1,252 @@
1/*
2 * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
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
26package java.io;
27
28
29/**
30 * Package-private abstract class for the local filesystem abstraction.
31 */
32
33abstract class FileSystem {
34
35 /**
36 * Return the FileSystem object representing this platform's local
37 * filesystem.
38 */
39 public static native FileSystem getFileSystem();
40
41
42 /* -- Normalization and construction -- */
43
44 /**
45 * Return the local filesystem's name-separator character.
46 */
47 public abstract char getSeparator();
48
49 /**
50 * Return the local filesystem's path-separator character.
51 */
52 public abstract char getPathSeparator();
53
54 /**
55 * Convert the given pathname string to normal form. If the string is
56 * already in normal form then it is simply returned.
57 */
58 public abstract String normalize(String path);
59
60 /**
61 * Compute the length of this pathname string's prefix. The pathname
62 * string must be in normal form.
63 */
64 public abstract int prefixLength(String path);
65
66 /**
67 * Resolve the child pathname string against the parent.
68 * Both strings must be in normal form, and the result
69 * will be in normal form.
70 */
71 public abstract String resolve(String parent, String child);
72
73 /**
74 * Return the parent pathname string to be used when the parent-directory
75 * argument in one of the two-argument File constructors is the empty
76 * pathname.
77 */
78 public abstract String getDefaultParent();
79
80 /**
81 * Post-process the given URI path string if necessary. This is used on
82 * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string
83 * still has slash separators; code in the File class will translate them
84 * after this method returns.
85 */
86 public abstract String fromURIPath(String path);
87
88
89 /* -- Path operations -- */
90
91 /**
92 * Tell whether or not the given abstract pathname is absolute.
93 */
94 public abstract boolean isAbsolute(File f);
95
96 /**
97 * Resolve the given abstract pathname into absolute form. Invoked by the
98 * getAbsolutePath and getCanonicalPath methods in the File class.
99 */
100 public abstract String resolve(File f);
101
102 public abstract String canonicalize(String path) throws IOException;
103
104
105 /* -- Attribute accessors -- */
106
107 /* Constants for simple boolean attributes */
108 public static final int BA_EXISTS = 0x01;
109 public static final int BA_REGULAR = 0x02;
110 public static final int BA_DIRECTORY = 0x04;
111 public static final int BA_HIDDEN = 0x08;
112
113 /**
114 * Return the simple boolean attributes for the file or directory denoted
115 * by the given abstract pathname, or zero if it does not exist or some
116 * other I/O error occurs.
117 */
118 public abstract int getBooleanAttributes(File f);
119
120 public static final int ACCESS_READ = 0x04;
121 public static final int ACCESS_WRITE = 0x02;
122 public static final int ACCESS_EXECUTE = 0x01;
123
124 /**
125 * Check whether the file or directory denoted by the given abstract
126 * pathname may be accessed by this process. The second argument specifies
127 * which access, ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE, to check.
128 * Return false if access is denied or an I/O error occurs
129 */
130 public abstract boolean checkAccess(File f, int access);
131 /**
132 * Set on or off the access permission (to owner only or to all) to the file
133 * or directory denoted by the given abstract pathname, based on the parameters
134 * enable, access and oweronly.
135 */
136 public abstract boolean setPermission(File f, int access, boolean enable, boolean owneronly);
137
138 /**
139 * Return the time at which the file or directory denoted by the given
140 * abstract pathname was last modified, or zero if it does not exist or
141 * some other I/O error occurs.
142 */
143 public abstract long getLastModifiedTime(File f);
144
145 /**
146 * Return the length in bytes of the file denoted by the given abstract
147 * pathname, or zero if it does not exist, is a directory, or some other
148 * I/O error occurs.
149 */
150 public abstract long getLength(File f);
151
152
153 /* -- File operations -- */
154
155 /**
156 * Create a new empty file with the given pathname. Return
157 * <code>true</code> if the file was created and <code>false</code> if a
158 * file or directory with the given pathname already exists. Throw an
159 * IOException if an I/O error occurs.
160 */
161 public abstract boolean createFileExclusively(String pathname)
162 throws IOException;
163
164 /**
165 * Delete the file or directory denoted by the given abstract pathname,
166 * returning <code>true</code> if and only if the operation succeeds.
167 */
168 public abstract boolean delete(File f);
169
170 /**
171 * List the elements of the directory denoted by the given abstract
172 * pathname. Return an array of strings naming the elements of the
173 * directory if successful; otherwise, return <code>null</code>.
174 */
175 public abstract String[] list(File f);
176
177 /**
178 * Create a new directory denoted by the given abstract pathname,
179 * returning <code>true</code> if and only if the operation succeeds.
180 */
181 public abstract boolean createDirectory(File f);
182
183 /**
184 * Rename the file or directory denoted by the first abstract pathname to
185 * the second abstract pathname, returning <code>true</code> if and only if
186 * the operation succeeds.
187 */
188 public abstract boolean rename(File f1, File f2);
189
190 /**
191 * Set the last-modified time of the file or directory denoted by the
192 * given abstract pathname, returning <code>true</code> if and only if the
193 * operation succeeds.
194 */
195 public abstract boolean setLastModifiedTime(File f, long time);
196
197 /**
198 * Mark the file or directory denoted by the given abstract pathname as
199 * read-only, returning <code>true</code> if and only if the operation
200 * succeeds.
201 */
202 public abstract boolean setReadOnly(File f);
203
204
205 /* -- Filesystem interface -- */
206
207 /**
208 * List the available filesystem roots.
209 */
210 public abstract File[] listRoots();
211
212 /* -- Disk usage -- */
213 public static final int SPACE_TOTAL = 0;
214 public static final int SPACE_FREE = 1;
215 public static final int SPACE_USABLE = 2;
216
217 public abstract long getSpace(File f, int t);
218
219 /* -- Basic infrastructure -- */
220
221 /**
222 * Compare two abstract pathnames lexicographically.
223 */
224 public abstract int compare(File f1, File f2);
225
226 /**
227 * Compute the hash code of an abstract pathname.
228 */
229 public abstract int hashCode(File f);
230
231 // Flags for enabling/disabling performance optimizations for file
232 // name canonicalization
233 static boolean useCanonCaches = true;
234 static boolean useCanonPrefixCache = true;
235
236 private static boolean getBooleanProperty(String prop, boolean defaultVal) {
237 String val = System.getProperty(prop);
238 if (val == null) return defaultVal;
239 if (val.equalsIgnoreCase("true")) {
240 return true;
241 } else {
242 return false;
243 }
244 }
245
246 static {
247 useCanonCaches = getBooleanProperty("sun.io.useCanonCaches",
248 useCanonCaches);
249 useCanonPrefixCache = getBooleanProperty("sun.io.useCanonPrefixCache",
250 useCanonPrefixCache);
251 }
252}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t