public final class FileSystem
extends java.lang.Object
asManagedEnvironment(li.cil.oc.api.fs.FileSystem, li.cil.oc.api.fs.Label, li.cil.oc.api.network.EnvironmentHost, java.lang.String, int)
or its overloads will appear as
filesystem components in the component network. Note that the
component's visibility is set to Neighbors per default. If you wish
to change the file system's visibility (e.g. like the disk drive does) you
must cast the environment's node to Component
and set the visibility to the desired value.
Note that these methods should not be called in the pre-init phase,
since the API.fileSystem
may not have been initialized
at that time. Only start calling these methods in the init phase or later.Modifier and Type | Method and Description |
---|---|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
Label label)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
Label label,
EnvironmentHost host,
java.lang.String accessSound)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
Label label,
EnvironmentHost host,
java.lang.String accessSound,
int speed)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
java.lang.String label)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
java.lang.String label,
EnvironmentHost host,
java.lang.String accessSound)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static ManagedEnvironment |
asManagedEnvironment(FileSystem fileSystem,
java.lang.String label,
EnvironmentHost host,
java.lang.String accessSound,
int speed)
Creates a network node that makes the specified file system available via
the common file system driver.
|
static FileSystem |
asReadOnly(FileSystem fileSystem)
Wrap a file system retrieved via one of the from??? methods to
make it read-only.
|
static FileSystem |
fromClass(java.lang.Class<?> clazz,
java.lang.String domain,
java.lang.String root)
Creates a new file system based on the location of a class.
|
static FileSystem |
fromComputerCraft(java.lang.Object mount)
Creates a new file system based on a ComputerCraft mount.
|
static FileSystem |
fromMemory(long capacity)
Creates a new writable file system that resides in memory.
|
static FileSystem |
fromSaveDirectory(java.lang.String root,
long capacity)
Same as
fromSaveDirectory(String, long, boolean) with the
buffered parameter being true, i.e. |
static FileSystem |
fromSaveDirectory(java.lang.String root,
long capacity,
boolean buffered)
Creates a new writable file system in the save folder.
|
public static FileSystem fromClass(java.lang.Class<?> clazz, java.lang.String domain, java.lang.String root)
"/assets/" + domain + "/" + rootIf the class is located in a JAR file, this will create a read-only file system based on that JAR file. If the class file is located in the native file system, this will create a read-only file system first trying from the actual location of the class file, and failing that by searching the class path (i.e. it'll look for a path constructed as described above). If the specified path cannot be located, the creation fails and this returns null.
clazz
- the class whose containing JAR to wrap.domain
- the domain, usually your mod's ID.root
- an optional subdirectory.public static FileSystem fromSaveDirectory(java.lang.String root, long capacity, boolean buffered)
"saves/" + WORLD_NAME + "/opencomputers/" + rootThe first part may differ, in particular for servers. Usually the name will be the address of the node used to represent the file system. Note that by default file systems are "buffered", meaning that any changes made to them are only saved to disk when the world is saved. This ensured that the file system contents do not go "out of sync" when the game crashes, but introduces additional memory overhead, since all files in the file system have to be kept in memory.
root
- the name of the file system.capacity
- the amount of space in bytes to allow being used.buffered
- whether data should only be written to disk when saving.public static FileSystem fromSaveDirectory(java.lang.String root, long capacity)
fromSaveDirectory(String, long, boolean)
with the
buffered parameter being true, i.e. will always create a
buffered file system.root
- the name of the file system.capacity
- the amount of space in bytes to allow being used.public static FileSystem fromMemory(long capacity)
capacity
- the capacity of the file system.public static FileSystem fromComputerCraft(java.lang.Object mount)
mount
- the mount to wrap with a file system.public static FileSystem asReadOnly(FileSystem fileSystem)
fileSystem
- the file system to wrap.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, java.lang.String accessSound, int speed)
fileSystem
- the file system to wrap.label
- the label of the file system.host
- the tile entity containing the file system.accessSound
- the name of the sound effect to play when the file
system is accessed. This has to be the fully
qualified resource name, e.g.
opencomputers:floppy_access.speed
- the speed multiplier for this file system.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, java.lang.String label, EnvironmentHost host, java.lang.String accessSound, int speed)
fileSystem
- the file system to wrap.label
- the label of the file system.host
- the tile entity containing the file system.accessSound
- the name of the sound effect to play when the file
system is accessed. This has to be the fully
qualified resource name, e.g.
opencomputers:floppy_access.speed
- the speed multiplier for this file system.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, EnvironmentHost host, java.lang.String accessSound)
fileSystem
- the file system to wrap.label
- the label of the file system.host
- the tile entity containing the file system.accessSound
- the name of the sound effect to play when the file
system is accessed. This has to be the fully
qualified resource name, e.g.
opencomputers:floppy_access.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, java.lang.String label, EnvironmentHost host, java.lang.String accessSound)
fileSystem
- the file system to wrap.label
- the read-only label of the file system.host
- the tile entity containing the file system.accessSound
- the name of the sound effect to play when the file
system is accessed. This has to be the fully
qualified resource name, e.g.
opencomputers:floppy_access.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label)
fileSystem
- the file system to wrap.label
- the label of the file system.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, java.lang.String label)
fileSystem
- the file system to wrap.label
- the read-only label of the file system.public static ManagedEnvironment asManagedEnvironment(FileSystem fileSystem)
fileSystem
- the file system to wrap.