public abstract class FilesystemBasedFileImpl extends AbstractFile
Modifier and Type | Field and Description |
---|---|
protected String |
currentFile
Current file if any
|
protected File |
currentRealFile
Current Real File if any
|
protected boolean |
isAppend
Is this file in append mode
|
protected SessionInterface |
session
SessionInterface
|
isReady
Modifier | Constructor and Description |
---|---|
protected |
FilesystemBasedFileImpl(SessionInterface session,
FilesystemBasedDirImpl dir,
String path)
Special constructor for possibly external file
|
protected |
FilesystemBasedFileImpl(SessionInterface session,
FilesystemBasedDirImpl dir,
String path,
boolean append) |
Modifier and Type | Method and Description |
---|---|
boolean |
abortFile()
Try to abort the current transfer if any
|
boolean |
canRead() |
static boolean |
canRead(File file)
Adapt File.canRead() to leverage synchronization error with filesystem
|
boolean |
canWrite() |
void |
clear()
Set empty this FtpFile, mark it unReady.
|
boolean |
closeFile()
Close the current FileInterface
|
boolean |
delete()
Delete the current FileInterface.
|
boolean |
exists() |
static boolean |
exists(File file)
Adapt File.exists() to leverage synchronization error with filesystem
|
DirInterface |
getDir() |
String |
getFile() |
protected File |
getFileFromPath(String path)
Get the File from this path, checking first its validity
|
protected FileInputStream |
getFileInputStream() |
protected FileOutputStream |
getFileOutputStream(boolean append)
Returns the FileOutputStream in Out mode associated with the current
file.
|
long |
getPosition()
Return the current position in the FileInterface.
|
protected RandomAccessFile |
getRandomFile()
Returns the RandomAccessFile in Out mode associated with the current
file.
|
protected String |
getRelativePath(File file)
Get the relative path (without mount point)
|
SessionInterface |
getSession() |
boolean |
isDirectory()
Is the current FileInterface a directory and exists
|
static boolean |
isDirectory(File file)
Adapt File.isDirectory() to leverage synchronization error with filesystem
|
boolean |
isFile()
Is the current FileInterface a file and exists
|
static boolean |
isFile(File file)
Adapt File.isFile() to leverage synchronization error with filesystem
|
boolean |
isInReading() |
boolean |
isInWriting() |
long |
length() |
DataBlock |
readDataBlock()
Read a new block for FileInterface
|
DataBlock |
readDataBlock(byte[] bufferGiven)
Read a new block for FileInterface
|
boolean |
renameTo(String path)
Rename the current FileInterface into a new filename from argument
|
void |
setPosition(long position)
Change the position in the file.
|
void |
writeDataBlock(DataBlock dataBlock)
Function called by the DataNetworkHandler when it receives one DataBlock
(Store like command)
|
checkIdentify, getMarker, restartMarker, retrieve, store
protected final SessionInterface session
protected String currentFile
protected File currentRealFile
protected boolean isAppend
protected FilesystemBasedFileImpl(SessionInterface session, FilesystemBasedDirImpl dir, String path, boolean append) throws CommandAbstractException
session
- dir
- It is not necessary the directory that owns this file.path
- append
- CommandAbstractException
protected FilesystemBasedFileImpl(SessionInterface session, FilesystemBasedDirImpl dir, String path)
session
- dir
- It is not necessary the directory that owns this file.path
- public final void clear() throws CommandAbstractException
FileInterface
clear
in interface FileInterface
clear
in class AbstractFile
CommandAbstractException
public SessionInterface getSession()
public final DirInterface getDir()
protected final File getFileFromPath(String path) throws CommandAbstractException
path
- CommandAbstractException
protected final String getRelativePath(File file)
file
- public static boolean isDirectory(File file)
file
- public boolean isDirectory() throws CommandAbstractException
FileInterface
CommandAbstractException
public static boolean isFile(File file)
file
- public boolean isFile() throws CommandAbstractException
FileInterface
CommandAbstractException
public final String getFile() throws CommandAbstractException
CommandAbstractException
public boolean closeFile() throws CommandAbstractException
FileInterface
CommandAbstractException
public final boolean abortFile() throws CommandAbstractException
FileInterface
CommandAbstractException
public long length() throws CommandAbstractException
CommandAbstractException
public final boolean isInReading()
public final boolean isInWriting()
public static boolean canRead(File file)
file
- public boolean canRead() throws CommandAbstractException
CommandAbstractException
public boolean canWrite() throws CommandAbstractException
CommandAbstractException
public static boolean exists(File file)
file
- public boolean exists() throws CommandAbstractException
CommandAbstractException
public boolean delete() throws CommandAbstractException
FileInterface
CommandAbstractException
public boolean renameTo(String path) throws CommandAbstractException
FileInterface
path
- the new filename (path could be relative or absolute
-
without mount point)CommandAbstractException
public final DataBlock readDataBlock() throws FileTransferException, FileEndOfTransferException
FileInterface
FileTransferException
FileEndOfTransferException
public final DataBlock readDataBlock(byte[] bufferGiven) throws FileTransferException, FileEndOfTransferException
FileInterface
bufferGiven
- use the given buffer to readFileTransferException
FileEndOfTransferException
public final void writeDataBlock(DataBlock dataBlock) throws FileTransferException
FileInterface
FileTransferException
public final long getPosition()
public final void setPosition(long position) throws IOException
position
- the position to setIOException
protected FileInputStream getFileInputStream()
protected RandomAccessFile getRandomFile()
protected FileOutputStream getFileOutputStream(boolean append)
append
- True if the FileOutputStream should be in append
modeCopyright © 2009–2022 Waarp. All rights reserved.