public class FileRemote extends java.io.File implements MarkMask_ifc, TreeNodeNamed_ifc
File
but it does not immediately or never use the implementation of File. All operations are overridden.
The implementation is part of the aggregated device
which may use the capabilities of java.io.File
or also java.nio.files.
File
, there the information are gotten from the operation system
in any case, the access is correct but can be slow especially the file is located anywhere in network
or in a specific device.
FileRemoteAccessor
implementations referenced with device
.
It may be any information on an embedded hardware, not only in a standard network.
For example the access to zip archives are implemented by FileAccessZip
.
A file can be present only with one line in a text document which contains path, size, date.
In this case the content is not available, but the properties of the file. See FileList
.
timeRefresh
and timeChildren
. With this information
an application can decide whether the file should be #refreshProperties(CallbackEvent)
or whether its propertees seems to be actual valid.
FileRemoteAccessor
: device
to refresh.
File
for local files.
FileCluster
: itsCluster
.
The cluster assures that only one FileRemote instance exists for one physical file inside an application.
In this case some additional properties can be stored to the FileRemote instance like selected etc.
which are seen application-width.
clusterOfApplication
:FileCluster
assures that any file has only exact one FileRemote instance as presentation.
On the one hand this prevents too many access to the file system.
If the instance is refreshed a short time ago then it should not be refreshed for the same physical file
in another instance.
setMarked(int)
is not supported by a file system itself but it is supported here.
The itsCluster
for a file (usual the clusterOfApplication
) is independent
of the device()
which is the reference to the file system implementor.
fromFile(File)
if you have already given a java.io.File instance.
get(String)
with relative or absolute given path.
getDir(CharSequence)
explicitely get or create a directory
getFile(CharSequence, CharSequence)
in opposite to get(String) with dispersed directory path and name
child(CharSequence)
from a given FileRemote as directory
child(CharSequence, int, int, long, long, long)
to create a child with partially known properties
subdir(CharSequence)
to get or create definitely a directory inside a given FileRemote directory.
clusterOfApplication
whether the file is already known and returns it, or they create and register the adequate FileRemote instance
in the cluster.
The FileRemote instance should/can be synchronized with the real file instance by calling #refreshProperties(CallbackEvent)
or for directory instances with #refreshPropertiesAndChildren()
from the local file system you can call
fromFile(File)
. This delegates working to #fromFile(FileCluster, File)
with the static given clusterOfApplication
which looks whether the FileRemote instance
is existing already, or registeres it in the file cluster.
The implementor of the file system depends on the given path.
child(CharSequence)
, subdir(CharSequence)
or child(CharSequence, int, int, long, long, long)
whereby the child can be a deeper one, the path is a relative path from the given parent.
This FileRemote instance describes a possible existing file or maybe a non existing one,
adequate like creation of instance of File
.
Note that on #refreshPropertiesAndChildren(CallbackEvent)
this instance will be removed
from the children list if it is not existing.
FileCluster#getFile(CharSequence)
.
This instance will be created if it is not existing, or it will be get from an existing instance
of this RemoteFile inside the cluster. The instance won't be deleted if the physical file is not existing.
For example you can create FileRemote testFile = theFileCluster.getFile("X:/MyPath/file.ext");This instance is existing independent of the existence of such a physical file. But
if(testFile.exists()){....may return false.
File
in the determination as interface. The advantage is:
FileRemoteWalkerCallback
which is given either by the application
or given for specific commands in the implementation in the device.
It is used to do actions with any (selected) file or directory.
#refreshAndMark(int, boolean, String, int, int, FileRemoteWalkerCallback)
marks files for copy, move or delete.
#refreshAndCompare(FileRemote, int, String, int, FileRemoteProgressEvData)
compares two trees of files.
#copyChecked(String, String, int, CallbackEvent)
copies some or all files in a tree.
#deleteChecked(CallbackEvent, int)
deletes some or all files in a tree.
FileRemoteWalkerCallback
: It is a callback interface with methods for each file and each started and finished directory.
FileRemoteProgressEvData
: It is an instance which is filled with data. The time order is handled by a timer
which activates it for example in a cycle for 200 milliseconds. The user extends this base class with the showing method.
In a time range of 200 milliseconds there can be executed some more files, for example 1000 if the file system is local.
Not any file forces to be showed. Therewith calculation time is saved.
File.mkdir()
or File.delete()
.
This operations are the first in the Java of the 1990th presuming a simple file system.
Reader.read(char[])
does not return a negative number on reading error which may be possible, instead throws.
An FileReader.open() which may return an information does not exist, instead the constructor is used for open,
which throws an exception if the file does not exist.
This means effort for exception handling though the situation of a non existing file is expectable.
Exception handling should be intrinsically only done on real faulty situations.
File
needs a). Exception handling is done only on really exceptions.
EventWithDst
with FileRemoteProgressEvData
as data type.
The back or progress event can be used also to get information about the progress of a longer operation,
for example copy long files. But it is also used for the success or error information.
Modifier and Type | Class and Description |
---|---|
static class |
FileRemote.CallbackEvent
Type for callback notification for any action with remote files.
|
static class |
FileRemote.Ecmp
Possibilities for comparison.
|
static interface |
FileRemote.FileRemoteAccessorSelector
interface to build an instance, which decides about the instance for physical access to files
in knowledge of the path.
|
class |
FileRemote.InternalAccess
This inner non static class is only intent to access from a FileRemoteAccessor to any file.
|
static class |
FileRemote.XXXCallbackCmd
Designates that the copy process which was forced forward with this callback should be stopped and aborted.
|
Modifier and Type | Field and Description |
---|---|
private int |
_ident
A indent number, Primarily for debug and test.
|
private FileRemote.InternalAccess |
acc_ |
private static FileRemote.FileRemoteAccessorSelector |
accessorSelector
Instance of the application-width selector for
FileRemoteAccessor . |
private java.util.Map<java.lang.String,FileRemote> |
children
The content of a directory.
|
static FileCluster |
clusterOfApplication
This cluster is used if a specific cluster should not be used.
|
private static int |
ctIdent
Counter, any instance has an ident number.
|
protected long |
date
Timestamp of the file.
|
protected long |
dateCreation
Timestamp of the file.
|
protected long |
dateLastAccess
Timestamp of the file.
|
protected FileRemoteAccessor |
device
The device which manages the physical files.
|
(package private) EventSource |
evSrc |
protected int |
flags
Some flag bits.
|
FileCluster |
itsCluster
Any FileRemote instance should be member of a FileCluster.
|
protected long |
length
Length of the file.
|
static int |
mAbsPath
Type of given path.
|
protected FileMark |
mark
A mark and count instance for this file.
|
static int |
mCanRead
Info about the file stored in
flags returned with getFlags() . |
static int |
mCanReadAny
Group and any read and write permissions.
|
static int |
mCanReadGrp
Group and any read and write permissions.
|
static int |
mCanWrite
Info about the file stored in
flags returned with getFlags() . |
static int |
mCanWriteAny
Group and any read and write permissions.
|
static int |
mCanWriteGrp
Group and any read and write permissions.
|
static int |
mDirectory
Info whether the File is a directory.
|
static int |
mExecute
Info whether it is an executable (executable flag on unix)
|
static int |
mExecuteAny
Info whether it is an executable (executable flag on unix)
|
static int |
mExecuteGrp
Group and any read and write permissions.
|
static int |
mExist
Info about the file stored in
flags returned with getFlags() . |
static int |
mFile
Info whether the File is a directory.
|
static int |
mHidden
Info about the file stored in
flags returned with getFlags() . |
static int |
modeCmprLogComparedFiles
Bits for the logging mode of
#cmprDirs(File, File, String, List) . |
static int |
modeCmprLogMissing1File
Bits for the logging mode of
#cmprDirs(File, File, String, List) . |
static int |
modeCmprLogMissing2File
Bits for the logging mode of
#cmprDirs(File, File, String, List) . |
static int |
modeCmprLogNotEqualFiles
Bits for the logging mode of
#cmprDirs(File, File, String, List) . |
static int |
modeCopyCreateAsk |
static int |
modeCopyCreateMask |
static int |
modeCopyCreateNever |
static int |
modeCopyCreateYes |
static int |
modeCopyExistAll |
static int |
modeCopyExistAsk |
static int |
modeCopyExistMask |
static int |
modeCopyExistNewer |
static int |
modeCopyExistOlder |
static int |
modeCopyExistSkip |
static int |
modeCopyReadOnlyAks |
static int |
modeCopyReadOnlyMask |
static int |
modeCopyReadOnlyNever |
static int |
modeCopyReadOnlyOverwrite |
static int |
mRefreshChildPending
Set if the file is removed yet because a refresh is pending.
|
static int |
mRelativePath
Type of given path.
|
static int |
mRoot
Set if it is a root directory.
|
static int |
mShouldRefresh
Flags as result of an comparison: the other file exist but its content is different.
|
static int |
mSymLinkedPath
A symbolic link in unix.
|
static int |
mTested
Set if the file is tested physically.
|
static int |
mThreadIsRunning
Set if a thread runs to get file properties.
|
(package private) java.lang.Object |
oFile
This is the internal file object.
|
(package private) FileRemote |
parent
The parent instance, it is the directory where the file is member of.
|
protected java.nio.file.Path |
path
can be null or set with the valid path.
|
protected java.lang.String |
sCanonicalPath
The unique path to the file or directory entry.
|
protected java.lang.String |
sDir
The directory path of the file.
|
private static long |
serialVersionUID |
protected java.lang.String |
sFile
The name with extension of the file or directory name.
|
long |
timeChildren
The last time where the file was synchronized with its physical properties.
|
long |
timeRefresh
The last time where the file was synchronized with its physical properties.
|
static java.lang.String |
version
Version, history and license.
|
select, select2, select2Parent, selectParent
Modifier | Constructor and Description |
---|---|
protected |
FileRemote(FileCluster cluster,
FileRemoteAccessor device,
FileRemote parent,
java.lang.CharSequence sPath,
long length,
long dateLastModified,
long dateCreation,
long dateLastAccess,
int flags,
java.lang.Object oFileP,
boolean OnlySpecialCall)
Constructs an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
_setProperties(long length,
long date,
long dateCreation,
long dateAccess,
int flags,
java.lang.Object oFileP)
Sets the properties to this.
|
void |
abortAction()
It sends an abort event to the execution thread or to any remote device to abort any action with files.
|
boolean |
canExecute()
true if due to Java orientation to the file system the file is executable.
|
boolean |
canRead()
true if due to Java orientation to the file system the file is readable (visible).
|
boolean |
canWrite()
true if due to Java orientation to the file system the file is not read only.
|
void |
check(java.lang.String sFiles,
java.lang.String sWildcardSelection,
FileRemoteProgressEvData evback)
Deprecated.
|
void |
chgProps(boolean bWait,
java.lang.String newName,
int maskFlags,
int newFlags,
long newDate,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Change the file properties maybe in a remote device.
|
void |
chgPropsRecursive(int maskFlags,
int newFlags,
long newDate,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Change the file properties maybe in a remote device.
|
FileRemote |
child(java.lang.CharSequence sPathChild)
Gets or creates a child with the given name.
|
private FileRemote |
child(java.lang.CharSequence sPathChild,
int flags,
int length,
long dateLastModified,
long dateCreation,
long dateLastAccess)
Returns the instance of FileRemote which is the child of this.
|
java.util.Map<java.lang.String,FileRemote> |
children()
Gets the Index of the children sorted by name.
|
void |
cleanChildren()
Cleans the children list.
|
void |
cmdRemote(FileRemoteCmdEventData.Cmd cmd,
FileRemote dstdir,
java.lang.String selectFilter,
int cycleProgress,
int depthWalk,
FileRemoteCmdEventData cmdDataArg,
EventWithDst<FileRemoteProgressEvData,?> progressEv)
This is the basic operation to force execution with this file or dir
either on another device or in another thread, depending on its
device() . |
void |
cmprDirTreeTo(boolean bWait,
FileRemote dir2,
java.lang.String mask,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Refreshes a file tree and compare some or all files.
|
void |
copyChecked(java.lang.String pathDst,
java.lang.String nameModification,
int mode,
FileRemoteWalkerCallback callbackUser,
FileRemoteProgressEvData timeOrderProgress)
Copies all files which are checked before.
|
void |
copyDirTreeTo(boolean bWait,
FileRemote dirDst,
int depth,
int markSet,
int markSetDir,
java.lang.String selectFilter,
int selectMask,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
void |
copyDirTreeTo(boolean bWait,
FileRemote dirDst,
int depth,
java.lang.String mask,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
java.lang.String |
copyTo(FileRemote dst,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
void |
copyTo(FileRemote dst,
EventWithDst<FileRemoteProgressEvData,?> evBack,
int mode)
Copies a file or directory tree to another file in the same device.
|
void |
countAllFileLength(EventWithDst<FileRemoteProgressEvData,?> evBack)
Count the sum of length of all files in this directory tree.
|
static java.util.Map<java.lang.String,FileRemote> |
createChildrenList()
Method to create a children list.
|
boolean |
createNewFile() |
long |
creationTime()
Returns the creation time of the file if the file system supports it.
|
boolean |
delete()
Deletes this file, correct the parent's children list, remove this file.
|
void |
delete(EventWithDst<FileRemoteProgressEvData,?> evBack)
Deletes a file maybe in a remote device.
|
void |
deleteFilesDirTree(boolean bWait,
int depth,
java.lang.String mask,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
FileRemoteAccessor |
device() |
boolean |
exists()
Returns true if the file seems to be existing.
|
java.io.File |
file() |
static FileRemote |
fromFile(java.io.File src)
Returns a FileRemote instance from a standard java.io.File instance.
|
static FileRemote |
get(FileCluster cluster,
java.lang.String filePath) |
static FileRemote |
get(java.lang.String filePath)
Gets an existing FileRemote instance or creates a new one.
|
java.lang.String |
getAbsolutePath() |
static FileRemote.FileRemoteAccessorSelector |
getAccessorSelector() |
java.lang.String |
getCanonicalPath() |
FileRemote |
getChild(java.lang.CharSequence name) |
FileMark |
getCreateMark()
Gets or creates a
FileMark for this file. |
static FileRemote |
getDir(java.lang.CharSequence dirPath)
Returns the instance which is associated to the given directory.
|
static FileRemote |
getDir(FileCluster cluster,
java.lang.CharSequence dirPath)
Returns the instance which is associated to the given directory.
|
java.lang.CharSequence |
getDirChars() |
static FileRemote |
getFile(java.lang.CharSequence dir,
java.lang.CharSequence name)
Returns the instance which is associated to the given directory and name.
|
static FileRemote |
getFile(FileCluster cluster,
java.lang.CharSequence dirPath,
java.lang.CharSequence name)
Returns the instance which is associated to the given directory and the file in this directory.
|
int |
getFlags() |
int |
getFlagsTested()
Return the flags of the file after tested with file system itself.
|
int |
getMark()
Returns the mark of a
mark or 0 if it is not present. |
java.lang.String |
getName() |
java.lang.String |
getParent()
Returns the parent path, it is the directory path.
|
FileRemote |
getParentFile()
Gets the parent directory.
|
java.lang.String |
getPath()
Gets the path of the file.
|
java.lang.CharSequence |
getPathChars()
Returns the same as
getPath() for files, but ends with '/' if this is a directory. |
java.lang.CharSequence |
getStateDevice()
Returns the state of the device statemachine, to detect whether it is active or ready.
|
int |
ident() |
FileRemote.InternalAccess |
internalAccess()
This routine is only intent to access from a FileRemoteAccessor to any file.
|
java.lang.CharSequence |
isChild(java.lang.CharSequence path)
Checks whether the given path describes a child (any deepness) of this file and returns the normalized child string.
|
boolean |
isDirectory()
Returns true if the FileRemote instance was created as directory
or if any
#refreshProperties(CallbackEvent) call before this call
has detected that it is an directory. |
boolean |
isFile()
TODO mFile is not set yet, use !
|
boolean |
isHidden()
TODO mFile is not set yet, use !
|
boolean |
isMarked(int mask) |
java.lang.CharSequence |
isParent(java.lang.CharSequence path)
Checks whether the given path describes a parent (any deepness) of this file and returns the normalized child string.
|
boolean |
isRoot() |
boolean |
isSymbolicLink() |
boolean |
isTested()
Returns true if the file was tested in the past.
|
boolean |
isTested(long since)
Returns true if the last time of refreshing is newer than since.
|
long |
lastAccessTime()
Returns the last access time of the file if the file system supports it.
|
long |
lastModified() |
long |
length() |
FileRemote[] |
listFiles()
This method overrides java.io.File.listFiles() but returns Objects from this class type.
|
java.io.File[] |
listFiles(java.io.FileFilter filter) |
FileMark |
mark()
Gets the
FileMark for this file or null if not marked in any kind. |
boolean |
mkdir()
Creates the directory named by this abstract pathname.
|
java.lang.String |
mkdir(boolean recursively,
EventWithDst<FileRemoteProgressEvData,FileRemoteCmdEventData> evBack)
Creates the directory named by this abstract pathname
|
boolean |
mkdirs()
Creates the directory named by this abstract pathname , including any
necessary but nonexistent parent directories.
|
void |
moveTo(java.lang.String sFiles,
FileRemote dst,
FileRemoteProgressEvData evback)
Moves this file or some files in this directory to another file(s) maybe in a remote device.
|
java.lang.Object |
oFile() |
java.io.InputStream |
openInputStream(long passPhrase)
Opens a read access to this file.
|
java.io.OutputStream |
openOutputStream(long passPhrase)
Opens a write access to this file.
|
java.nio.channels.ReadableByteChannel |
openRead(long passPhrase)
Opens a read access to this file.
|
java.nio.channels.WritableByteChannel |
openWrite(long passPhrase)
Opens a write access to this file.
|
java.nio.file.Path |
path() |
(package private) void |
putNewChild(FileRemote child) |
void |
refreshAndMark(boolean bWait,
int depth,
int setMark,
int setMarkDir,
java.lang.String sMaskSelection,
long markSelection,
FileRemoteWalkerCallback callbackUser,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Refreshes a file tree and mark some files.
|
void |
refreshAndSearch(int depth,
java.lang.String mask,
int mark,
byte[] search,
FileRemoteWalkerCallback callbackUser,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Refreshes a file tree and search in some or all files.
|
void |
refreshProperties()
Gets the properties of the file from the physical file immediately in this thread.
|
void |
refreshProperties(EventWithDst<FileRemoteProgressEvData,?> evBack)
Gets the properties of the file from the physical file.
|
void |
refreshPropertiesAndChildren(boolean bWait,
EventWithDst<FileRemoteProgressEvData,?> evBack)
Refreshes the properties of this file and gets all children in an extra thread with user-callback for any file.
|
boolean |
renameTo(java.io.File dst)
renames or moves this file to the given path in dst.
|
java.lang.String |
renameTo(FileRemote dst,
EventWithDst<FileRemoteProgressEvData,?> evBack) |
long |
resetMarked(int mask)
Resets the mark bits of this file.
|
long |
resetMarkedRecurs(int mask,
int[] nrofFiles)
Resets the mark bits of this file and all children (
children() ) which are referred in the FileRemote instance. |
private long |
resetMarkedRecurs(int mask,
int[] nrofFiles,
int recursion)
Recursively called method for
resetMarkedRecurs(int, int[]) |
boolean |
sameDevice(FileRemote other)
Check whether two files are at the same device.
|
void |
search(byte[] search,
FileRemoteWalkerCallback callbackUser,
FileRemoteProgressEvData timeOrderProgress)
Search in all files.
|
static boolean |
setAccessorSelector(FileRemote.FileRemoteAccessorSelector accessorSelectorP) |
void |
setCanonicalAbsPath(java.lang.String pathP)
Sets this as a non-symbolic linked file or dir with the given path.
|
void |
setDirShouldRefresh() |
void |
setFileObject(java.lang.Object oFile) |
boolean |
setLastModified(long time) |
long |
setMarked(int mask)
Marks the file with the given bits in mask.
|
int |
setMarked(int mask,
java.lang.Object data)
marks a bit in the
mark , creates it if it is not existing yet. |
int |
setNonMarked(int mask,
java.lang.Object data)
resets a marker bit in the existing
mark or does nothing if the bit is not present. |
int |
setNonMarkedRecursively(int mask,
java.lang.Object data)
resets a marker bit in the existing
mark or does nothing if the bit is not present. |
java.lang.StringBuilder |
setPathTo(java.lang.StringBuilder ret)
Fills the path to the given StringBuilder and returns the StringBuilder to concatenate.
|
void |
setShouldRefresh() |
void |
setSymbolicLinkedPath(java.lang.String pathP)
Sets this as a symbolic linked file or dir with the given path.
|
boolean |
shouldRefresh() |
FileRemote |
subdir(java.lang.CharSequence sPathChild)
Gets or creates a child with the given name which is a sub directory of this.
|
java.lang.String |
toString() |
void |
walkLocal(FileRemote dstdir,
int markSet,
int markSetDir,
java.lang.String selectFilter,
int selectMask,
int depthWalk,
FileRemoteWalkerCallback callback,
FileRemoteCmdEventData cmdDataArg,
int cycleProgress,
EventWithDst<FileRemoteProgressEvData,?> progressEv)
Walks local only through the FileRemote instances without touch the underlying files on a device.
|
void |
walkRemote(boolean bWait,
FileRemote dirDst,
int depth,
java.lang.String selectFilter,
int cycleProgress,
EventWithDst<FileRemoteProgressEvData,?> evProgress)
walk file tree with specified callback adequate the concept which is implemented in
FileAccessorLocalJava7
or maybe other file access for embedded control. |
void |
XXXcopyTo(FileRemote dst,
int mode) |
compareTo, createTempFile, createTempFile, deleteOnExit, equals, getAbsoluteFile, getCanonicalFile, getFreeSpace, getTotalSpace, getUsableSpace, hashCode, isAbsolute, list, list, listFiles, listRoots, setExecutable, setExecutable, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toURI, toURL
private static final long serialVersionUID
public static final java.lang.String version
FileRemoteProgressEventConsumer
.
FileRemoteCmdEventData
from the inner class CmdEventData.
That causes using FileRemoteCmdEventData.setCmdWalkRemote(FileRemote, org.vishia.fileRemote.FileRemoteCmdEventData.Cmd, FileRemote, String, int, int)
etc. instead immediately writing to its variables. Its better to obvious the software goal!
walkRemote(boolean, FileRemote, int, String, int, EventWithDst)
from 'walker'
Cmd#walkRefresh
from Cmd.walkSelectMark, the name is more concise.
#walkLocal(Cmd, FileRemote, int, int, String, int, int, FileRemoteWalkerCallback, FileRemoteCmdEventData, int, EventWithDst)
it uses the moved and renewed FileRemoteWalker
.
FileRemoteCmdEventData
has now private members and getter. It should be used consequently as payload for a remote access.
Yet it is obfuscated, it is necessary to know the FileRemote instance while working with. But this is not possible if it is really remote.
copyTo(FileRemote, EventWithDst)
and moveTo(String, FileRemote, FileRemoteProgressEvData)
now via device.cmd(), the new approach. Used in The.file.Commander
getPathChars()
now returns dir path ends with slash.
This is in opposite to getPath()
, unchanged, defined by File.getPath()
.
get(String)
, getFile(CharSequence, CharSequence)
, #getDir(String)
#refreshAndMark(int, int, int, String, long, FileRemoteWalkerCallback, FileRemoteProgressEvData)
the depths should be unique as first or second argument, todo change the other operations adequate
#getDirFileDst(String, FileRemote, String[])
usable for String given dir and mask
fromFile(File)
and child(CharSequence, int, int, long, long, long)
:
Generally on creating a FileRemote it should not has any access to the file system, because it is remote.
This is now consequently realized. Till now only the PC file system was used,
hence one access was usual not obviously. But on access to a non existing network drive, sometimes trouble occur.
For The.file.Commander the rule is: Do not access to resources in the graphic thread which are not guaranteed existing.
The graphic thread should never be delayed. This is now true (should be true).
FileMark.selectSomeInDir
, fix: algorithm.
mTested
, mShouldRefresh
, mRefreshChildPending
mThreadIsRunning
to the highest digit of int, to recognize for manual viewing. That flags should not used in applications.
Remove of flags for comparison, the bits are used and defined inside FileMark
for a longer time.
#copyDirTreeTo(FileRemote, int, String, int, FileRemoteProgressEvData)
clusterOfApplication
: There is a singleton, the FileCluster
is not necessary as argument for fromFile(File)
especially to work more simple to use FileRemote
capabilities for File operations.
#refreshPropertiesAndChildren(CallbackFile)
used in Fcmd with an Thread on demand,
see org.vishia.fileLocalAccessor.FileAccessorLocalJava7#walkFileTree(FileRemote, boolean, boolean, String, int, int, FileRemoteWalkerCallback)
and FileRemoteAccessor.FileWalkerThread
.
FileAccessorLocalJava6#selectLocalFileAlways
in getAccessorSelector()
for compatibility with Java6. There the existence of java.nio.file.Files is checked, and the File access
in Java7 is used if available. So this class runs with Java6 too, which is necessary in some established environments.
#getChildren(ChildrenEvent)
with aborting a last request.
#getChildren(ChildrenEvent)
should work proper with
Files.walkFileTree(java.nio.file.Path, java.util.Set, int, java.nio.file.FileVisitor)
.
The event should be called back on 300 ms with the gathered files. If the access needs more time,
it should be able to have more events to present a part of files, or to abort it.
The concept is tested in java-6 yet.
MarkMask_ifc
is renamed, all methods setMarked(int)
etc. are named 'marked' instead of 'selected'.
It is a problem of wording: The instances are only marked, not yet 'selected'. See application
of this interface in org.vishia.gral.widget.GralFileSelector
: A selected line is the current one
or some marked lines.
MarkMask_ifc
for the #cmprResult
.
#moveTo(String, FileRemote, CallbackEvent)
now have a parameter with file names.
sFile
#cmprResult
, setMarked(int)
isTested()
mkdir()
, mkdirs()
, #mkdir(boolean, CallbackEvent)
,
createNewFile()
.
TODO some operation uses still the super implementation of File.
But the super class File should only be used as interface.
child(CharSequence)
accepts a path to a sub child.
New isChild(CharSequence)
, isParent(CharSequence)
.
resetMarkedRecurs(int, int[])
#fromFile(FileCluster, File)
has the FileCluster parameter yet, necessary for the concept.
This method is not necessary as far as possible because most of Files are a FileRemote instance yet by reference (Fcmd app)
FileCluster#getFile(String, String)
and #child(String)
should be used to get an instance of this class. The instances which refers the same file
on the file system are existing only one time in the application respectively in the FileRemoteAccessor
.
In this case additional information can be set to files such as 'selected' or a comparison result. It is in progression.
flags
contains bits for #mChecked
to mark files as checked
with #check(FileRemote, CallbackEvent)
. With that the check state is able to view.
flags
contains bits for #mCmpContent
etc. for comparison to view.
#copyChecked(CallbackEvent, int)
in cohesion with changes
in org.vishia.fileLocalAccessor.Copy_FileLocalAcc
.
CallbackCmd#successCode
etc.
FileRemote.CallbackEvent
contains all the methods to do something with currently copying files,
for example CallbackEvent#copyOverwriteFile(int)
etc.
FileRemoteCmdEventData.filesrc
and filedst and CallbackEvent#filedst
and dst
instead EventCmdtypeWithBackEvent#getRefData()
.
mDirectory
should be set always, especially also though mTested
is false.
That should be assured by the FileRemoteAccessor
implementation.
children
is now of super type File, not FileRemote. Nevertheless FileRemote objects
are stored there. Experience is possible to store a File object returned from File.listFiles without wrapping, and
replace that with a FileRemote object if necessary. listFiles() returns a File[] like its super method.
isTested()
openInputStream(long)
. An application may need that, for example to create
a Reader
with the input stream. Some implementations, especially a local file and a ZipFile
supports that. An InputStream
may force a blocking if data are not available yet for file in a remote device
but that may be accepted.
listFiles(FileFilter)
now implemented here.
FileAccessZip
.
parent
and children
. They are filled calling #refreshPropertiesAndChildren(CallbackEvent)
.
FileRemote.FileRemoteAccessorSelector
and setAccessorSelector(FileRemoteAccessorSelector)
.
The user can have any algorithm to select a FileRemoteAccessor
depending on the
path of the file. A prefix String may determine how the file is to access. If that routine
is not called, the FileAccessorLocalJava7.selectLocalFileAlways
.
#FileRemote(FileRemoteAccessor, FileRemote, String, String, long, long, int, Object)
has the parent as parameter. The parameter oFileP is stored now. It is any data to access the file object.
#refreshProperties(CallbackEvent)
and #refreshPropertiesAndChildren(CallbackEvent)
have to be called if the properties of the real file on the local system (java.io.File)
or any remote system are need. That routines envisages the continuation of working
with a callback event are invocation mechanism. For example if the file properties
should be shown in a graphic application, the building of the graphic can't stop and wait
for more as some 100 milliseconds. It is better to clear a table and continue working in graphic.
If the properties are gotten from the remote system then the table will be filled.
That may be invoked from another thread, the communication thread for the remote device
or by an event mechanism (see FileRemote.CallbackEvent
respectively org.vishia.event.EventCmdtypeWithBackEvent
.
fromFile(File)
reads are properties of a local file if one is given.
In that case the #refreshProperties(CallbackEvent)
need not be invoked additionally.
openRead(long)
and openWrite(long)
accepts a non-given device.
They select it calling FileRemoteAccessorSelector#selectFileRemoteAccessor(String)
length
, lastModified()
, isDirectory()
etc.
now returns only the stored values. It may necessary to invoke #refreshProperties(CallbackEvent)
in the application before they are called to get the correct values. The refreshing
can't be called in that getter routines because they should not wait for communication.
In the case of local files that access may be shorten in time, but it isn't known
whether it is a local file. The user algorithm should work with remote files too if they are
tested locally only. Therefore a different strategy to access properties are not proper to use.
getParentFile()
now uses the parent
reference. If it is null,
a new FileRemote instance for the parent is created, but without access to the file,
only with knowledge of the path string. Because the #FileRemote(FileRemoteAccessor, FileRemote, String, String, long, long, int, Object)
will be gotten the parent of it too, all parent instances will be set recursively then.
listFiles()
now returns the children
only. If the user has not called
#refreshPropertiesAndChildren(CallbackEvent)
, it is empty.
#delete(String, boolean, EventCmdtypeWithBackEvent)
with given mask. TODO: It should done in
FileAccessorLocalJava7
in an extra thread.
#chgProps(String, int, int, long, CallbackEvent)
, #countAllFileLength(CallbackEvent)
.
Enhancements.
sFile
(renamed from name) is empty if this describes
an directory and it is known that it is an directory. The ctor is adapted therefore.
getParent()
is changed. Some assertions are set.
sDir
and an empty name in #key
.
getParentFile()
now implemented here.
fromFile(File)
to convert from a normal File instance.
#_setProperties(long, long, int, Object)
and symbolic linked paths.
oFile
. In the future the superclass File should be used only as interface.
TODO: For any file access the oFile-instance should be used by device
.
#copyTo(FileRemote, EventCmdPingPongType)
org.vishia.commander.Fcmd
, this tool
should work with remote files with any protocol for example FTP. But firstly it is implemented and tested
only for local files. The concept is:
FileRemoteAccessor
is responsible to execute the remote access.
public static final int modeCopyReadOnlyMask
public static final int modeCopyReadOnlyNever
public static final int modeCopyReadOnlyOverwrite
public static final int modeCopyReadOnlyAks
public static final int modeCopyExistMask
public static final int modeCopyExistNewer
public static final int modeCopyExistOlder
public static final int modeCopyExistAll
public static final int modeCopyExistSkip
public static final int modeCopyExistAsk
public static final int modeCopyCreateMask
public static final int modeCopyCreateNever
public static final int modeCopyCreateYes
public static final int modeCopyCreateAsk
public static final int modeCmprLogNotEqualFiles
#cmprDirs(File, File, String, List)
.public static final int modeCmprLogMissing2File
#cmprDirs(File, File, String, List)
.public static final int modeCmprLogMissing1File
#cmprDirs(File, File, String, List)
.public static final int modeCmprLogComparedFiles
#cmprDirs(File, File, String, List)
.public static final int mExist
flags
returned with getFlags()
.public static final int mCanRead
flags
returned with getFlags()
.public static final int mCanWrite
flags
returned with getFlags()
.public static final int mHidden
flags
returned with getFlags()
.public static final int mDirectory
mTested
flag bit.public static final int mFile
mTested
flag bit.public static final int mExecute
public static final int mExecuteAny
public static final int mRelativePath
public static final int mAbsPath
public static final int mSymLinkedPath
public static final int mCanReadGrp
public static final int mCanWriteGrp
public static final int mExecuteGrp
public static final int mCanReadAny
public static final int mCanWriteAny
public static final int mRoot
mDirectory
is set too.public static final int mShouldRefresh
public static final int mThreadIsRunning
public static final int mRefreshChildPending
public static final int mTested
private static FileRemote.FileRemoteAccessorSelector accessorSelector
FileRemoteAccessor
.private static int ctIdent
private final int _ident
public static final FileCluster clusterOfApplication
public final FileCluster itsCluster
protected FileRemoteAccessor device
FileAccessorLocalJava7
is used.protected FileMark mark
public long timeRefresh
public long timeChildren
protected java.lang.String sDir
protected java.lang.String sFile
protected java.lang.String sCanonicalPath
sDir
contains the linked path.protected long date
protected long dateCreation
protected long dateLastAccess
protected long length
protected int flags
mExist
etc.FileRemote parent
private java.util.Map<java.lang.String,FileRemote> children
listFiles()
without filter.
The content is valid at the time of calling refreshPropertiesAndChildren(boolean, EventWithDst)
or its adequate.
It is possible that the content of the physical directory is changed meanwhile.
If this field should be returned without null, especially on listFiles()
and the file is a directory,
the {@link #refreshPropertiesAndChildren(boolean, EventWithDst)java.lang.Object oFile
protected java.nio.file.Path path
EventSource evSrc
private final FileRemote.InternalAccess acc_
protected FileRemote(FileCluster cluster, FileRemoteAccessor device, FileRemote parent, java.lang.CharSequence sPath, long length, long dateLastModified, long dateCreation, long dateLastAccess, int flags, java.lang.Object oFileP, boolean OnlySpecialCall)
FileCluster
.
exists()
returns false. This instance
describes a File object only, it does not access to the file system.
The properties of the real file inclusively the length and date can be gotten
from the file system calling #refreshProperties(CallbackEvent)
. This operation may be
invoked in another thread (depending on the device) and may be need some operation time.cluster
- null, then use clusterOfApplication
, elsewhere the special cluster where the file is member of.
It can be null if the parent is given, then the cluster of the parent is used.
It have to be matching to the parent. It do not be null if a parent is not given.
A cluster can be created in an application invoking the constructor FileCluster.FileCluster()
.device
- The device which organizes the access to the file system. It may be null, then the device
will be gotten from the parent or from the sDirP.parent
- The parent file if known or null. If it is null, the sDirP have to be given with the complete absolute path.
If parent is given, this file will be added to the parent as child.sPath
- The path to the directory. If the parent file is given, either it have to be match to or it should be null.
The standard path separator is the slash "/".
A backslash will be converted to slash internally, it isn't distinct from the slash.
If this parameter ends with an slash or backslash and the name is null or empty, this is designated
as an directory descriptor. mDirectory
will be set in flags
.length
- The length of the file. Maybe 0 if unknown.date
- Timestamp of the file. Maybe 0 if unknown.flags
- Properties of the file. Maybe 0 if unknown.oFileP
- an system file Object, may be null.OnlySpecialCall
- public java.nio.file.Path path()
public java.io.File file()
public FileRemote child(java.lang.CharSequence sPathChild)
itsCluster
because it is assumed that it is a file, not a directory.
But all created sub directories of a given local path are registered.sPathChild
- Name or relative pathname of the child.
It can be contain "/" or "\", if more as one level of child should be created. If it has a '/' on end it is created as a sub directory
and registered in its itsCluster
.public FileRemote subdir(java.lang.CharSequence sPathChild)
itsCluster
.sPathChild
- Name or relative pathname of the child.
It can be contain "/" or "\", if more as one level of child should be created. It may have a '/' on end or not.private FileRemote child(java.lang.CharSequence sPathChild, int flags, int length, long dateLastModified, long dateCreation, long dateLastAccess)
itsCluster
sName
- Name of the child or a local path from this to a deeper sub child. If the name ends with a slash
or backslash, the returned instance will be created as sub directory.public FileRemote getChild(java.lang.CharSequence name)
public java.util.Map<java.lang.String,FileRemote> children()
public void cleanChildren()
public static java.util.Map<java.lang.String,FileRemote> createChildrenList()
IndexMultiTable
is better,
because the sorted list is better able to view in debugger.public static boolean setAccessorSelector(FileRemote.FileRemoteAccessorSelector accessorSelectorP)
public static FileRemote.FileRemoteAccessorSelector getAccessorSelector()
public static FileRemote fromFile(java.io.File src)
src
- Any File or FileRemote instance.clusterOfApplication
.public static FileRemote get(FileCluster cluster, java.lang.String filePath)
public static FileRemote get(java.lang.String filePath)
filePath
- if ends with "/" then gets or creates a directory.public static FileRemote getDir(FileCluster cluster, java.lang.CharSequence dirPath)
cluster
- the cluster where the dir should be searcheddirPath
- The directory path where the file is located, given absolute.public static FileRemote getDir(java.lang.CharSequence dirPath)
dirPath
- The directory path where the file is located, given absolute.public static FileRemote getFile(FileCluster cluster, java.lang.CharSequence dirPath, java.lang.CharSequence name)
dirPath
- The directory path where the file is located,name
- The name of the file.public static FileRemote getFile(java.lang.CharSequence dir, java.lang.CharSequence name)
dir
- The directory path where the file is located, given absolute.name
- The name of the file.public FileRemoteAccessor device()
void putNewChild(FileRemote child)
public void setShouldRefresh()
public void setDirShouldRefresh()
public boolean shouldRefresh()
public long setMarked(int mask)
mask
- public long resetMarked(int mask)
mask
- Mask to reset bits.public long resetMarkedRecurs(int mask, int[] nrofFiles)
children()
) which are referred in the FileRemote instance.
This method does not access the files on the file system. It works only with the FileRemote instances.bit
- mask Mask to reset mark bits.nrofFiles
- Output reference, will be incremented for all files which's mark are reseted.
Maybe null, then unused.private long resetMarkedRecurs(int mask, int[] nrofFiles, int recursion)
resetMarkedRecurs(int, int[])
mask
- nrofFiles
- recursion
- public FileMark mark()
FileMark
for this file or null if not marked in any kind.public int getMark()
mark
or 0 if it is not present.getMark
in interface MarkMask_ifc
MarkMask_ifc.getMark()
public int setNonMarked(int mask, java.lang.Object data)
mark
or does nothing if the bit is not present.setNonMarked
in interface MarkMask_ifc
mask
- The bit which presents the source.MarkMask_ifc.setNonMarked(int, java.lang.Object)
public int setNonMarkedRecursively(int mask, java.lang.Object data)
mark
or does nothing if the bit is not present.public int setMarked(int mask, java.lang.Object data)
mark
, creates it if it is not existing yet.setMarked
in interface MarkMask_ifc
mask
- The bit which presents the source.MarkMask_ifc.setMarked(int, java.lang.Object)
public boolean isMarked(int mask)
public void _setProperties(long length, long date, long dateCreation, long dateAccess, int flags, java.lang.Object oFileP)
FileRemoteAccessor
implementation to set properties of this file.
Only because the FileRemoteAccessor
implementation may be organized
in another package, it should be public.length
- date
- flags
- oFileP
- reference to a file Object, for example java.io.File for local files.public void refreshProperties(EventWithDst<FileRemoteProgressEvData,?> evBack)
callback
- if null gets the properties immediately in this thread.public void cmdRemote(FileRemoteCmdEventData.Cmd cmd, FileRemote dstdir, java.lang.String selectFilter, int cycleProgress, int depthWalk, FileRemoteCmdEventData cmdDataArg, EventWithDst<FileRemoteProgressEvData,?> progressEv)
device()
.
It uses the FileRemoteAccessor.cmd(boolean, FileRemoteCmdEventData, EventWithDst)
for access, it's only a wrapper.
But the device()
is clarified before.cmd
- one of the admissible commands for this argument set, all commands which should be executable in a remote device.dstdir
- if necessary a destination, null if cmd does not need a destinationselectFilter
- to select files and dirs per name.cycleProgress
- 0 = progressEv for any file action, else time in ms for progress feedbackdepthWalk
- 0 any deepness, 1 = one child levelcmdDataArg
- If null then create temporary instance internally, else reuse itprogressEv
- event for back information to inform about progress and success.
null then execution is done in the own thread if possible in the own device (local file system).
If it should be executed really on a remote device, then null = no feedback.
Else use of this event instance for feedback and done.
Use EventConsumerAwait.awaitExecution(long, boolean)
for done information.
The EventConsumer
is the instance used as destination for EventWithDst.EventWithDst(String, EventSource, EventConsumer, org.vishia.event.EventThread_ifc, Payload)
.
The instances for the progressEv and its consumer can be created and used persistently.
Note that EventWithDst.cleanData()
should be invoked before call this operation.public void walkLocal(FileRemote dstdir, int markSet, int markSetDir, java.lang.String selectFilter, int selectMask, int depthWalk, FileRemoteWalkerCallback callback, FileRemoteCmdEventData cmdDataArg, int cycleProgress, EventWithDst<FileRemoteProgressEvData,?> progressEv)
dstdir
- a possible destination FileRemote instance, maybe used in callback.markSet
- this bits are set or reset to all selected files. Note: FileMark.resetMark
determines set or reset.markSetDir
- this bits are set or reset to all selected directories. Note: FileMark.resetMark
determines set or reset.selectFilter
- given file filter due to FilepathFilterM
selectMask
- mask for selection dir or files. Note: it is possible to reset exact this bits with markSet and markSetDirdepthWalk
- 0: walk through full deepness, 1: only the first level after this src directory.callback
- execute the callback for any selected dir or file.cmdDataArg
- if not null then this instance is reused as data for walking.cycleProgress
- <0 then do not use an extra thread. 1: event for any selected file and dir for feedback.
>1: time in ms for feedback in a suitable time.progressEv
- if not null then this event is processed for any file or dir or after cycleProcess ms.
For any file and dir the number of files and the sum of bytes are count.public void walkRemote(boolean bWait, FileRemote dirDst, int depth, java.lang.String selectFilter, int cycleProgress, EventWithDst<FileRemoteProgressEvData,?> evProgress)
FileAccessorLocalJava7
or maybe other file access for embedded control.
All arguments are set to an instance of FileRemoteCmdEventData
,
with them device
FileRemoteAccessor.cmd(boolean, FileRemoteCmdEventData, EventWithDst)
is called.bWait
- true then executes the walker in this thread, false then use an extra thread.dirDst
- can be used by the callbackdepth
- depth to walk,markSet
- Bits to mark files while walking throughmarkSetDir
- Bits to mark directories while walking throughselectFilter
- Wildcard mask to select source files. Maybe empty or null, then all files are used.selectMark
- Bits to select from mark maybe manually set before or via other algorithm
It can use some specific bits: FileMark.orWithSelectString
, FileMark.ignoreSymbolicLinks
callback
- null possible. A callback operation set for each file and dir. This defines what to do with the files.cycleProgress
- cycle for progress in ms, 0 means progress for any file.evProgress
- for progress. If bWait is false and evBack is null, no answer is given.public void refreshProperties()
public void refreshPropertiesAndChildren(boolean bWait, EventWithDst<FileRemoteProgressEvData,?> evBack)
FileRemoteAccessor#refreshPropertiesAndChildren(FileRemote, boolean, FileFilter, CallbackFile)
will be called with the given CallbackFile.callback
- maybe null if the callback is not used.bWait
- true then waits for success. On return the walk through is finished and all callback routines are invoked already.
false then this method may return immediately. The callback routines are not invoked. The walk is done in another thread.
Note: Whether or not another thread is used for communication it is not defined with them. It is possible to start another thread
and wait for success, for example if communication with a remote device is necessary.public void refreshAndMark(boolean bWait, int depth, int setMark, int setMarkDir, java.lang.String sMaskSelection, long markSelection, FileRemoteWalkerCallback callbackUser, EventWithDst<FileRemoteProgressEvData,?> evBack)
FileRemoteWalkerCallback#finished(FileRemote, org.vishia.util.SortedTreeWalkerCallback.Counters)
will be invoked.depth
- deepness to entry in the directory tree. Use 0 if all levels should enter.setMark
- bits to set in the mark()
SelectMask.selectMask
for the selected files
If FileMark.resetMark
is set, the bits given in this field will be set to 0.setMarkDir
- bits to set in the mark()
for the directories containing selected files
If FileMark.resetMark
is set, the bits given in this field will be set to 0.sMaskSelection
- file selection mask due to FilepathFilterM
for files using the device FileAccessorLocalJava7
or any other proper select string for other devices.markSelection
- Bits to select with mark bits.
If FileMark.orWithSelectString
is set, this is a OR relation, elsewhere AND with the select string.
OR relation means, a file is selected either with the sMaskSelection or with one of this bits.
AND relation means, one of this bits should be set, and the sMaskSelection should be matching.callbackUser
- a user instance which will be informed on start, any file, any directory and the finish.progressCopyDirTreeWithCallback
- instance for callback.public void refreshAndSearch(int depth, java.lang.String mask, int mark, byte[] search, FileRemoteWalkerCallback callbackUser, EventWithDst<FileRemoteProgressEvData,?> evBack)
FileRemoteWalkerCallback#finished(FileRemote, org.vishia.util.SortedTreeWalkerCallback.Counters)
will be invoked.depth
- at least 1 for enter in the first directory. Use 0 if all levels should entered.mask
- a mask to select directory and filesbits
- to select files by its mark, 0 then select all (ignore mark)callbackUser
- maybe null, a user instance which will be informed on start, any file, any directory and the finish.timeOrderProgress
- maybe null, if given then this callback is informed on any file or directory.public void cmprDirTreeTo(boolean bWait, FileRemote dir2, java.lang.String mask, EventWithDst<FileRemoteProgressEvData,?> evBack)
FileRemoteWalkerCallback#finished(FileRemote, org.vishia.util.SortedTreeWalkerCallback.Counters)
will be invoked.depth
- at least 1 for enter in the first directory. Use 0 if all levels should entered.mask
- a mask to select directory and filesbits
- to select files by its mark, 0 then select all (ignore mark)callbackUser
- maybe null, a user instance which will be informed on start, any file, any directory and the finish.timeOrderProgress
- maybe null, if given then this callback is informed on any file or directory.public void copyDirTreeTo(boolean bWait, FileRemote dirDst, int depth, java.lang.String mask, EventWithDst<FileRemoteProgressEvData,?> evBack)
public void copyDirTreeTo(boolean bWait, FileRemote dirDst, int depth, int markSet, int markSetDir, java.lang.String selectFilter, int selectMask, EventWithDst<FileRemoteProgressEvData,?> evBack)
public void deleteFilesDirTree(boolean bWait, int depth, java.lang.String mask, EventWithDst<FileRemoteProgressEvData,?> evBack)
public java.lang.String copyTo(FileRemote dst, EventWithDst<FileRemoteProgressEvData,?> evBack)
public java.lang.String renameTo(FileRemote dst, EventWithDst<FileRemoteProgressEvData,?> evBack)
public boolean renameTo(java.io.File dst)
File.renameTo(File)
which is not used.
The File dst should be either a FileRemote instance, or it is converted to it for temporary usage.renameTo
in class java.io.File
public void setSymbolicLinkedPath(java.lang.String pathP)
FileRemoteAccessor
implementation to set properties of this file.
Only because the FileRemoteAccessor
implementation may be organized
in another package, it should be public.pathP
- The path where the file is organized.public void setCanonicalAbsPath(java.lang.String pathP)
FileRemoteAccessor
implementation to set properties of this file.
Only because the FileRemoteAccessor
implementation may be organized
in another package, it should be public.pathP
- The absolute canonical path where the file is organized.public boolean sameDevice(FileRemote other)
other
- The other file to checkFileRemoteAccessor
instances of both files using device
.equals(other.device)
returns true.public java.nio.channels.ReadableByteChannel openRead(long passPhrase)
ReadableByteChannel.read(java.nio.ByteBuffer)
invocation returns 0 if there are no bytes available in this moment. An polling invocation later may transfer that bytes.
In this kind a non blocking mode is possible.passPhrase
- a pass phrase if the access is secured.public java.io.InputStream openInputStream(long passPhrase)
passPhrase
- a pass phrase if the access is secured.public java.io.OutputStream openOutputStream(long passPhrase)
passPhrase
- a pass phrase if the access is secured.public java.nio.channels.WritableByteChannel openWrite(long passPhrase)
passPhrase
- a pass phrase if the access is secured.public long length()
length
in class java.io.File
public long lastModified()
lastModified
in class java.io.File
public long creationTime()
public long lastAccessTime()
public boolean setLastModified(long time)
setLastModified
in class java.io.File
public java.lang.Object oFile()
public void setFileObject(java.lang.Object oFile)
public int getFlags()
public java.lang.String getName()
getName
in interface TreeNodeNamed_ifc
getName
in class java.io.File
public java.lang.String getParent()
getParent
in class java.io.File
File.getParent()
public java.lang.String getPath()
getCanonicalPath()
is:
The canonical path under Unix-Systems (linux) is the linked path.
The return path of this routine is the path without dissolving symbolic links.getPath
in class java.io.File
public java.lang.CharSequence getPathChars()
getPath()
for files, but ends with '/' if this is a directory.
It is very sensible and useful to dedicate a path to an existing directory with ending '/'.
It does not build a String from a new StringBuilder.public java.lang.CharSequence getDirChars()
public java.lang.StringBuilder setPathTo(java.lang.StringBuilder ret)
public java.lang.String getCanonicalPath()
getCanonicalPath
in class java.io.File
public java.lang.CharSequence isChild(java.lang.CharSequence path)
path
- Any path may contain /../public java.lang.CharSequence isParent(java.lang.CharSequence path)
path
- Any path may contain /../public FileRemote getParentFile()
sDir
.getParentFile
in class java.io.File
public boolean isTested()
public boolean isTested(long since)
since
- A milliseconds after 1970public boolean exists()
#refreshProperties(CallbackEvent)
is called yet. But if the file was refreshed already,
the existing flag is returned only. To assure that the existing of the file is correct,
call #refreshProperties(CallbackEvent)
before this call on a proper time.
Note that an invocation of File.exists()
may have the same problem. The file
may exist in the time of this call, but it may not exist ever more in the future if the application
will deal with it. Usage of a file for opening a reader or writer without Exception is the only one
assurance whether the file exists really. Note that a deletion of an opened file will be prevent
from the operation system.exists
in class java.io.File
File.exists()
public boolean isFile()
isFile
in class java.io.File
File.isFile()
public boolean isHidden()
isHidden
in class java.io.File
File.isFile()
public boolean isDirectory()
#refreshProperties(CallbackEvent)
call before this call
has detected that it is an directory.isDirectory
in class java.io.File
File.isDirectory()
public boolean isRoot()
public boolean canWrite()
File.canWrite()
canWrite
in class java.io.File
public boolean canRead()
File.canRead()
canRead
in class java.io.File
public boolean canExecute()
File.canExecute()
canExecute
in class java.io.File
public int getFlagsTested()
mCanRead
etc.public boolean isSymbolicLink()
public java.lang.String getAbsolutePath()
getAbsolutePath
in class java.io.File
public FileRemote[] listFiles()
listFiles
in class java.io.File
If the children files are gotten from the maybe remote file system, this method returns immediately
with that result. But it may be out of date. The user can call {@link #refreshPropertiesAndChildren(CallbackEvent)}
to get the new situation.
If the children are not gotten up to now they are gotten yet. The method blocks until the information is gotten,
see {@link FileRemoteAccessor#refreshFilePropertiesAndChildren(FileRemote, EventCmdPingPongType)} with null as event parameter.
public java.io.File[] listFiles(java.io.FileFilter filter)
listFiles
in class java.io.File
public boolean createNewFile() throws java.io.IOException
createNewFile
in class java.io.File
java.io.IOException
public boolean delete()
delete
in class java.io.File
public void delete(EventWithDst<FileRemoteProgressEvData,?> evBack)
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method.backEvent
- The event for success. If null, delete in the same thread in the local file system.public boolean mkdir()
#mkdir(boolean, CallbackEvent)
.
For local file system see File.mkdir()
.mkdir
in class java.io.File
public boolean mkdirs()
#mkdir(boolean, CallbackEvent)
.
For local file system see File.mkdir()
.mkdirs
in class java.io.File
public java.lang.String mkdir(boolean recursively, EventWithDst<FileRemoteProgressEvData,FileRemoteCmdEventData> evBack)
recursively
- Creates necessary but nonexistent parent directories. Note that if this
operation fails it may have succeeded in creating some of the necessary
parent directories.evback
- If given this routine does not wait. Instead the success will be sent with the given evback
to the given destination routine given in its constructor CallbackEvent#CallbackEvent(EventConsumer, EventTimerThread, EventSource)
.
If not given this routine waits till execution, see mkdir()
@Deprecated public void check(java.lang.String sFiles, java.lang.String sWildcardSelection, FileRemoteProgressEvData evback)
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method in the other execution thread
or communication receiving thread.sFiles
- Maybe null or empty. If given, some file names separated with ':' or " : " should be used
in this directory to check and select.sWildcardSelection
- Maybe null or empty. If given, it is the select mask for files in directories.evback
- The event instance for success. It can be contain a ready-to-use FileRemoteCmdEventData
as its opponent. then that is used.public void copyChecked(java.lang.String pathDst, java.lang.String nameModification, int mode, FileRemoteWalkerCallback callbackUser, FileRemoteProgressEvData timeOrderProgress)
this
is the dir or file as root for copy to the given pathDst.
The files to copy are marked in this directory or it is this file.
FileRemoteProgressEvData
is used. This timeOrder should be created as overridden time order
in the applications space with the application specific EventTimerThread_ifc
instance. Especially it can be used
in a graphical environment. See there to show a sequence diagram.
pathDst
- String given destination for the copynameModification
- Modification for each name. null then no modification. TODOmode
- One of the bits modeCopyCreateYes
etc.callbackUser
- Maybe null, elsewhere on every directory and file which is finished to copy a callback is invoked.timeOrderProgress
- may be null, to show the progress of copy.public void copyTo(FileRemote dst, EventWithDst<FileRemoteProgressEvData,?> evBack, int mode)
modeCopyReadOnlyMask
modeCopyReadOnlyAks
: Send a callback event with the file name, wait for answer
FileRemoteCmdEventData
with FileRemoteCmdEventData.Cmd.copyChecked
to the destination. Before that the destination
for the event is set with calling of FileRemoteAccessor#prepareCmdEvent(CallbackEvent)
.
That completes the given FileRemote.CallbackEvent
with the necessary FileRemoteCmdEventData
and its correct destination EventConsumer
.
FileRemote.CallbackEvent
. After any status message was received the FileRemoteCmdEventData
gotten as EventCmdPingPongType#getOpponent()
from the received FileRemote.CallbackEvent
can be used to influence the copy process:
The commands of the callback are:
CallbackCmd#done
: The last callback to designate the finish of succession.
CallbackCmd#askDstNotAbletoOverwr
: The destination file exists and it is readonly. It can't be set writeable
though the modeCopyReadOnlyOverwrite
designation was sent in the mode argument.
CallbackCmd#askDstOverwr
: The destination file exits.
Because modeCopyExistAsk
is given it is the request for asking whether it should be overridden.
CallbackCmd#askDstReadonly
: The destination file exists and it is read only.
Because the modeCopyReadOnlyAks
is given it is the request for asking whether it should be overridden though.
CallbackCmd#askErrorDstCreate
: The destination file does not exists or it exists and it is writeable or set writeable.
Nevertheless the creation or replacement of the file (open for write) fails. It is possible that the medium is read only
or the user has no write access to the directory. Usual the copy of that file should be skipped sending FileRemoteCmdEventData.Cmd.abortCopyFile
.
On the other hand the user can clarify what's happen and then send FileRemoteCmdEventData.Cmd.overwr
to repeat it.
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
CallbackCmd#askDstNotAbletoOverwr
: The destination file
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method.dst
- This file will be created or filled newly. If it is existing but read only,
nothing is copied and an error message is fed back.evback
- The event for status messages and success.public void XXXcopyTo(FileRemote dst, int mode)
public void moveTo(java.lang.String sFiles, FileRemote dst, FileRemoteProgressEvData evback)
FileAccessorLocalJava7.executerCommission
.
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method.sFiles
- maybe null or "". Elsewhere it contains a list of files in this directory
which are to move. The files are separated with dots and can have white spaces before and after the dot
for better readability. Write for example "myfile1.ext : myfile2.ext"
If it is empty, this will be moved to dst.dst
- The destination for move. If dst is a directory this file or directory tree
will be copied into. If dst is an existing file nothing will be done and an error message will be fed back.
If dst does not exist this will be stored as a new file or directory tree as dst.
Note that this can be a file or a directory tree.backEvent
- The event for success.public void search(byte[] search, FileRemoteWalkerCallback callbackUser, FileRemoteProgressEvData timeOrderProgress)
this
is the dir or file as root for copy to the given pathDst.
The files to copy are marked in this directory or it is this file.
FileRemoteProgressEvData
is used. This timeOrder should be created as overridden time order
in the applications space with the application specific EventTimerThread_ifc
instance. Especially it can be used
in a graphical environment. See there to show a sequence diagram.
search
- String given destination for the copynameModification
- Modification for each name. null then no modification. TODOmode
- One of the bits modeCopyCreateYes
etc.callbackUser
- Maybe null, elsewhere on every directory and file which is finished to copy a callback is invoked.timeOrderProgress
- may be null, to show the progress of copy.public void chgProps(boolean bWait, java.lang.String newName, int maskFlags, int newFlags, long newDate, EventWithDst<FileRemoteProgressEvData,?> evBack)
File.setWritable(boolean)
etc. or they are given as parameter.
EventCmdtypeWithBackEvent#opponent
which is type of FileRemoteCmdEventData
to send the request.newName
- A new name for the file. This parameter may be null, then the old name remain.maskFlags
- mask which flags should be changednewFlags
- value of the flag bits.newDate
- if not 0 a new time stamp of fileevback
- The event for success, containing the cmd event as opponent.public void chgPropsRecursive(int maskFlags, int newFlags, long newDate, EventWithDst<FileRemoteProgressEvData,?> evBack)
File.setWritable(boolean)
etc. or they are given as parameter.
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method.newName
- A new name for the file. This parameter may be null, then the old name remain.backEvent
- The event for success.public void countAllFileLength(EventWithDst<FileRemoteProgressEvData,?> evBack)
EventCmdPingPongType#callback
.EventConsumer#processEvent(EventCmdPingPongType)
method.newName
- A new name for the file. This parameter may be null, then the old name remain.backEvent
- The event for success.public void abortAction()
#copyTo(FileRemote, CallbackEvent, int)
, #check(FileRemote, CallbackEvent)
,public java.lang.CharSequence getStateDevice()
public int ident()
public java.lang.String toString()
toString
in class java.io.File
public FileRemote.InternalAccess internalAccess()