Skip to content

Commit 7216b21

Browse files
hansonrhansonr
authored andcommitted
Adds FileSystemView and File.list(), File.listFiles()
- only for files that have been cached.
1 parent ce82cd4 commit 7216b21

File tree

6 files changed

+948
-53
lines changed

6 files changed

+948
-53
lines changed

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

Lines changed: 24 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ public boolean canWrite() {
781781
* method denies read access to the file or directory
782782
*/
783783
public boolean exists() {
784-
return this.path.indexOf("!/") < 0 && fs._exists(this);
784+
return path.indexOf("!/") < 0 && (fs._exists(this) || fs._isDir(this));
785785
}
786786

787787
/**
@@ -832,55 +832,29 @@ public boolean isFile() {
832832
// }
833833
// return ((fs.getBooleanAttributes(this) & FileSystem.BA_REGULAR) != 0);
834834
}
835-
//
836-
// /**
837-
// * Tests whether the file named by this abstract pathname is a hidden
838-
// * file. The exact definition of <em>hidden</em> is system-dependent. On
839-
// * UNIX systems, a file is considered to be hidden if its name begins with
840-
// * a period character (<code>'.'</code>). On Microsoft Windows systems, a file is
841-
// * considered to be hidden if it has been marked as such in the filesystem.
842-
// *
843-
// * @return <code>true</code> if and only if the file denoted by this
844-
// * abstract pathname is hidden according to the conventions of the
845-
// * underlying platform
846-
// *
847-
// * @throws SecurityException
848-
// * If a security manager exists and its <code>{@link
849-
// * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
850-
// * method denies read access to the file
851-
// *
852-
// * @since 1.2
853-
// */
854-
// public boolean isHidden() {
855-
// SecurityManager security = System.getSecurityManager();
856-
// if (security != null) {
857-
// security.checkRead(path);
858-
// }
859-
// return ((fs.getBooleanAttributes(this) & FileSystem.BA_HIDDEN) != 0);
860-
// }
861-
//
862-
// /**
863-
// * Returns the time that the file denoted by this abstract pathname was
864-
// * last modified.
865-
// *
866-
// * @return A <code>long</code> value representing the time the file was
867-
// * last modified, measured in milliseconds since the epoch
868-
// * (00:00:00 GMT, January 1, 1970), or <code>0L</code> if the
869-
// * file does not exist or if an I/O error occurs
870-
// *
871-
// * @throws SecurityException
872-
// * If a security manager exists and its <code>{@link
873-
// * java.lang.SecurityManager#checkRead(java.lang.String)}</code>
874-
// * method denies read access to the file
875-
// */
876-
// public long lastModified() {
877-
// SecurityManager security = System.getSecurityManager();
878-
// if (security != null) {
879-
// security.checkRead(path);
880-
// }
881-
// return fs.getLastModifiedTime(this);
882-
// }
883-
//
835+
836+
/**
837+
* Tests whether the file named by this abstract pathname is a hidden
838+
* file. The exact definition of <em>hidden</em> is system-dependent. On
839+
* UNIX systems, a file is considered to be hidden if its name begins with
840+
* a period character (<code>'.'</code>). On Microsoft Windows systems, a file is
841+
* considered to be hidden if it has been marked as such in the filesystem.
842+
*
843+
* @return <code>true</code> if and only if the file denoted by this
844+
* abstract pathname is hidden according to the conventions of the
845+
* underlying platform
846+
*
847+
* @throws SecurityException
848+
* If a security manager exists and its <code>{@link
849+
* java.lang.SecurityManager#checkRead(java.lang.String)}</code>
850+
* method denies read access to the file
851+
*
852+
* @since 1.2
853+
*/
854+
public boolean isHidden() {
855+
return false;// getName().startsWith(".");
856+
}
857+
884858
/**
885859
* Returns the length of the file denoted by this abstract pathname.
886860
* The return value is unspecified if this pathname denotes a directory.

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
package java.io;
2727

28+
import java.util.Map;
29+
import java.util.Map.Entry;
30+
import java.util.Set;
31+
2832
import swingjs.JSUtil;
2933

3034
/**
@@ -93,7 +97,7 @@ public boolean delete(File f) {
9397
* successful; otherwise, return <code>null</code>.
9498
*/
9599
public String[] list(File f) {
96-
return null;
100+
return JSUtil.getCachedFileList(f);
97101
}
98102

99103
/**

sources/net.sf.j2s.java.core/src/javax/swing/JFileChooser.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
import javax.swing.event.EventListenerList;
4949
import javax.swing.filechooser.FileFilter;
5050
import javax.swing.filechooser.FileSystemView;
51-
//import javax.swing.filechooser.FileSystemView;
5251
import javax.swing.filechooser.FileView;
5352

5453
import swingjs.JSUtil;

0 commit comments

Comments
 (0)