Download Now
Forums

    Reference EAssetError

    Declared in Codebot.Render.Assets.pas on line 53

    Assets are the files a program loads while it runs, such as fonts, images, and sounds. They are named by their path below the assets folder, with forward slashes, such as 'fonts/roboto.ttf'.
    An asset comes from one of two places:
    A file in the assets folder, which is beside the program. On macOS it
    is also searched for in the folders above the program.
    A dat file, which holds every asset of a program in one file. It is kept
    beside the program and is named after it, such as cardgames.dat.
    A dat file is only used by a program which has set AssetKey, and only if the dat file is there. Without a key, or without a dat file, assets are files in the assets folder. When a dat file is used an asset which is not in it is still looked for in the assets folder.
    Every byte of a dat file is changed with xor by the four bytes of the key, so its contents can not be read without the key. See AssetXor.
    A program makes its own dat file when it is started with --build-dat. The hosts in Codebot.Render.Scenes handle that before they open a window.
    The layout of a dat file, before the xor, with numbers stored low byte first:
    Header 'CDAT', the version as 4 bytes, the number of assets as 4
    bytes, the size of the index as 4 bytes, and the offset of the
    index as 8 bytes
    Data The bytes of each asset, one after the other
    Index For each asset the length of its name as 2 bytes, its name in
    UTF-8, its offset as 8 bytes, and its size as 8 bytes
    Names are compared without regard to case, so a program finds the same assets on every system.
    The working directory is never used to find an asset. Every search starts from the program itself, so a program finds its assets however it was started. The dat file beside the program is looked for first, and then the assets folder beside the program.
      EAssetError = class(Exception);