145 |
public boolean canRead () |
public boolean canRead () |
146 |
{ |
{ |
147 |
// Test for existence. This also does the SecurityManager check |
// Test for existence. This also does the SecurityManager check |
148 |
if (!exists()) |
if (!exists ()) |
149 |
return(false); |
return false; |
150 |
|
|
151 |
return(canReadInternal(path)); |
return canReadInternal (path); |
152 |
} |
} |
153 |
|
|
154 |
/** |
/** |
169 |
{ |
{ |
170 |
// We still need to do a SecurityCheck since exists() only checks |
// We still need to do a SecurityCheck since exists() only checks |
171 |
// for read access |
// for read access |
172 |
SecurityManager sm = System.getSecurityManager(); |
checkWrite (); |
|
if (sm != null) |
|
|
sm.checkWrite(path); |
|
173 |
|
|
174 |
// Test for existence. This is required by the spec |
// Test for existence. This is required by the spec |
175 |
if (!exists()) |
if (!exists()) |
208 |
*/ |
*/ |
209 |
public boolean createNewFile() throws IOException |
public boolean createNewFile() throws IOException |
210 |
{ |
{ |
211 |
SecurityManager s = System.getSecurityManager (); |
checkWrite (); |
|
|
|
|
if (s != null) |
|
|
s.checkWrite (path); |
|
|
|
|
212 |
return createInternal (getPath ()); |
return createInternal (getPath ()); |
213 |
} |
} |
214 |
|
|
279 |
*/ |
*/ |
280 |
public boolean exists () |
public boolean exists () |
281 |
{ |
{ |
282 |
// Check the SecurityManager |
checkRead (); |
283 |
SecurityManager sm = System.getSecurityManager(); |
return existsInternal (path); |
|
if (sm != null) |
|
|
sm.checkRead(path); |
|
|
|
|
|
return(existsInternal(path)); |
|
284 |
} |
} |
285 |
|
|
286 |
/** |
/** |
529 |
*/ |
*/ |
530 |
public boolean isDirectory () |
public boolean isDirectory () |
531 |
{ |
{ |
532 |
SecurityManager s = System.getSecurityManager (); |
checkRead (); |
533 |
|
return isDirectoryInternal (path); |
|
if (s != null) |
|
|
s.checkRead (path); |
|
|
|
|
|
return isDirectoryInternal(path); |
|
534 |
} |
} |
535 |
|
|
536 |
/** |
/** |
545 |
*/ |
*/ |
546 |
public boolean isFile () |
public boolean isFile () |
547 |
{ |
{ |
548 |
SecurityManager s = System.getSecurityManager (); |
checkRead (); |
|
|
|
|
if (s != null) |
|
|
s.checkRead(path); |
|
|
|
|
549 |
return isFileInternal (path); |
return isFileInternal (path); |
550 |
} |
} |
551 |
|
|
591 |
*/ |
*/ |
592 |
public long lastModified () |
public long lastModified () |
593 |
{ |
{ |
594 |
SecurityManager s = System.getSecurityManager (); |
checkRead (); |
595 |
|
return lastModifiedInternal (path); |
|
if (s != null) |
|
|
s.checkRead (path); |
|
|
|
|
|
return lastModifiedInternal(path); |
|
596 |
} |
} |
597 |
|
|
598 |
/* |
/* |
611 |
*/ |
*/ |
612 |
public long length () |
public long length () |
613 |
{ |
{ |
614 |
SecurityManager s = System.getSecurityManager (); |
checkRead (); |
615 |
if (s != null) |
return lengthInternal (path); |
|
s.checkRead (path); |
|
|
|
|
|
return lengthInternal(path); |
|
616 |
} |
} |
617 |
|
|
618 |
/* |
/* |
650 |
*/ |
*/ |
651 |
public String[] list (FilenameFilter filter) |
public String[] list (FilenameFilter filter) |
652 |
{ |
{ |
653 |
// Check the SecurityManager |
checkRead (); |
|
SecurityManager s = System.getSecurityManager (); |
|
|
if (s != null) |
|
|
s.checkRead (path); |
|
654 |
|
|
655 |
// Get the list of files |
// Get the list of files |
656 |
String list_path = PlatformHelper.removeTailSeparator(path); |
String list_path = PlatformHelper.removeTailSeparator(path); |
663 |
if (files == null) |
if (files == null) |
664 |
return new String[0]; |
return new String[0]; |
665 |
if (filter == null) |
if (filter == null) |
666 |
return(files); |
return files; |
667 |
|
|
668 |
// Apply the filter |
// Apply the filter |
669 |
int count = 0; |
int count = 0; |
681 |
if (files[i] != null) |
if (files[i] != null) |
682 |
retfiles[count++] = files[i]; |
retfiles[count++] = files[i]; |
683 |
|
|
684 |
return(retfiles); |
return retfiles; |
685 |
} |
} |
686 |
|
|
687 |
/** |
/** |
871 |
*/ |
*/ |
872 |
public boolean mkdir () |
public boolean mkdir () |
873 |
{ |
{ |
874 |
// Check the SecurityManager |
checkWrite (); |
875 |
SecurityManager sm = System.getSecurityManager(); |
String mk_path = PlatformHelper.removeTailSeparator (path); |
876 |
if (sm != null) |
return mkdirInternal (mk_path); |
|
sm.checkWrite(path); |
|
|
|
|
|
String mk_path; |
|
|
mk_path = PlatformHelper.removeTailSeparator(path); |
|
|
|
|
|
return(mkdirInternal(mk_path)); |
|
877 |
} |
} |
878 |
|
|
879 |
/** |
/** |
1012 |
public boolean setReadOnly () |
public boolean setReadOnly () |
1013 |
{ |
{ |
1014 |
// Test for existence. |
// Test for existence. |
1015 |
if (!exists()) |
if (!exists ()) |
1016 |
return(false); |
return false; |
1017 |
|
|
1018 |
// We still need to do a SecurityCheck since exists() only checks |
// We still need to do a SecurityCheck since exists() only checks |
1019 |
// for read access |
// for read access |
1020 |
SecurityManager sm = System.getSecurityManager(); |
checkWrite (); |
1021 |
if (sm != null) |
return setReadOnlyInternal (path); |
|
sm.checkWrite(path); |
|
|
|
|
|
return setReadOnlyInternal(path); |
|
1022 |
} |
} |
1023 |
|
|
1024 |
/** |
/** |
1156 |
*/ |
*/ |
1157 |
public synchronized boolean renameTo (File dest) |
public synchronized boolean renameTo (File dest) |
1158 |
{ |
{ |
1159 |
// Check the SecurityManager |
checkWrite (); |
|
SecurityManager s = System.getSecurityManager (); |
|
|
|
|
|
if (s != null) |
|
|
s.checkWrite (path); |
|
|
|
|
1160 |
// Call our native rename method |
// Call our native rename method |
1161 |
boolean rc = renameToInternal(path, dest.getPath()); |
return renameToInternal (path, dest.getPath ()); |
|
|
|
|
return rc; |
|
1162 |
} |
} |
1163 |
|
|
1164 |
/* |
/* |
1187 |
if (time < 0) |
if (time < 0) |
1188 |
throw new IllegalArgumentException("Negative modification time: " + time); |
throw new IllegalArgumentException("Negative modification time: " + time); |
1189 |
|
|
1190 |
|
checkWrite (); |
1191 |
|
return setLastModifiedInternal (path, time); |
1192 |
|
} |
1193 |
|
|
1194 |
|
private void checkWrite () |
1195 |
|
{ |
1196 |
// Check the SecurityManager |
// Check the SecurityManager |
1197 |
SecurityManager s = System.getSecurityManager (); |
SecurityManager s = System.getSecurityManager (); |
1198 |
|
|
1199 |
if (s != null) |
if (s != null) |
1200 |
s.checkWrite (path); |
s.checkWrite (path); |
1201 |
|
} |
1202 |
|
|
1203 |
|
private void checkRead () |
1204 |
|
{ |
1205 |
|
// Check the SecurityManager |
1206 |
|
SecurityManager s = System.getSecurityManager (); |
1207 |
|
|
1208 |
return setLastModifiedInternal (path, time); |
if (s != null) |
1209 |
|
s.checkRead (path); |
1210 |
} |
} |
1211 |
|
|
1212 |
/** |
/** |
1231 |
// FIXME: ********IMPLEMENT ME!!!!!!*************** |
// FIXME: ********IMPLEMENT ME!!!!!!*************** |
1232 |
return; |
return; |
1233 |
} |
} |
1234 |
|
|
1235 |
|
private void writeObject (ObjectOutputStream oos) throws IOException |
1236 |
|
{ |
1237 |
|
oos.defaultWriteObject (); |
1238 |
|
oos.writeChar (separatorChar); |
1239 |
|
} |
1240 |
|
|
1241 |
|
private void readObject (ObjectInputStream ois) |
1242 |
|
throws ClassNotFoundException, IOException |
1243 |
|
{ |
1244 |
|
ois.defaultReadObject (); |
1245 |
|
|
1246 |
|
// If the file was from an OS with a different dir separator, |
1247 |
|
// fixup the path to use the separator on this OS. |
1248 |
|
char oldSeparatorChar = ois.readChar (); |
1249 |
|
|
1250 |
|
if (oldSeparatorChar != separatorChar) |
1251 |
|
path = path.replace (oldSeparatorChar, separatorChar); |
1252 |
|
} |
1253 |
} // class File |
} // class File |
1254 |
|
|