ewe.io
Class FakeFileSystem
java.lang.Object
ewe.data.DataObject
ewe.data.LiveObject
ewe.data.LiveTreeNode
ewe.io.FakeFileSystem
- All Implemented Interfaces:
- Comparable, Copyable, DataUnit, FieldListener, LiveData, MutableTreeNode, TreeNode
- public class FakeFileSystem
- extends LiveTreeNode
A FakeFileSystem is used to simulate a FileSystem, possibly starting from another read-only File
system. The FakeFileSystem provides a File object that can be used to browse and access the
FakeFileSystem using the File methods getNew(), getChild() and list().
Usually you would start the FakeFileSystem with entries found in another file storage system
like a ZipFile or a EweFile. Then the FakeFileSystem would allow data to be written into the
FakeFileSystem - but the data would be written into memory and not into the original system
(e.g. ZipFile).
For example, when a Ewe application is being run in a WebBrowser by a Java VM, upon startup
the VM looks for a file called "_filesystem.zip" on the server. If that file is found it is
used as the start of the FakeFileSystem and the default file system for the application then
becomes that FileSystem. Here is an excerpt from the source code that does this:
try{
ewe.zip.ZipFile zf = new ewe.zip.ZipFile(ewe.sys.Vm.openRandomAccessStream("_filesystem.zip","r"));
System.out.println("Loading virtual file system.");
ewe.zip.ZipEntryFile zef = new ewe.zip.ZipEntryFile(zf);
fileSystem = new ewe.io.FakeFileSystem();
fileSystem.addVolume("Disk1",zef.getNew("/"));
zf.close();
}catch(IOException e){} //No virtual file system found.
The addVolume() method is used to add a volume (simulated root drive) to the FakeFileSystem
and the method getFile() returns a File object that can be used to access the
FakeFileSystem.
| Methods inherited from class ewe.data.LiveTreeNode |
addChild, addressOfChild, addressOfChild, addressOfChild, canExpand, collapse, expand, findNamedChild, getChild, getChildAt, getChildAt, getChildCount, getChildren, getParent, getParent, getSibling, indexOfChild, insertChild, isLeaf, isNamed, removeChild, setParent |
| Methods inherited from class ewe.data.LiveObject |
action, action, addMeToPanel, addObjectToPanel, addToPanel, decode, decoded, decodeFields, enableEditorScrolling, encode, encoded, encodeFields, fieldChanged, fieldChanged, fieldEvent, getEditor, getEditorScroller, getIcon, getName, input, makeNewEditor, runAsApp, textDecode, textEncode |
| Methods inherited from class ewe.data.DataObject |
_getSetField, appendAllFields, compareTo, copied, copyFrom, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getDeclaredFieldValue, getFieldList, getFieldList, getMyFieldList, getNew |
deviceName
public String deviceName
- This is the name of the File system which by default is
"Virtual File System". You can change this to be anything else.
unsortedNames
public PropertyList unsortedNames
sorted
public PropertyList sorted
FakeFileSystem
public FakeFileSystem()
addVolume
public void addVolume(String systemName,
File root)
getFile
public File getFile()
defaultVolume
public String defaultVolume()
sortNames
protected void sortNames()
find
public int find(String name)
findNode
public ewe.io.FakeFileSystem.FileNode findNode(String name)
main
public static void main(String[] args)