ccs.cpc.impl
Class DiskVFile

java.lang.Object
  extended by ccs.cpc.VFile
      extended by ccs.cpc.impl.DiskVFile
All Implemented Interfaces:
ccs.utils.FileEscapeObserver

 class DiskVFile
extends VFile
implements ccs.utils.FileEscapeObserver


Nested Class Summary
 
Nested classes/interfaces inherited from class ccs.cpc.VFile
VFile.BasicRSSorter, VFile.ExtnSorter, VFile.NameSorter
 
Field Summary
 
Fields inherited from class ccs.cpc.VFile
hitpoints, isSelected
 
Constructor Summary
DiskVFile(java.io.File f, VDevice vd, DiskVFile parent)
           
 
Method Summary
 java.io.File acceptDeferred(java.lang.String leafname)
           
 void acceptReal(java.lang.String leafname, ccs.utils.SwappingBuffer data)
          Directories: copy this data into yourself, creating a VFile for it.
 boolean contains(java.lang.String leafname)
          Directories: have you a file called this?
 void fileEscaped(java.io.File originalf, java.io.File usef, java.lang.Exception e)
          Called when FileKiller is unable to complete the process of wiping a file asynchronously.
 VFile getContainee(java.lang.String leafname)
          Directories: you contain this, we'd like it.
 VFile[] getContents()
          Directories: your contents please.
 VFileMeta getMetadata()
          Return metadata for yourself, if available.
 long getSize()
          Files: return your size, if known, else -1L.
 java.io.File getUnderlyingFile()
           
 boolean isExist()
          Does this file still exist?
 boolean isRealiseInstant()
          For leaf nodes: can you realise a file instantly?
 boolean isWritable()
          whether this vfile can be updated (i.e. virtualised).
 void mkdir(java.lang.String name)
          Directories: create this subdir.
 void postrecursionHook(boolean isRoot)
          Directories: we've finished recursing through you.
 void prerecursionHook(boolean isRoot)
          Directories: prepare to be recursed through.
 ccs.utils.SwappingBuffer realiseAsBuffer()
          For leaf nodes, put your data into a SwappingBuffer.
 java.io.File realiseAsFile()
          For leaf nodes: turn this VFile into a disk File.
 void rename(VFile vf, java.lang.String newname)
          Directories: rename the attached VFile to the name given.
 void virtualiseFromFile(java.io.File f, boolean maybeChanged)
          For leaf nodes, your contents becomes the contents of the supplied physical file (which is usually an updated form of the result of a realise() earlier).
 void virtualiseFromWad(byte[] buf, boolean maybeChanged)
          For leaf nodes, your contents become the contents of the supplied wad.
 void wipe(VFile vf)
          Directories: wipe this VFile and its contents from the face of the world.
 
Methods inherited from class ccs.cpc.VFile
acceptVirtual, createRealiseMonitor, disposeRealiseMonitor, equals, fsanitise, getDecoratedName, getDevice, getDisplayName, getID, getName, getParent, getPath, getTrackingParent, hashCode, hasInternalSeparator, isDir, normaliseName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DiskVFile

DiskVFile(java.io.File f,
          VDevice vd,
          DiskVFile parent)
Method Detail

realiseAsFile

public java.io.File realiseAsFile()
                           throws java.io.IOException,
                                  ccs.LoseException,
                                  ccs.ArghException
Description copied from class: VFile
For leaf nodes: turn this VFile into a disk File. This should only be used where a file is really necessary (e.g. external viewers). For all other uses, prefer realiseAsBuffer to suppress redundant copies. This is an identity operation for DiskVFiles.

Specified by:
realiseAsFile in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

virtualiseFromFile

public void virtualiseFromFile(java.io.File f,
                               boolean maybeChanged)
                        throws java.io.IOException,
                               ccs.LoseException,
                               ccs.ArghException
Description copied from class: VFile
For leaf nodes, your contents becomes the contents of the supplied physical file (which is usually an updated form of the result of a realise() earlier). any copy other than yourself must vanish. maybeChanged is true if the operation for which it was realise might have changed it - if false no update is necessary. A NOP for DiskVFiles, an update() and FileKill for ArchVFiles.

Specified by:
virtualiseFromFile in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

realiseAsBuffer

public ccs.utils.SwappingBuffer realiseAsBuffer()
                                         throws java.io.IOException
Description copied from class: VFile
For leaf nodes, put your data into a SwappingBuffer. The preferred method of access to data.

Specified by:
realiseAsBuffer in class VFile
Throws:
java.io.IOException

isRealiseInstant

public boolean isRealiseInstant()
Description copied from class: VFile
For leaf nodes: can you realise a file instantly? Default false.

