Pulsar  3d3a057
bfsar_file.h
Go to the documentation of this file.
1 /**
2  * @file
3  * @brief Sound archive file table access
4  */
5 #pragma once
6 
7 #include <pulsar/bfsar/bfsar.h>
8 
9 /// Sound archive file type
10 typedef enum {
12 
13  /// Sub-file is embedded in the sound archive
14  /** @note Can be embedded directly in the FILE section, or in one of the sound archive groups */
15  PLSR_BFSARFileInfoType_Internal = _PLSR_BFSAR_FILE_IDENTIFIER_INTERNAL,
16 
17  /// Sub-file is external to the archive and referenced by path
18  PLSR_BFSARFileInfoType_External = _PLSR_BFSAR_FILE_IDENTIFIER_EXTERNAL,
20 
21 /// Sound archive external file location
22 typedef struct {
23  char path[FS_MAX_PATH];
25 
26 /// Sound archive internal file location
27 typedef struct {
28  /// Can be `false` in case offset and/or size are not pointing to a file
29  /**
30  * - `false` usually means the file is within a group (and that groups should be scanned to find the actual location)
31  * - Always `true` if returned from plsrBFSARFileScan()
32  */
33  bool valid;
34 
35  u16 id;
36  u32 offset;
37  u32 size;
39 
40 /// Sound archive file information
41 typedef struct {
43  union {
46  };
47  bool fromGroup; ///< `true` if file was found in a group, as opposed to directly stored in the FILE section
48  u32 groupIndex; ///< Group index the file was found in (populated if fromGroup is set to `true`)
50 
51 /// Fetch file information from the specified index in the file table
52 PLSR_RC plsrBFSARFileGet(const PLSR_BFSAR* bfsar, u32 index, PLSR_BFSARFileInfo* out);
53 
54 /// Similar to plsrBFSARFileGet(), but also scans groups for the requested index in case file is internal and has an invalid location
55 PLSR_RC plsrBFSARFileScan(const PLSR_BFSAR* bfsar, u32 index, PLSR_BFSARFileInfo* out);
56 
57 /// Make sound file information less archive dependent (eg: external path become absolute)
59 
60 NX_INLINE u32 plsrBFSARFileCount(const PLSR_BFSAR* bfsar) {
61  return bfsar->fileTable.info.count;
62 }
Sound archive internal file location.
Definition: bfsar_file.h:27
Sound archive external file location.
Definition: bfsar_file.h:22
Sound archive file.
Definition: bfsar.h:34
Unknown.
Definition: bfsar_file.h:11
u32 count
Table entry/block count.
Definition: archive.h:41
PLSR_RC plsrBFSARFileGet(const PLSR_BFSAR *bfsar, u32 index, PLSR_BFSARFileInfo *out)
Fetch file information from the specified index in the file table.
PLSR_RC plsrBFSARFileInfoNormalize(const PLSR_BFSAR *bfsar, PLSR_BFSARFileInfo *soundFileInfo)
Make sound file information less archive dependent (eg: external path become absolute) ...
Sound archive file information.
Definition: bfsar_file.h:41
Sound archive init.
bool fromGroup
true if file was found in a group, as opposed to directly stored in the FILE section ...
Definition: bfsar_file.h:47
u32 groupIndex
Group index the file was found in (populated if fromGroup is set to true)
Definition: bfsar_file.h:48
PLSR_ArchiveTableInfo info
Cached table information.
Definition: archive.h:47
PLSR_RC plsrBFSARFileScan(const PLSR_BFSAR *bfsar, u32 index, PLSR_BFSARFileInfo *out)
Similar to plsrBFSARFileGet(), but also scans groups for the requested index in case file is internal...
Sub-file is embedded in the sound archive.
Definition: bfsar_file.h:15
Sub-file is external to the archive and referenced by path.
Definition: bfsar_file.h:18
u32 PLSR_RC
Result code returned by Pulsar functions.
Definition: types.h:73
bool valid
Can be false in case offset and/or size are not pointing to a file.
Definition: bfsar_file.h:33
PLSR_BFSARFileInfoType
Sound archive file type.
Definition: bfsar_file.h:10