mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-30 15:41:12 +00:00
Add directory support for extract_all
This commit is contained in:
parent
8ecfc51799
commit
aef60b7ec1
1 changed files with 10 additions and 4 deletions
14
pak.c
14
pak.c
|
@ -314,8 +314,15 @@ bool pak_extract_one(pak_file_t *pak, const char *file) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pak_extract_all(pak_file_t *pak) {
|
bool pak_extract_all(pak_file_t *pak, const char *dir) {
|
||||||
size_t itr;
|
size_t itr;
|
||||||
|
|
||||||
|
if (!pak_tree_spawn(dir))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (chdir(dir))
|
||||||
|
return false;
|
||||||
|
|
||||||
for (itr = 0; itr < vec_size(pak->directories); itr++) {
|
for (itr = 0; itr < vec_size(pak->directories); itr++) {
|
||||||
if (!pak_extract_one(pak, pak->directories[itr].name))
|
if (!pak_extract_one(pak, pak->directories[itr].name))
|
||||||
return false;
|
return false;
|
||||||
|
@ -446,15 +453,14 @@ bool pak_close(pak_file_t *pak) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* test extraction */
|
/* test extraction */
|
||||||
int main() {
|
int main() {
|
||||||
pak_file_t *pak = pak_open("pak0.pak", "r");
|
pak_file_t *pak = pak_open("pak0.pak", "r");
|
||||||
if (!pak) abort();
|
if (!pak) abort();
|
||||||
|
|
||||||
pak_extract_all(pak);
|
pak_extract_all(pak, "foo/");
|
||||||
|
|
||||||
pak_close(pak);
|
pak_close(pak);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in a new issue