Class DirAssetPackage

java.lang.Object
com.massifmaps.utils.AssetPackage
com.massifmaps.utils.DirAssetPackage

public class DirAssetPackage extends AssetPackage
An asset package based on a file system directory.
Assets are read directly from the directory, thus the assets can be modified
on the fly without repackaging them into a ZIP archive. This is mostly useful
for style development.
Note: assets and directories with names starting with '.' are ignored.
  • Constructor Details

    • DirAssetPackage

      public DirAssetPackage(String dirPath) throws IOException
      Constructs a directory asset package from the specified directory.
      Parameters:
      dirPath - The full path of the directory containing the assets.
      Throws:
      Exception - If the directory could not be opened.
      IOException
    • DirAssetPackage

      public DirAssetPackage(String dirPath, AssetPackage baseAssetPackage) throws IOException
      Constructs a directory asset package from the specified directory and a fallback asset package.
      Parameters:
      dirPath - The full path of the directory containing the assets.
      baseAssetPackage - The base asset package. If an asset is not found in the directory, base asset package is used.
      Throws:
      Exception - If the directory could not be opened.
      IOException
  • Method Details

    • getDirPath

      public String getDirPath()
      Returns the full path of the directory containing the assets.
      Returns:
      The full path of the directory containing the assets.
    • getLocalAssetNames

      public StringVector getLocalAssetNames()
      Returns the list of assets stored in the directory, ignoring the base asset package.
      Returns:
      The list of asset names stored in the directory.
    • reload

      public void reload()
      Rescans the directory. Use this if assets were added to or removed from the directory
      after the asset package was created.
    • getAssetNames

      public StringVector getAssetNames()
      Description copied from class: AssetPackage
      Returns list of assets in the asset package.
      All listed assets can read using loadAsset API.
      Overrides:
      getAssetNames in class AssetPackage
      Returns:
      List of asset names.
    • loadAsset

      public BinaryData loadAsset(String name)
      Description copied from class: AssetPackage
      Loads the specified asset from the asset package.
      Overrides:
      loadAsset in class AssetPackage
      Parameters:
      name - The asset name to read.
      Returns:
      Asset data, if the asset exists and was successfully read. Null pointer otherwise.