Mortic comes with a very powerful and flexible filesystem. However, this can be very confusing to people trying to start with mortic when they want to read a simple file. This tutorial serves as an introduction to the FileManager.
All of the code in this tutorial will take place in the pull-down Mortic Console. This is a very powerful tool, and it is never to early to learn how to use it.
This type of filesystem is easiest to learn by example. After this section there will be even more examples, so don't worry.
A Virtual File System is a type of filesystem where actual files are mounted on imaginary directories. However, to start using the file manager, you have to get it:
Now that you have the file manager, you can start to play with it. Our first example lets us access the directory "./data/scripts" from our VFS directory "/scripts":
>>> fs.mountReal("./data/scripts", "/scripts")
>>> file = fs.open("/scripts/test.py")
That last line of code opened the real file "./data/scripts/test.py". Get it? Lets try another one: >>> fs.mountReal("/var/log", "/log")
This lets us access the files in "/var/log" from "/log" inside mortic. Useful, no?
So far you have only seen the Real Mount, or mounting a real directory on an imaginary, VFS directory. However, there is also a Mirror Mount, or mounting an imaginary directory on another one. For example: >>> fs.mountMirror("/log", "/scripts/log")
This lets us access all the files in the VFS path "/log" from "/scripts/log" as well! Neato, huh!
The real power of a VFS comes in when you can make your own mounts by extending mortic::IMount. Clever use of this class can result in the ability to mount zip files on a directory, or accessing a website like a real file. The possibilities are almost endless. I would explain how to make your own mount right here, but it is a very complex topic and is best left for another issue. In the meantime, have fun!
Generated on Sat Dec 30 21:21:59 2006 for mortic by
1.4.4