public class NativeSshFile extends Object implements SshFile
SshFile.Attribute, SshFile.Permission
Modifier and Type | Field and Description |
---|---|
protected File |
file |
protected String |
fileName |
protected static org.slf4j.Logger |
LOG |
protected NativeFileSystemView |
nativeFileSystemView |
protected String |
userName |
Modifier | Constructor and Description |
---|---|
protected |
NativeSshFile(NativeFileSystemView nativeFileSystemView,
String fileName,
File file,
String userName)
Constructor, internal do not use directly.
|
Modifier and Type | Method and Description |
---|---|
boolean |
create()
Create a new file
|
InputStream |
createInputStream(long offset)
Create input stream for reading.
|
OutputStream |
createOutputStream(long offset)
Create output stream for writing.
|
void |
createSymbolicLink(SshFile destination) |
boolean |
delete()
Delete file.
|
boolean |
doesExist()
Does this file exists?
|
boolean |
equals(Object obj) |
String |
getAbsolutePath()
Get full name.
|
Object |
getAttribute(SshFile.Attribute attribute,
boolean followLinks) |
Map<SshFile.Attribute,Object> |
getAttributes(boolean followLinks) |
long |
getLastModified()
Get last modified time.
|
String |
getName()
Get short name.
|
File |
getNativeFile() |
String |
getOwner()
Get owner name
|
SshFile |
getParentFile()
Get the immediate parent.
|
File |
getPhysicalFile()
Returns the according physical file.
|
static String |
getPhysicalName(String rootDir,
String currDir,
String fileName,
boolean caseInsensitive)
Get the physical canonical file name.
|
long |
getSize()
Get file size.
|
void |
handleClose()
Handle post-handle-close functionality.
|
protected void |
handleUnsupportedAttributes(Collection<SshFile.Attribute> attributes) |
boolean |
isDirectory()
Is it a directory?
|
boolean |
isExecutable()
Check file exec permission.
|
boolean |
isFile()
Is it a file?
|
boolean |
isReadable()
Check read permission.
|
boolean |
isRemovable()
Has delete permission.
|
boolean |
isWritable()
Check file write permission.
|
List<SshFile> |
listSshFiles()
List files.
|
boolean |
mkdir()
Create directory.
|
boolean |
move(SshFile dest)
Move file object.
|
static String |
normalizeSeparateChar(String pathName)
Normalize separate character.
|
String |
readSymbolicLink() |
void |
setAttribute(SshFile.Attribute attribute,
Object value) |
void |
setAttributes(Map<SshFile.Attribute,Object> attributes) |
boolean |
setLastModified(long time)
Set the last modified time stamp of a file
|
String |
toString() |
void |
truncate()
Truncate file to length 0.
|
protected static final org.slf4j.Logger LOG
protected String fileName
protected File file
protected String userName
protected final NativeFileSystemView nativeFileSystemView
protected NativeSshFile(NativeFileSystemView nativeFileSystemView, String fileName, File file, String userName)
nativeFileSystemView
- public File getNativeFile()
public String getAbsolutePath()
getAbsolutePath
in interface SshFile
public String getName()
public String getOwner()
public boolean isDirectory()
isDirectory
in interface SshFile
SshFile
is a directorypublic boolean isFile()
public boolean doesExist()
public long getSize()
public long getLastModified()
getLastModified
in interface SshFile
SshFile
public boolean setLastModified(long time)
setLastModified
in interface SshFile
time
- The last modified time, in milliseconds since the epoch. See File.setLastModified(long)
.public boolean isReadable()
isReadable
in interface SshFile
SshFile
is readable by the userpublic boolean isWritable()
isWritable
in interface SshFile
SshFile
is writable by the userpublic boolean isExecutable()
isExecutable
in interface SshFile
SshFile
is executable by the userpublic boolean isRemovable()
isRemovable
in interface SshFile
SshFile
is removable by the userpublic SshFile getParentFile()
SshFile
getParentFile
in interface SshFile
public boolean delete()
public boolean create() throws IOException
create
in interface SshFile
IOException
- if something wrong happenpublic void truncate() throws IOException
truncate
in interface SshFile
IOException
- if something wrong happenpublic boolean move(SshFile dest)
public boolean mkdir()
public List<SshFile> listSshFiles()
listSshFiles
in interface SshFile
List
of SshFile
spublic OutputStream createOutputStream(long offset) throws IOException
createOutputStream
in interface SshFile
offset
- The number of bytes at where to start writing.
If the file is not random accessible,
any offset other than zero will throw an exception.OutputStream
used to write to the SshFile
IOException
public InputStream createInputStream(long offset) throws IOException
createInputStream
in interface SshFile
offset
- The number of bytes of where to start reading.
If the file is not random accessible,
any offset other than zero will throw an exception.InputStream
used to read the SshFile
IOException
public void handleClose()
SshFile
handleClose
in interface SshFile
public static final String normalizeSeparateChar(String pathName)
public static final String getPhysicalName(String rootDir, String currDir, String fileName, boolean caseInsensitive)
rootDir
- The root directory.currDir
- The current directory. It will always be with respect to the
root directory.fileName
- The input file name.public File getPhysicalFile()
public Map<SshFile.Attribute,Object> getAttributes(boolean followLinks) throws IOException
getAttributes
in interface SshFile
IOException
public void setAttributes(Map<SshFile.Attribute,Object> attributes) throws IOException
setAttributes
in interface SshFile
IOException
protected void handleUnsupportedAttributes(Collection<SshFile.Attribute> attributes)
public Object getAttribute(SshFile.Attribute attribute, boolean followLinks) throws IOException
getAttribute
in interface SshFile
IOException
public void setAttribute(SshFile.Attribute attribute, Object value) throws IOException
setAttribute
in interface SshFile
IOException
public String readSymbolicLink() throws IOException
readSymbolicLink
in interface SshFile
IOException
public void createSymbolicLink(SshFile destination) throws IOException
createSymbolicLink
in interface SshFile
IOException
Copyright © 2008–2018 The Apache Software Foundation. All rights reserved.