Index

Package: Resources

Description

package Resources is

Classes

Resource_File

type Resource_File is tagged limited private;

Primitive operations:

Get_Filename
Get_Packfile
Reference
Unreference

References:

resources.ads:51:10 (declaration)
resources.adb:111:21 (reference)
resources.adb:120:41 (reference)
resources.adb:130:42 (reference)
resources.adb:138:36 (reference)
resources.adb:145:42 (reference)
resources.adb:153:41 (reference)
resources.adb:162:40 (reference)
resources.adb:171:34 (reference)
resources.adb:179:42 (reference)
resources.ads:52:40 (reference)
resources.ads:56:41 (reference)
resources.ads:59:42 (reference)
resources.ads:63:36 (reference)
resources.ads:67:42 (reference)
resources.ads:71:41 (reference)
resources.ads:75:34 (reference)
resources.ads:125:10 (full declaration)
resources.ads:144:40 (reference)
resources.ads:146:42 (reference)
A Resource_File represents a resource file loaded in memory. The contents of the file can be accessed via various methods. Once a Resource_File is closed, its backing data should no longer be relied upon. If the file data is required after the Resource_File must be closed, a copy of the contents should be made. Resource files are cached to avoid the cost of searching and reading from disk each time file is needed but the details of the cache and how/when it is purged are private.

Tasks & Protected

Async_Operation (protected type)

References:

resources.ads:14:20 (declaration)
resources.adb:24:20 (body)
resources.adb:45:9 (label)
resources.adb:50:59 (reference)
resources.ads:28:9 (label)
resources.ads:29:42 (reference)
tiles-libraries.adb:207:31 (reference)
tiles.adb:169:31 (reference)

Called by:

Delete defined at resources.ads:31:15
Tiles.Construct defined at tiles.ads:122:15
Tiles.Libraries.Construct defined at tiles-libraries.ads:128:15
Protected state object useful for asynchronously loading resources.

Types

A_Async_Operation

type A_Async_Operation is access all Async_Operation;

References:

resources.ads:29:10 (declaration)
resources.adb:49:35 (reference)
resources.adb:50:76 (reference)
resources.ads:31:35 (reference)
tiles-libraries.ads:117:25 (reference)
tiles.ads:112:25 (reference)

A_Resource_File

type A_Resource_File is access all Resource_File'Class;

References:

resources.ads:52:10 (declaration)
archives-zip_archives.adb:32:48 (reference)
archives-zip_archives.adb:87:46 (reference)
archives-zip_archives.ads:26:46 (reference)
archives.adb:53:48 (reference)
archives.ads:24:48 (reference)
archives.ads:85:46 (reference)
audio_players-cache.adb:77:86 (reference)
audio_players-cache.ads:36:24 (reference)
audio_players-cache.ads:58:86 (reference)
font_api-alfont_fonts.adb:40:20 (reference)
resources.adb:106:47 (reference)
resources.adb:347:64 (reference)
resources.adb:358:40 (reference)
resources.adb:361:45 (reference)
resources.adb:376:40 (reference)
resources.adb:401:45 (reference)
resources.adb:426:72 (reference)
resources.adb:427:20 (reference)
resources.adb:435:50 (reference)
resources.ads:93:72 (reference)
resources.ads:98:50 (reference)
resources.ads:135:47 (reference)
tiles-libraries-loading.adb:182:21 (reference)
worlds.adb:134:20 (reference)

Constants & Global variables

RESOURCE_ERROR

RESOURCE_ERROR,
    RESOURCE_FORMAT_ERROR : exception;

References:

