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 java.lang.Object
implements FtpFile

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

Version:
$Rev: 725420 $, $Date: 2008-12-10 21:36:20 +0100 (Wed, 10 Dec 2008) $
Author:
The Apache MINA Project (dev@mina.apache.org)

Constructor Summary
protected NativeFtpFile(java.lang.String fileName, java.io.File file, User user)
          Constructor, internal do not use directly.
 
Method Summary
 java.io.InputStream createInputStream(long offset)
          Create input stream for reading.
 java.io.OutputStream createOutputStream(long offset)
          Create output stream for writing.
 boolean delete()
          Delete file.
 boolean doesExist()
          Does this file exists?
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAbsolutePath()
          Get full name.
 java.lang.String getGroupName()
          Get group name
 long getLastModified()
          Get last modified time.
 int getLinkCount()
          Get link count
 java.lang.String getName()
          Get short name.
 java.lang.String getOwnerName()
          Get file owner.
 java.io.File getPhysicalFile()
          Get the physical file object.
static java.lang.String getPhysicalName(java.lang.String rootDir, java.lang.String currDir, java.lang.String fileName)
          Get the physical canonical file name.
static java.lang.String getPhysicalName(java.lang.String rootDir, java.lang.String currDir, java.lang.String fileName, boolean caseInsensitive)
           
 long getSize()
          Get file size.
 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.
 java.util.List<FtpFile> listFiles()
          List files.
 boolean mkdir()
          Create directory.
 boolean move(FtpFile dest)
          Move file object.
static java.lang.String normalizeSeparateChar(java.lang.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, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeFtpFile

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

Method Detail

getAbsolutePath

public java.lang.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 java.lang.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 java.lang.String getOwnerName()
Get file owner.

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

getGroupName

public java.lang.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 java.io.File getPhysicalFile()
Get the physical file object.


listFiles

public java.util.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 java.io.OutputStream createOutputStream(long offset)
                                        throws java.io.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:
java.io.IOException

createInputStream

public java.io.InputStream createInputStream(long offset)
                                      throws java.io.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:
java.io.IOException

normalizeSeparateChar

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


getPhysicalName

public static final java.lang.String getPhysicalName(java.lang.String rootDir,
                                                     java.lang.String currDir,
                                                     java.lang.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 java.lang.String getPhysicalName(java.lang.String rootDir,
                                                     java.lang.String currDir,
                                                     java.lang.String fileName,
                                                     boolean caseInsensitive)

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


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