Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
pass 秘bytes on to Path
  • Loading branch information
BobHanson committed Jan 23, 2020
commit 04243b8df112da274b2e289376057eeec4c95bba
9 changes: 8 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/io/FileDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ public final class FileDescriptor {
*/
File _file;

public byte[] _getBytes(boolean checkDisk) {
if (_file.秘bytes == null && checkDisk) {
// a check for file existence sets the bytes
_file.exists();
}
return _file.秘bytes;
}

private int pos, len = -1;

public void _setPosAndLen(int pos, int len) {
Expand Down Expand Up @@ -283,5 +291,4 @@ synchronized void closeAll(Closeable releaser) throws IOException {
}
}


}
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/java/io/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private boolean _regular(File file) {
}

boolean _exists(File file) {
return (file.秘bytes != null || JSUtil.getFileAsBytes(file) != null);
return (file.秘bytes != null || (file.秘bytes=JSUtil.getFileAsBytes(file)) != null);
}

boolean _isDir(File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@

package java.nio.channels;

import java.io.IOException;


/**
* A channel that can read and write bytes. This interface simply unifies
* {@link ReadableByteChannel} and {@link WritableByteChannel}; it does not
Expand Down
6 changes: 6 additions & 0 deletions sources/net.sf.j2s.java.core/src/swingjs/JSFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ private JSFileChannel(FileDescriptor fd, String path, boolean readable, boolean
this.fd = fd;
this.parent = parent;
this.path = (JSPath) new File(path).toPath();
if (fd != null && (readable || append))
this.path.秘bytes = fd._getBytes(true);
this.path.setIsTempFile(fd._isTempFile());
Set<StandardOpenOption> options = new HashSet<>();
if (readable)
Expand Down Expand Up @@ -406,6 +408,10 @@ public JSByteChannel(FileDescriptor fd, JSPath path, Set<? extends OpenOption> o
boolean truncate = options.contains(StandardOpenOption.TRUNCATE_EXISTING);
boolean create = options.contains(StandardOpenOption.CREATE);
boolean createNew = options.contains(StandardOpenOption.CREATE_NEW);
if ((read ||append) && path.秘bytes == null && fd != null) {
path.秘bytes = fd._getBytes(true);
}

if (read && write) {
秘bytes = getBytes();
if (秘bytes == null) {
Expand Down