resources.ads:116:5 (declaration)
audio_players-cache.adb:34:19 (reference)
audio_players-cache.adb:47:19 (reference)
audio_players-cache.adb:153:19 (reference)
audio_players-cache.adb:222:19 (reference)
entities-enemies.adb:18:19 (reference)
entities-items.adb:19:19 (reference)
entities-triggers.adb:22:19 (reference)
entities.adb:73:23 (reference)
entity_factory.adb:40:18 (reference)
font_api.adb:47:19 (reference)
physics-clip_maps.adb:22:19 (reference)
worlds.adb:119:23 (reference)
worlds.adb:241:23 (reference)
entities-enemies-keen4.adb:15:14 (reference)
entities-enemies-keen4.adb:63:14 (reference)
entities-enemies-keen4.adb:112:14 (reference)
entities-enemies-keen4.adb:162:14 (reference)
entities-enemies-keen4.adb:211:14 (reference)
entities-enemies-keen4.adb:260:14 (reference)
entities-enemies-keen4.adb:309:14 (reference)
entities-enemies-keen4.adb:357:14 (reference)
entities-enemies-keen4.adb:405:14 (reference)
entities-items-keen4.adb:23:14 (reference)
entities-items-keen4.adb:81:14 (reference)
entities-items-keen4.adb:140:14 (reference)
entities-items-keen4.adb:199:14 (reference)
entities-items-keen4.adb:258:14 (reference)
entities-items-keen4.adb:316:14 (reference)
entities-items-keen4.adb:374:14 (reference)
entities-items-keen4.adb:433:14 (reference)
entities-items-keen4.adb:492:14 (reference)
entities-items-keen4.adb:551:14 (reference)
entities-items-keen4.adb:609:14 (reference)
entities-items-keen4.adb:668:14 (reference)
entities-items-keen4.adb:727:14 (reference)
entities-sprites-keen4.adb:21:14 (reference)
entities-sprites-keen4.adb:91:14 (reference)
entities-sprites-keen4.adb:163:14 (reference)
entities-sprites-keen4.adb:233:14 (reference)
entities-sprites-keen4.adb:303:14 (reference)
entities-sprites-keen4.adb:373:14 (reference)
entities-sprites-keen4.adb:443:14 (reference)
entities-sprites-keen4.adb:513:14 (reference)
entities-sprites-keen4.adb:583:14 (reference)
entities-sprites-keen4.adb:653:14 (reference)
entities-sprites-keen4.adb:723:14 (reference)
entities-sprites-keen4.adb:793:14 (reference)
entities-sprites-keen4.adb:898:14 (reference)
entities-triggers-keen.adb:22:14 (reference)

RESOURCE_FORMAT_ERROR

RESOURCE_FORMAT_ERROR : exception;

References:

resources.ads:117:5 (declaration)
resources-images.adb:78:19 (reference)

Subprograms & Entries

Async_Operation. Complete

procedure Complete;

References:

resources.ads:18:19 (declaration)
resources.adb:26:19 (body)
resources.adb:29:13 (label)
tiles-libraries-loading.adb:116:27 (reference)
tiles-libraries-loading.adb:131:31 (reference)
tiles.adb:271:28 (reference)

Called by:

Tiles.Libraries.Loading.Loading_Task defined at tiles-libraries-loading.adb:93:15
Tiles.Libraries.Loading.Loading_Task defined at tiles-libraries-loading.adb:93:15
Tiles.Load_Bitmap defined at tiles.ads:136:15
Notifies the object that the operation is complete. This will free up all threads blocking on the Wait entry.

Async_Operation. Is_Complete

function Is_Complete return Boolean;

References:

resources.ads:21:18 (declaration)
resources.adb:33:18 (body)
resources.adb:36:13 (label)
tiles-indices.adb:60:47 (reference)
tiles-libraries.adb:392:31 (reference)
tiles.adb:198:27 (reference)
tiles.adb:251:31 (reference)
tiles.adb:260:31 (reference)

Called by:

Tiles.Get_Bitmap defined at tiles.ads:127:14
Tiles.Indices.Tile_Queue.Remove defined at tiles-indices.ads:123:19
Tiles.Is_Loaded defined at tiles.ads:133:14
Tiles.Load_Bitmap defined at tiles.ads:136:15
Checks the state of the operation without waiting for completion.

Async_Operation. Wait (abstract)

entry Wait;

References:

resources.ads:24:15 (declaration)
resources.adb:40:15 (body)
resources.adb:43:13 (label)
tiles-libraries.adb:399:24 (reference)
tiles.adb:342:24 (reference)

Called by:

Tiles.Libraries.Wait_For_Load defined at tiles-libraries.ads:148:15
Tiles.Wait_For_Load defined at tiles.ads:140:15
Blocks the caller until the operation is complete.

Delete

procedure Delete
( op: in out A_Async_Operation );

References:

resources.ads:31:15 (declaration)
resources.adb:49:15 (body)
resources.adb:53:9 (label)
tiles-libraries.adb:215:9 (reference)
tiles.adb:180:9 (reference)

Called by:

