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 Detail

      • normalizedRelativePath

        static String normalizedRelativePath​(String path)
      • 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 UUID
        fileMatcher - Match by file name (exact, case sensitive)
        fileWildcardMatcher - Match file by wildcard (?, *)
        modNameMatcher - Match by mod name
        path - Match path
        recursive - 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.