File tree 6 files changed +97
-0
lines changed
6 files changed +97
-0
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,11 @@ typedef struct PakAlias {
39
39
40
40
#pragma pack(pop)
41
41
42
+ /**
43
+ * Get pak version from pak buffer.
44
+ * @param void *buffer - pointer to pak.
45
+ * @return uint32_t - pak version.
46
+ */
42
47
#define pakGetVerison (buffer ) (*(uint32_t *)buffer)
43
48
#define PAK_HEADER_SIZE_V4 sizeof(PakHeaderV4)
44
49
#define PAK_HEADER_SIZE_V5 sizeof(PakHeaderV5)
Original file line number Diff line number Diff line change 8
8
9
9
#include "pak_defs.h"
10
10
#include "pak_header.h"
11
+
12
+ /**
13
+ * Package a pak file, returns NULL_File on failure.
14
+ * Note: this would allocate memory.
15
+ * @param MyPakHeader *myHeader - pointer to MyPakHeader struct.
16
+ * @param PakFile *pakResFile - pointer to all resource files.
17
+ * @param PakAlias *pakAlias - pointer to all alias.
18
+ * @return PakFile - the packed file.
19
+ */
11
20
PakFile pakPackFiles (MyPakHeader * myHeader , PakFile * pakResFile ,
12
21
PakAlias * pakAlias );
22
+
23
+ /**
24
+ * Get a single file from pak, returns NULL_File on failure.
25
+ * @param void *pakBuffer - pointer to pak.
26
+ * @param uint16_t *id - target file id.
27
+ * @return PakFile - the target file.
28
+ */
13
29
PakFile pakGetFile (void * pakBuffer , uint16_t id );
30
+
31
+ /**
32
+ * Get all files from pak, returns NULL on failure.
33
+ * Note: this would allocate memory.
34
+ * @param void* buffer - pointer to pak.
35
+ * @return PakFile* - pointer to all files in pak.
36
+ */
14
37
PakFile * pakGetFiles (void * buffer );
15
38
16
39
#endif // __PAK_FILE_H__
Original file line number Diff line number Diff line change 7
7
#include <stdio.h>
8
8
#include <stdlib.h>
9
9
10
+ /**
11
+ * Read a file into memory, returns NULL_File on failure.
12
+ * Note: this would allocate memory.
13
+ * @param const char *fileName - target file name.
14
+ * @return PakFile - target file content.
15
+ */
10
16
PakFile readFile (const char * fileName );
17
+
18
+ /**
19
+ * Write a file to storage, this would overwrite existing file.
20
+ * @param const char *fileName - target file name.
21
+ * @param PakFile file - target file content.
22
+ * @return bool - succeed or not.
23
+ */
11
24
bool writeFile (const char * fileName , const PakFile file );
12
25
13
26
#endif // __PAK_FILE_IO_H__
Original file line number Diff line number Diff line change @@ -13,9 +13,21 @@ typedef struct FileType {
13
13
uint8_t size ;
14
14
} FileType ;
15
15
16
+ /**
17
+ * Generate a FileType, for internal uses only.
18
+ * @param char* type - file extension.
19
+ * @param char* identifer - file header identifer in string.
20
+ * @see pakGetFileType()
21
+ * @return FileType
22
+ */
16
23
#define PAK_GEN_FILE_TYPE (type , identifer ) \
17
24
{type, identifer, sizeof(identifer) - 1}
18
25
26
+ /**
27
+ * Get file extension form a file, returns "" on failure.
28
+ * @param PakFile file - the file to parse.
29
+ * @return char* - pointer to file extension.
30
+ */
19
31
char * pakGetFileType (PakFile file );
20
32
21
33
#endif // __PAK_GET_FILE_TYPE_H__
Original file line number Diff line number Diff line change 5
5
#include <stdio.h>
6
6
#include <strings.h>
7
7
8
+ /**
9
+ * Generate MyPakHeader struct from pak buffer.
10
+ * @param _in_ void *buffer - pointer to pak buffer.
11
+ * @param _out_ MyPakHeader myHeader - target file content.
12
+ * @return bool - succeed or not.
13
+ */
8
14
bool pakParseHeader (void * buffer , MyPakHeader * myHeader );
15
+
16
+ /**
17
+ * Write pak header from MyPakHeader struct to buffer.
18
+ * @param MyPakHeader myHeader - target MyPakHeader struct.
19
+ * @param void *buffer - pointer to target pak buffer.
20
+ * @return unsigned int - pak header size, 0 on failure.
21
+ */
9
22
unsigned int pakWriteHeader (MyPakHeader * myHeader , void * buffer );
23
+
24
+ /**
25
+ * Check if pak format is legal.
26
+ * @param void *buffer - pointer to pak buffer.
27
+ * @param unsigned int size - pak buffer size in bytes.
28
+ * @return bool - succeed or not.
29
+ */
10
30
bool pakCheckFormat (void * buffer , unsigned int size );
11
31
12
32
#endif // __PAK_HEADERS_H__
Original file line number Diff line number Diff line change 18
18
#include "pak_file_io.h"
19
19
#include "pak_get_file_type.h"
20
20
#include "pak_header.h"
21
+
22
+ /**
23
+ * Unpack a pak file to target path.
24
+ * @param void *buffer - pointer to target pak buffer.
25
+ * @param char *outputPath - target path.
26
+ * @return bool - succeed or not.
27
+ */
21
28
bool pakUnpack (void * buffer , char * outputPath );
29
+
30
+ /**
31
+ * Pack a pak file from target index (ini) file,
32
+ * returns NULL_File on failure.
33
+ * Note: this would allocate memory.
34
+ * @param PakFile pakIndex - target pak index file.
35
+ * @param char *path - target path.
36
+ * @return PakFile - packed pak.
37
+ */
22
38
PakFile pakPack (PakFile pakIndex , char * path );
39
+
40
+ /**
41
+ * Count number of specified char in string.
42
+ * @param char *string - target string.
43
+ * @param uint32_t length - target string length.
44
+ * @param char toCount - specified char to count.
45
+ * @return uint32_t - number of specified char.
46
+ */
23
47
uint32_t countChar (char * string , uint32_t length , char toCount );
24
48
25
49
#endif // __PAK_PACKER_UNPACKER_H__
You can’t perform that action at this time.
0 commit comments