Tiles.Delete defined at tiles.ads:124:15
Tiles.Libraries.Delete defined at tiles-libraries.ads:130:15

Calls:

Resources.Delete.Free defined at resources.adb:50:19
Unchecked_Deallocation defined at a-uncdea.ads:20:15

Loading_Begins

procedure Loading_Begins;

References:

resources.ads:36:15 (declaration)
resources.adb:92:15 (body)
resources.adb:95:9 (label)
tiles-libraries-loading.adb:190:19 (reference)
worlds.adb:139:9 (reference)

Calls:

Resources.Increment defined at resources.adb:58:19

Loading_Ends

procedure Loading_Ends;

References:

resources.ads:38:15 (declaration)
resources.adb:99:15 (body)
resources.adb:102:9 (label)
tiles-libraries-loading.adb:119:23 (reference)
tiles-libraries-loading.adb:133:27 (reference)
tiles-libraries-loading.adb:217:23 (reference)
tiles-libraries-loading.adb:230:23 (reference)
worlds.adb:155:9 (reference)
worlds.adb:162:13 (reference)

Called by:

Tiles.Libraries.Loading.Load_From_Disk defined at tiles-libraries-loading.ads:15:14
Tiles.Libraries.Loading.Load_From_Disk defined at tiles-libraries-loading.ads:15:14
Tiles.Libraries.Loading.Loading_Task defined at tiles-libraries-loading.adb:93:15
Tiles.Libraries.Loading.Loading_Task defined at tiles-libraries-loading.adb:93:15
Worlds.Load_World defined at worlds.ads:56:14
Worlds.Load_World defined at worlds.ads:56:14

Calls:

Resources.Decrement defined at resources.adb:59:19

Get_Address

function Get_Address
( this: access Resource_File )
return Address;

References:

resources.ads:56:14 (declaration)
audio_players-cache.adb:219:75 (dispatching call)
font_api-alfont_fonts.adb:45:61 (dispatching call)
resources.adb:120:14 (body)
resources.adb:126:9 (label)

Called by:

Audio_Players.Cache.Create_Mp3_Sound defined at audio_players-cache.ads:125:14
Font_API.Alfont_Fonts.Construct defined at font_api-alfont_fonts.ads:25:15
Returns the address of the resource file's data. The length of the data can be determined by calling Size.

Get_Filename

function Get_Filename
( this: access Resource_File )
return String;

References:

resources.ads:59:14 (declaration)
archives.adb:54:93 (dispatching call)
audio_players-cache.adb:193:48 (dispatching call)
audio_players-cache.adb:223:66 (dispatching call)
resources.adb:130:14 (body)
resources.adb:133:9 (label)

Called by:

Archives.Load_Archive defined at archives.ads:24:14
Audio_Players.Cache.Create_Mp3_Sound defined at audio_players-cache.ads:125:14
Audio_Players.Cache.Get_Filename defined at audio_players-cache.ads:111:14

Calls:

Support.Paths.Get_Filename defined at support-paths.ads:36:14
To_String defined at a-strunb.ads:65:13
Returns the filename of the resource.

Get_Id

function Get_Id
( this: access Resource_File )
return String;

References:

resources.ads:63:14 (declaration)
archives-zip_archives.adb:91:47 (dispatching call)
resources.adb:138:14 (body)
resources.adb:141:9 (label)
resources.adb:402:63 (dispatching call)
resources.adb:411:49 (dispatching call)
resources.adb:417:45 (dispatching call)

Called by:

Archives.Zip_Archives.Construct defined at archives-zip_archives.ads:25:15
Resources.Unload defined at resources.adb:361:19
Resources.Unload defined at resources.adb:361:19
Resources.Unload defined at resources.adb:361:19

Calls:

To_String defined at a-strunb.ads:65:13
Returns an identifying string comprised of the original filepath and group name used to find the resource.

Get_Packfile

function Get_Packfile
( this: access Resource_File )
return A_Packfile;

References:

resources.ads:67:14 (declaration)
audio_players-cache.adb:145:29 (dispatching call)
resources.adb:145:14 (body)
resources.adb:148:9 (label)

Called by:

Audio_Players.Cache.Construct defined at audio_players-cache.ads:90:15
Returns a packfile reference to the resource. Be sure to close the packfile before unloading the resource.

Get_Stream

