What is FSector?
Short description:
FSector creates separated fs, like window.create for the terminal.
Why should I use FSector?
Here are some examples:
- Sandbox programs
- Virtual machines (mount rom into a directory and create the handle)
- Virtual hard disk drives
- Set ReadOnly (e. g. an OS folder or password files (to prevent setting a password to '' for example))
- Save storage with mounting paths into directories
- handle.mount simulates hard links
- Hierarchy your file systems (e. g. native fs -> Drives/{0} or native fs -> rom/help (i mean the help files))
- Mount disks into other directorys (for example in Drives/{0}/disk)
- Sharing data between programs (by using handle.mount())
- Executing programs relative to their destinations.
- Things i forgot.
Documentation
Spoiler
FSector.create(object parent, string rootDir)The first argument is the parent of your sector created by FSector.create().
By the first call, use fs as a parent.
handle.mount(string source, string destination)
Mounts a path to destination in this instance and for childs of this.
The destination can be read only.
handle.dismount(string path)
Dismounts a path in this instance.
handle.isMounted(string path)
Checks, if a path is mounted in this instance
handle.setReadOnly(string path, bool readOnly)
Set read only or read and write to a directory of this instance.
Load API
To load the API, just dofile the API (it returns the API) or edit:
FSector = {} to
FSector = _ENV
and load it by os.loadAPI().
Example
Spoiler
Example with an inserted disk.
local root= FSector.create(fs, '') -- Creates a fs-handle pointing to /
root.mount('disk', 'rom/disk')
local rom = FSector.create(root, 'rom') -- Creates a fs-handle with root as a parent to import all mounted paths, pointing to /rom.
textutils.tabulate(rom.list 'disk')
sleep(1)
root.dismount 'rom/disk'
textutils.tabulate(rom.list 'disk') -- ERROR: Not a directory
Screenshots
Spoiler
WIP [Work in progress]
Spoiler
handle.find()
They don't find mounted paths yet.
fs.current()
fs.native()
Error Messages
License
Spoiler
The source file contains this license:MIT License
Copyright © 2016 Sewbacca
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.