libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit b55c6c6d902746f2ebfc11be903a2e8ca648979f
parent 0b744e6f0bf79b7556672958c65871221d79def1
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sun, 28 May 2017 15:21:11 +0200

Fix(Packer): Moved a function in Morphux/lib

Diffstat:
Msrc/packer_file.c | 23+----------------------
Mtests/test_packer.c | 15---------------
2 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/src/packer_file.c b/src/packer_file.c @@ -172,27 +172,6 @@ bool get_file_information(packer_file_t *file) { return true; } -FILE *packer_file_to_disk(packer_file_t *file) { - char *tmp = NULL; - - for (tmp = file->fn + 1; *tmp; tmp++) - { - if (*tmp == '/') - { - *tmp = 0; - if (mkdir(file->fn, S_IRWXU) == -1 && errno != EEXIST) - { - *tmp = '/'; - goto open; - } - *tmp = '/'; - } - } - -open: - return fopen(file->fn, "w+"); -} - #define _CHUNK_SIZE 2048 bool packer_file_from_binary_to_disk(const char *content, off_t *ctr) { @@ -207,7 +186,7 @@ bool packer_file_from_binary_to_disk(const char *content, off_t *ctr) { if (file.fn == NULL) return false; - fd = packer_file_to_disk(&file); + fd = recursive_file_open(file.fn); if (fd == NULL) goto cleanup; diff --git a/tests/test_packer.c b/tests/test_packer.c @@ -489,20 +489,6 @@ TEST(packer_extract_archive_1) { return TEST_SUCCESS; } -TEST(packer_file_to_disk) { - packer_file_t *ptr = packer_file_init("one", "/two/"); - - TEST_ASSERT(packer_file_to_disk(ptr) == false, "Error did not raise"); - /* Hardcoding the file name to a wrong one */ - free(ptr->fn); - ptr->fn = strdup("/test"); - - TEST_ASSERT(packer_file_to_disk(ptr) == false, "Error did not raise"); - packer_file_free(ptr); - free(ptr); - return TEST_SUCCESS; -} - TEST(packer_read_archive_header) { packer_t *ctx = NULL; @@ -610,7 +596,6 @@ void register_test_packer(void) { reg_test("packer", packer_file_init); reg_test("packer", packer_extract_archive_1); reg_test("packer", packer_extract_archive_2); - reg_test("packer", packer_file_to_disk); reg_test("packer", packer_read_archive_header); reg_test("packer", packer_create_archive_cleanup); }