procedure Get_Stream
( this: access Resource_File;
strm: out A_Buffer_Stream );

References:

resources.ads:71:15 (declaration)
archives-zip_archives.adb:95:18 (dispatching call)
resources.adb:153:15 (body)
resources.adb:157:9 (label)
worlds.adb:142:22 (dispatching call)

Called by:

Archives.Zip_Archives.Construct defined at archives-zip_archives.ads:25:15
Worlds.Load_World defined at worlds.ads:56:14
Returns a new read-only stream backed by the resource contents. Be sure to close the stream before unloading the resource.

Size

function Size
( this: access Resource_File )
return Unsigned_32;

References:

resources.ads:75:14 (declaration)
archives-zip_archives.adb:94:78 (dispatching call)
audio_players-cache.adb:220:83 (dispatching call)
font_api-alfont_fonts.adb:45:91 (dispatching call)
resources.adb:171:14 (body)
resources.adb:174:9 (label)
resources.adb:389:45 (dispatching call)

Called by:

Archives.Zip_Archives.Construct defined at archives-zip_archives.ads:25:15
Audio_Players.Cache.Create_Mp3_Sound defined at audio_players-cache.ads:125:14
Font_API.Alfont_Fonts.Construct defined at font_api-alfont_fonts.ads:25:15
Resources.Load defined at resources.adb:356:19
Returns the size of the file in bytes;

Load_Resource

function Load_Resource
( filepath: String;
group: String )
return A_Resource_File;

References:

resources.ads:93:14 (declaration)
audio_players-cache.adb:45:26 (reference)
font_api-alfont_fonts.adb:43:21 (reference)
resources.adb:426:14 (body)
resources.adb:431:9 (label)
tiles-libraries-loading.adb:194:21 (reference)
worlds.adb:140:21 (reference)

Called by:

Audio_Players.Cache.Construct defined at audio_players-cache.ads:46:15
Font_API.Alfont_Fonts.Construct defined at font_api-alfont_fonts.ads:25:15
Tiles.Libraries.Loading.Load_From_Disk defined at tiles-libraries-loading.ads:15:14
Worlds.Load_World defined at worlds.ads:56:14

Calls:

Resources.Load defined at resources.adb:356:19
Searches for and loads a resource file, returning a reference to it. The search order for resources files is as follows: 1. filepath (If filepath is an absolute file path) 2. working_dir/filename 3. working_dir/group.zip/filename 4. media_dir/filename 5. media_dir/group.zip/filename (Where 'filename' is the filename taken from 'filepath'.) NULL will be returned if the file is not found or can't otherwise be accessed. Resource files are reference counted, so you must call Unload_Resource when finished with the Resource_File.

Unload_Resource

procedure Unload_Resource
( resource: in out A_Resource_File );

References:

resources.ads:98:15 (declaration)
audio_players-cache.adb:71:9 (reference)
font_api-alfont_fonts.adb:46:13 (reference)
font_api-alfont_fonts.adb:58:13 (reference)
resources.adb:435:15 (body)
resources.adb:440:9 (label)
tiles-libraries-loading.adb:197:13 (reference)
tiles-libraries-loading.adb:228:13 (reference)
worlds.adb:145:13 (reference)
worlds.adb:161:13 (reference)

Calls:

Resources.Unload defined at resources.adb:361:19
Unloads a resource file. Resource files are reference counted so be sure to call this when finished with a Resource_File.

Write_Path

function Write_Path
( filepath: String;
group: String )
return String;

References:

resources.ads:110:14 (declaration)
resources.adb:444:14 (body)
resources.adb:458:9 (label)
resources.ads:112:27 (reference)
worlds.adb:746:39 (reference)

Called by:

Worlds.Save defined at worlds.ads:107:15

Calls:

Normalize_Pathname defined at s-os_lib.ads:420:13
Resources.Find_On_Disk defined at resources.adb:284:14
Support.Paths.Get_Directory defined at support-paths.ads:28:14
Support.Paths.Get_Filename defined at support-paths.ads:36:14
Returns the location where a file can be written to overwrite an existing resource if possible or override an existing resource that is in an archive. The specified file will searched for with the same algorithm as Load_Resource. If the resource file is found and it's not in an archive, its absolute path will be returned. If the file was found in an archive or couldn't be found at all, then the returned path will point to a file of the same name in the executable directory.