Compare commits
No commits in common. "1f423b1d9b54e8ec2e48b54f5cd8ccbb72ef5052" and "b2dc73148e0732d5c583bc439306cee1ef3d5f76" have entirely different histories.
1f423b1d9b
...
b2dc73148e
4
compile
4
compile
@ -20,7 +20,7 @@ FG_BR_MAGENTA="\033[95"
|
|||||||
FG_BR_CYAN="\033[96"
|
FG_BR_CYAN="\033[96"
|
||||||
FG_BR_WHITE="\033[97"
|
FG_BR_WHITE="\033[97"
|
||||||
|
|
||||||
CC=gcc
|
CC=clang
|
||||||
AR=ar
|
AR=ar
|
||||||
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
|
CFLAGS="-Wall -Werror -pedantic -Iinclude -Iintern/c-cpp-aliases -Iintern/cpath/include "
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ if [[ $BUILD_TYPE == "debug" ]]; then
|
|||||||
else
|
else
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
cp ./include/pak.h dist
|
cp ./include/pak.h dist
|
||||||
CFLAGS+="-O3 -g "
|
CFLAGS+="-O3 "
|
||||||
PCKR_OUT="dist/pckr"
|
PCKR_OUT="dist/pckr"
|
||||||
PAKRD_OUT="dist/libpakrd.a"
|
PAKRD_OUT="dist/libpakrd.a"
|
||||||
fi
|
fi
|
||||||
|
@ -7,9 +7,10 @@ argparser_t parse_args(i32 argc, char *argv[]) {
|
|||||||
return (argparser_t){0};
|
return (argparser_t){0};
|
||||||
}
|
}
|
||||||
|
|
||||||
argparser_t output = {0};
|
argparser_t output = {
|
||||||
output.succeeded = true;
|
.succeeded = true,
|
||||||
output.args = (pckr_args_t){0};
|
.args = (pckr_args_t){0},
|
||||||
|
};
|
||||||
|
|
||||||
realpath(argv[1], output.args.dir);
|
realpath(argv[1], output.args.dir);
|
||||||
realpath(argv[2], output.args.output);
|
realpath(argv[2], output.args.output);
|
||||||
|
@ -40,7 +40,7 @@ i64 darr_add(darr_t **darr, void *item) {
|
|||||||
return INVALID_IDX;
|
return INVALID_IDX;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*darr)->capacity += BASE_CAPACITY;
|
(*darr)->capacity = orig->capacity + BASE_CAPACITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 index = (*darr)->count;
|
u64 index = (*darr)->count;
|
||||||
|
14
src/io.c
14
src/io.c
@ -16,8 +16,8 @@ struct dirwalk {
|
|||||||
u64 count;
|
u64 count;
|
||||||
FILE *current_file;
|
FILE *current_file;
|
||||||
DIR *current_dir;
|
DIR *current_dir;
|
||||||
char dst[PATH_MAX + 1];
|
char dst[PATH_MAX];
|
||||||
DIR *directories[MAX_DIR_DEPTH + 1];
|
DIR *directories[MAX_DIR_DEPTH];
|
||||||
};
|
};
|
||||||
|
|
||||||
u64 get_file_length(FILE *fp) {
|
u64 get_file_length(FILE *fp) {
|
||||||
@ -73,7 +73,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
dirwalk_t *dw = *dirwalk;
|
dirwalk_t *dw = *dirwalk;
|
||||||
|
|
||||||
char tmp[PATH_MAX + 1] = {0};
|
char tmp[PATH_MAX] = {0};
|
||||||
|
|
||||||
dirent_t *ep = NULL;
|
dirent_t *ep = NULL;
|
||||||
stat_t dirstat = {0};
|
stat_t dirstat = {0};
|
||||||
@ -102,7 +102,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
result.reading = true;
|
result.reading = true;
|
||||||
result.fp = dw->current_file;
|
result.fp = dw->current_file;
|
||||||
strncpy(result.name, ep->d_name, NAME_MAX + 1);
|
strncpy(result.name, ep->d_name, NAME_MAX);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
if ((dirstat.st_mode & S_IFDIR) == S_IFDIR) {
|
if ((dirstat.st_mode & S_IFDIR) == S_IFDIR) {
|
||||||
memset(dw->dst, 0, length);
|
memset(dw->dst, 0, length);
|
||||||
|
|
||||||
strncpy(dw->dst, tmp, length + 1);
|
strncpy(dw->dst, tmp, length);
|
||||||
|
|
||||||
dw->directories[(dw->count)++] = opendir(dw->dst);
|
dw->directories[(dw->count)++] = opendir(dw->dst);
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
result.reading = true;
|
result.reading = true;
|
||||||
result.fp = dw->current_file;
|
result.fp = dw->current_file;
|
||||||
strncpy(result.name, ep->d_name, NAME_MAX + 1);
|
strncpy(result.name, ep->d_name, NAME_MAX);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath) {
|
|||||||
|
|
||||||
u64 length = strlen(dw->dst);
|
u64 length = strlen(dw->dst);
|
||||||
|
|
||||||
strcpy(tmp, dw->dst);
|
strncpy(tmp, dw->dst, length);
|
||||||
|
|
||||||
memset(dw->dst, 0, length);
|
memset(dw->dst, 0, length);
|
||||||
|
|
||||||
|
10
src/pak.c
10
src/pak.c
@ -34,11 +34,13 @@ void write_pak(const pak_t *pak, toc_entry_t **toc_entries,
|
|||||||
bool create_asset_pack(const char *dirpath, const char *output) {
|
bool create_asset_pack(const char *dirpath, const char *output) {
|
||||||
bool created = false;
|
bool created = false;
|
||||||
|
|
||||||
char dst[PATH_MAX + 1] = {0};
|
char dst[PATH_MAX] = {0};
|
||||||
|
|
||||||
strcpy(dst, output);
|
u64 output_length = strlen(output);
|
||||||
|
strncpy(dst, output, output_length);
|
||||||
|
|
||||||
strcat(dst, PAK_EXT);
|
u64 ext_length = strlen(PAK_EXT);
|
||||||
|
strncat(dst, PAK_EXT, ext_length);
|
||||||
|
|
||||||
FILE *fp = fopen(dst, "wb");
|
FILE *fp = fopen(dst, "wb");
|
||||||
if (!fp) {
|
if (!fp) {
|
||||||
@ -250,7 +252,7 @@ toc_entry_t *create_toc_entry(const char *name, u64 offset) {
|
|||||||
entry->offset = offset;
|
entry->offset = offset;
|
||||||
entry->length = length + 1;
|
entry->length = length + 1;
|
||||||
|
|
||||||
strcpy(entry->name, name);
|
strncpy(entry->name, name, length);
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user