Interface StorageManager
-
public interface StorageManager
StorageManager manages the storage subsystem to store and load data at runtime. There are 2 types of storage: Runtime data (dynamic) stored and indexed in the client directory in ./storage folder and static storage shipped with mods, shipped under ./storage in the mod folder. Static storage items are read-only.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearFileCache()
void
delete(StorageItemDescriptor item)
Deletes a storage item.byte[]
loadBytes(StorageItemDescriptor item)
Loads the raw bytes from a file<T> T
loadObject(StorageItemDescriptor item, boolean deserializeObjRefs, Class<T> clazz)
Loads an object from storageInputStream
loadStream(StorageItemDescriptor item)
Loads the file as stream.static String
normalizedRelativePath(String path)
List<StorageItemDescriptor>
query(UUID uuidMatcher, String fileMatcher, String fileWildcardMatcher, String modNameMatcher, String path, boolean recursive)
Queries the storage for certain items.
All parameters are optional, multiple criteria are combined with AND
Example to search for a file precisely:void
storeBytes(StorageItemDescriptor item, byte[] data)
Save raw bytes to a filevoid
storeObject(StorageItemDescriptor item, boolean serializeObjRefs, Object obj)
Save an object to a fileOutputStream
storeStream(StorageItemDescriptor item)
Save data file using a stream.void
updateItemDescriptor(StorageItemDescriptor item)
-
-
-
Method Detail
-
query
List<StorageItemDescriptor> query(UUID uuidMatcher, String fileMatcher, String fileWildcardMatcher, String modNameMatcher, String path, boolean recursive)
Queries the storage for certain items.
All parameters are optional, multiple criteria are combined with AND
Example to search for a file precisely:.query(null, "3_new_loc.xml", null, "last-outpost", StorageDefaultLocations.SCENES + "/lo/stages/", false);
- Parameters:
uuidMatcher
- Match by storage item UUIDfileMatcher
- Match by file name (exact, case sensitive)fileWildcardMatcher
- Match file by wildcard (?, *)modNameMatcher
- Match by mod namepath
- Match pathrecursive
- Search recursively from path (or from the root if no path is given)
-
loadBytes
byte[] loadBytes(StorageItemDescriptor item)
Loads the raw bytes from a file- Parameters:
item
- Search for the item first with #query or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)
-
loadStream
InputStream loadStream(StorageItemDescriptor item)
Loads the file as stream. You are responsible to close the stream after use!- Parameters:
item
- Search for the item first with #query or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)
-
loadObject
<T> T loadObject(StorageItemDescriptor item, boolean deserializeObjRefs, Class<T> clazz)
Loads an object from storage- Parameters:
item
- Search for the item first with #query or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)clazz
- Type of the object to load
-
storeBytes
void storeBytes(StorageItemDescriptor item, byte[] data)
Save raw bytes to a file- Parameters:
item
- Search for the item first with #query to overwrite the file or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)
-
storeStream
OutputStream storeStream(StorageItemDescriptor item)
Save data file using a stream. You are responsible to close the stream after use!- Parameters:
item
- Search for the item first with #query to overwrite the file or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)
-
storeObject
void storeObject(StorageItemDescriptor item, boolean serializeObjRefs, Object obj)
Save an object to a file- Parameters:
item
- Search for the item first with #query to overwrite the file or create a new StorageItemDescriptor with this constructor: StorageItemDescriptor(CompatibilityRecord, String, String)
-
delete
void delete(StorageItemDescriptor item)
Deletes a storage item. Static items cannot be deleted.
-
updateItemDescriptor
void updateItemDescriptor(StorageItemDescriptor item)
-
clearFileCache
@RestrictedMethod void clearFileCache()
-
-