GPAK  1.0.0
A general-purpose archive library

◆ gpak_add_file()

GPAK_API int gpak_add_file ( gpak_t _pak,
const char *  _external_path,
const char *  _internal_path 
)
Brief Description:\n Adds a file to a G-PAK archive.

This function adds a new file to the G-PAK archive with the specified _external_path and _internal_path.

Parameters
_pakA pointer to the gpak_t.
_external_pathA string containing the external path of the file to add.
_internal_pathA string containing the internal path of the file within the G-PAK archive.
Returns
An integer value indicating success (0) or failure (-1).

Definition at line 354 of file gpak.c.

355 {
356  pak_entry_t _entry;
357  _entry.compressed_size_ = 0u;
358  _entry.uncompressed_size_ = 0u;
359  _entry.offset_ = 0u;
360  _entry.crc32_ = 0;
361 
362  ++_pak->header_.entry_count_;
363 
364  filesystem_tree_add_file(_pak->root_, _internal_path, _external_path, _entry);
365  return _gpak_make_error(_pak, GPAK_ERROR_OK);
366 }
GPAK_API void filesystem_tree_add_file(filesystem_tree_node_t *_root, const char *_path, const char *_file_path, pak_entry_t _entry)
@ GPAK_ERROR_OK
Definition: gpak_data.h:155
uint32_t crc32_
Definition: gpak_data.h:137
uint32_t uncompressed_size_
Definition: gpak_data.h:135
uint32_t compressed_size_
Definition: gpak_data.h:134
size_t offset_
Definition: gpak_data.h:136
Definition: gpak_data.h:133
uint32_t entry_count_
Definition: gpak_data.h:115
struct filesystem_tree_node * root_
Definition: gpak_data.h:260
pak_header_t header_
Definition: gpak_data.h:258

References gpak_entry_header::compressed_size_, gpak_entry_header::crc32_, gpak_header::entry_count_, filesystem_tree_add_file(), GPAK_ERROR_OK, gpak::header_, gpak_entry_header::offset_, gpak::root_, and gpak_entry_header::uncompressed_size_.