Skip to content

Commit 4570af7

Browse files
committed
fix for char File.separator missing
problem was that Java 7 assigns to a static method, fs.getSeparatorChar(); not a simple constant, which must remain available at runtime, so one cannot just substitute that by a constant, which will disappear.
1 parent df6f2ae commit 4570af7

File tree

2 files changed

+265
-2
lines changed

2 files changed

+265
-2
lines changed

sources/net.sf.j2s.java.core/src/java/io/File.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public class File
138138
// /**
139139
// * The FileSystem object representing the platform's local file system.
140140
// */
141-
// static private FileSystem fs = FileSystem.getFileSystem();
141+
static private FileSystem fs = FileSystem.getFileSystem();
142142

143143
/**
144144
* This abstract pathname's normalized pathname string. A normalized
@@ -171,7 +171,7 @@ int getPrefixLength() {
171171
*
172172
* @see java.lang.System#getProperty(java.lang.String)
173173
*/
174-
public static final char separatorChar = '/';// SwingJS was fs.getSeparator();
174+
public static final char separatorChar = fs.getSeparator();
175175

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

0 commit comments

Comments
 (0)