posix
Class File

java.lang.Object
  extended by java.io.File
      extended by posix.File
All Implemented Interfaces:
Serializable, Comparable<File>

public class File
extends File

Extend java.io.File with posix features.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar
 
Constructor Summary
File(File dir, String name)
           
File(String name)
           
File(String dir, String name)
           
 
Method Summary
 int getMode()
          Return the posix file mode.
 Stat getStat()
          Return the posix Stat record for the file.
 long lastAccessed()
          Return the posix last accessed time (atime).
 long lastChanged()
          Return the posix last changed time (ctime).
 boolean setLastAccessed(long atime)
          Set the posix last accessed time (atime).
 void setMode(int mode)
          Set the posix file permission bits.
 void setOwner(int uid, int gid)
          Set the posix file owner and group.
 void setTimes(long atime, long mtime)
          Set last accessed and last modified times.
 
Methods inherited from class java.io.File
canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getName, getParent, getParentFile, getPath, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setLastModified, setReadOnly, toString, toURI, toURL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

File

public File(String name)

File

public File(String dir,
            String name)

File

public File(File dir,
            String name)
Method Detail

lastAccessed

public long lastAccessed()
Return the posix last accessed time (atime).

Returns:
the accessed time in milliseconds since 1970

setLastAccessed

public boolean setLastAccessed(long atime)
Set the posix last accessed time (atime).

Parameters:
atime - the new last accessed time as Java milliseconds since 1970
Returns:
true iff the operation succeeded
Since:
1.2.1

setTimes

public void setTimes(long atime,
                     long mtime)
              throws IOException
Set last accessed and last modified times.

Throws:
IOException - on failure
Since:
1.2.1

lastChanged

public long lastChanged()
Return the posix last changed time (ctime).

Returns:
the changed time in milliseconds since 1970

getMode

public int getMode()
Return the posix file mode.

Returns:
a bitmask of posix file permissions and type

setMode

public void setMode(int mode)
             throws IOException
Set the posix file permission bits. Only the low order 12 bits corresponding to classic posix permisions are set.

Parameters:
mode - the new file permission bits
Throws:
IOException - on failure
Since:
1.2.1

setOwner

public void setOwner(int uid,
                     int gid)
              throws IOException
Set the posix file owner and group.

Parameters:
uid - the new file owner
gid - the new file group
Throws:
IOException - on failure
Since:
1.2.1

getStat

public Stat getStat()
             throws IOException
Return the posix Stat record for the file.

Returns:
the posix Stat record or null
Throws:
IOException - on failure