org.apache.ftpserver.filesystem.nativefs.impl
Class NativeFtpFile

java.lang.Object
  extended by org.apache.ftpserver.filesystem.nativefs.impl.NativeFtpFile
All Implemented Interfaces:
FtpFile

public class NativeFtpFile
extends Object
implements FtpFile

Internal class, do not use directly. This class wraps native file object.

Author:
Apache MINA Project

Constructor Summary
protected NativeFtpFile(String fileName, File file, User user)
          Constructor, internal do not use directly.
 
Method Summary
 InputStream createInputStream(long offset)
          Create input stream for reading.
 OutputStream createOutputStream(long offset)
          Create output stream for writing.
 boolean delete()
          Delete file.
 boolean doesExist()
          Does this file exists?
 boolean equals(Object obj)
          Implements equals by comparing getCanonicalPath() for the underlying file instabnce.
 String getAbsolutePath()
          Get full name.
 String getGroupName()
          Get group name
 long getLastModified()
          Get last modified time.
 int getLinkCount()
          Get link count
 String getName()
          Get short name.
 String getOwnerName()
          Get file owner.
 File getPhysicalFile()
          Get the physical file object.
static String getPhysicalName(String rootDir, String currDir, String fileName)
          Get the physical canonical file name.
static String getPhysicalName(String rootDir, String currDir, String fileName, boolean caseInsensitive)
           
 long getSize()
          Get file size.
 int hashCode()
           
 boolean isDirectory()
          Is it a directory?
 boolean isFile()
          Is it a file?
 boolean isHidden()
          Is a hidden file?
 boolean isReadable()
          Check read permission.
 boolean isRemovable()
          Has delete permission.
 boolean isWritable()
          Check file write permission.
 List<FtpFile> listFiles()
          List files.
 boolean mkdir()
          Create directory.
 boolean move(FtpFile dest)
          Move file object.
static String normalizeSeparateChar(String pathName)
          Normalize separate character.
 boolean setLastModified(long time)
          Set the last modified time stamp of a file
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeFtpFile

protected NativeFtpFile(String fileName,
                        File file,
                        User user)
Constructor, internal do not use directly.

Method Detail

getAbsolutePath

public String getAbsolutePath()
Get full name.

Specified by:
getAbsolutePath in interface FtpFile
Returns:
a path where the path separator is '/' (even if the operating system uses another character as path separator).

getName

public String getName()
Get short name.

Specified by:
getName in interface FtpFile
Returns:
the last part of the file path (the part after the last '/').

isHidden

public boolean isHidden()
Is a hidden file?

Specified by:
isHidden in interface FtpFile
Returns:
true if the FtpFile is hidden

isDirectory

public boolean isDirectory()
Is it a directory?

Specified by:
isDirectory in interface FtpFile
Returns:
true if the FtpFile is a directory

isFile

public boolean isFile()
Is it a file?

Specified by:
isFile in interface FtpFile
Returns:
true if the FtpFile is a file, false if it is a directory

doesExist

public boolean doesExist()
Does this file exists?

Specified by:
doesExist in interface FtpFile
Returns:
true if the FtpFile exists

getSize

public long getSize()
Get file size.

Specified by:
getSize in interface FtpFile
Returns:
The size of the FtpFile in bytes

getOwnerName

public String getOwnerName()
Get file owner.

Specified by:
getOwnerName in interface FtpFile
Returns:
The name of the owner of the FtpFile

getGroupName

public String getGroupName()
Get group name

Specified by:
getGroupName in interface FtpFile
Returns:
The name of the group that owns the FtpFile

getLinkCount

public int getLinkCount()
Get link count

Specified by:
getLinkCount in interface FtpFile
Returns:
The number of links for the FtpFile

getLastModified

public long getLastModified()
Get last modified time.

Specified by:
getLastModified in interface FtpFile
Returns:
The timestamp of the last modified time for the FtpFile

setLastModified

public boolean setLastModified(long time)
Set the last modified time stamp of a file

Specified by:
setLastModified in interface FtpFile
Parameters:
time - The last modified time, in milliseconds since the epoch. See File.setLastModified(long).

isReadable

public boolean isReadable()
Check read permission.

Specified by:
isReadable in interface FtpFile
Returns:
true if the FtpFile is readable by the user

isWritable

public boolean isWritable()
Check file write permission.

Specified by:
isWritable in interface FtpFile
Returns:
true if the FtpFile is writable by the user

isRemovable

public boolean isRemovable()
Has delete permission.

Specified by:
isRemovable in interface FtpFile
Returns:
true if the FtpFile is removable by the user

delete

public boolean delete()
Delete file.

Specified by:
delete in interface FtpFile
Returns:
true if the operation was successful

move

public boolean move(FtpFile dest)
Move file object.

Specified by:
move in interface FtpFile
Parameters:
dest - The target FtpFile to move the current FtpFile to
Returns:
true if the operation was successful

mkdir

public boolean mkdir()
Create directory.

Specified by:
mkdir in interface FtpFile
Returns:
true if the operation was successful

getPhysicalFile

public File getPhysicalFile()
Get the physical file object.


listFiles

public List<FtpFile> listFiles()
List files. If not a directory or does not exist, null will be returned.

Specified by:
listFiles in interface FtpFile
Returns:
The List of FtpFiles

createOutputStream

public OutputStream createOutputStream(long offset)
                                throws IOException
Create output stream for writing.

Specified by:
createOutputStream in interface FtpFile
Parameters:
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.
Returns:
An OutputStream used to write to the FtpFile
Throws:
IOException

createInputStream

public InputStream createInputStream(long offset)
                              throws IOException
Create input stream for reading.

Specified by:
createInputStream in interface FtpFile
Parameters:
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.
Returns:
An InputStream used to read the FtpFile
Throws:
IOException

normalizeSeparateChar

public static final String normalizeSeparateChar(String pathName)
Normalize separate character. Separate character should be '/' always.


getPhysicalName

public static final String getPhysicalName(String rootDir,
                                           String currDir,
                                           String fileName)
Get the physical canonical file name. It works like File.getCanonicalPath().

Parameters:
rootDir - The root directory.
currDir - The current directory. It will always be with respect to the root directory.
fileName - The input file name.
Returns:
The return string will always begin with the root directory. It will never be null.

getPhysicalName

public static final String getPhysicalName(String rootDir,
                                           String currDir,
                                           String fileName,
                                           boolean caseInsensitive)

equals

public boolean equals(Object obj)
Implements equals by comparing getCanonicalPath() for the underlying file instabnce. Ignores the fileName and User fields

Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.