Overrides:
isRealiseInstant in class VFile

virtualiseFromWad

public void virtualiseFromWad(byte[] buf,
                              boolean maybeChanged)
                       throws java.io.IOException
Description copied from class: VFile
For leaf nodes, your contents become the contents of the supplied wad. See virtualiseFromFile.

Specified by:
virtualiseFromWad in class VFile
Throws:
java.io.IOException

isWritable

public boolean isWritable()
Description copied from class: VFile
whether this vfile can be updated (i.e. virtualised).

Specified by:
isWritable in class VFile

getSize

public long getSize()
             throws java.io.IOException
Description copied from class: VFile
Files: return your size, if known, else -1L. This is part of what you need to return for getMetadata - hopefully this is slightly lighter weight.

Specified by:
getSize in class VFile
Throws:
java.io.IOException

isExist

public boolean isExist()
Description copied from class: VFile
Does this file still exist?

Specified by:
isExist in class VFile

contains

public boolean contains(java.lang.String leafname)
                 throws java.io.IOException,
                        ccs.LoseException,
                        ccs.ArghException
Description copied from class: VFile
Directories: have you a file called this? Directory with final separator.

Specified by:
contains in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

getContainee

public VFile getContainee(java.lang.String leafname)
                   throws java.io.IOException
Description copied from class: VFile
Directories: you contain this, we'd like it. Directory with final separator.

Specified by:
getContainee in class VFile
Throws:
java.io.IOException

getContents

public VFile[] getContents()
                    throws java.io.IOException,
                           ccs.LoseException,
                           ccs.ArghException
Description copied from class: VFile
Directories: your contents please.

Specified by:
getContents in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

mkdir

public void mkdir(java.lang.String name)
           throws java.io.IOException,
                  ccs.LoseException,
                  ccs.ArghException
Description copied from class: VFile
Directories: create this subdir. The name may or may not have a terminal separator.

Specified by:
mkdir in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

acceptDeferred

public java.io.File acceptDeferred(java.lang.String leafname)
                            throws java.io.IOException
Throws:
java.io.IOException

acceptReal

public void acceptReal(java.lang.String leafname,
                       ccs.utils.SwappingBuffer data)
                throws java.io.IOException,
                       ccs.LoseException,
                       ccs.ArghException
Description copied from class: VFile
Directories: copy this data into yourself, creating a VFile for it. This is the basis for moving / copying. Implementations should tolerate (and strip out) any terminal separator character.

Specified by:
acceptReal in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

wipe

public void wipe(VFile vf)
          throws java.io.IOException,
                 ccs.LoseException,
                 ccs.ArghException
Description copied from class: VFile
Directories: wipe this VFile and its contents from the face of the world. It never existed. If the VFile is a directory, it must be empty.

Specified by:
wipe in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

rename

public void rename(VFile vf,
                   java.lang.String newname)
            throws java.io.IOException,
                   ccs.LoseException,
                   ccs.ArghException
Description copied from class: VFile
Directories: rename the attached VFile to the name given. The VFile might be a folder. The name may or may not have a terminal separator; implementations should tolerate any combination. (Folder with / without, file with / without).

Specified by:
rename in class VFile
Throws:
java.io.IOException
ccs.LoseException
ccs.ArghException

getMetadata

public VFileMeta getMetadata()
                      throws java.io.IOException
Description copied from class: VFile
Return metadata for yourself, if available. Else null.

Specified by:
getMetadata in class VFile
Throws:
java.io.IOException

fileEscaped

public void fileEscaped(java.io.File originalf,
                        java.io.File usef,
                        java.lang.Exception e)
Description copied from interface: ccs.utils.FileEscapeObserver
Called when FileKiller is unable to complete the process of wiping a file asynchronously. If the process fails synchronously, the original call will throw instead.

Specified by:
fileEscaped in interface ccs.utils.FileEscapeObserver
Parameters:
originalf - The original filename.
usef - The temporary file used during wiping.
e - The exception that aborted the wipe..

getUnderlyingFile

public java.io.File getUnderlyingFile()

prerecursionHook

public void prerecursionHook(boolean isRoot)
Description copied from class: VFile
Directories: prepare to be recursed through. The default implementation does nothing (DiskVFiles need this hook). isRoot is set when this VFile is the root of the recursion, i.e. the PWD at the time. The rules for this are a bit different.

Overrides:
prerecursionHook in class VFile

postrecursionHook

public void postrecursionHook(boolean isRoot)
Description copied from class: VFile
Directories: we've finished recursing through you. The default implementation does nothing (DiskVFiles need this hook).

Overrides:
postrecursionHook in class VFile