# HG changeset patch # User David Demelier # Date 1665836398 -7200 # Node ID b12e13e7a3855c232191df8291d2ebf4184c72cb # Parent 35dd2068b4ab351566791ef7509c134b8737fdc5 core: remove VFS diff -r 35dd2068b4ab -r b12e13e7a385 GNUmakefile --- a/GNUmakefile Sat Oct 15 14:17:11 2022 +0200 +++ b/GNUmakefile Sat Oct 15 14:19:58 2022 +0200 @@ -10,7 +10,6 @@ INCDIR ?= $(PREFIX)/include # User options. -WITH_ZIP ?= yes WITH_ZSTD ?= yes WITH_DEBUG ?= no @@ -36,11 +35,6 @@ ZSTD_LIBS ?= $(shell pkg-config --libs libzstd) endif -ifeq ($(WITH_ZIP),yes) -LIBZIP_INCS ?= $(shell pkg-config --cflags libzip) -LIBZIP_LIBS ?= $(shell pkg-config --libs libzip) -endif - ifeq ($(OS),Darwin) OPENAL_LIBS ?= -framework OpenAL else @@ -68,10 +62,6 @@ INCS += $(ZSTD_INCS) endif -ifeq ($(WITH_ZIP),yes) -INCS += $(ZIP_INCS) -endif - OPTS := -Wall -Wextra -pipe ifeq ($(OS),Darwin) @@ -104,10 +94,6 @@ LIBMLK += $(ZSTD_LIBS) endif -ifeq ($(WITH_ZIP),yes) -LIBMLK += $(LIBZIP_LIBS) -endif - .DEFAULT_GOAL := all .SUFFIXES: @@ -133,9 +119,6 @@ ifeq ($(WITH_ZSTD),yes) echo "#define MLK_WITH_ZSTD" >> config.h endif -ifeq ($(WITH_ZIP),yes) - echo "#define MLK_WITH_ZIP" >> config.h -endif # }}} @@ -241,9 +224,6 @@ src/libmlk-core/core/texture.c \ src/libmlk-core/core/trace.c \ src/libmlk-core/core/util.c \ - src/libmlk-core/core/vfs-directory.c \ - src/libmlk-core/core/vfs-zip.c \ - src/libmlk-core/core/vfs.c \ src/libmlk-core/core/window.c \ src/libmlk-core/core/zfile.c LIBMLK_CORE_OBJS := $(LIBMLK_CORE_SRCS:.c=.o) @@ -439,12 +419,7 @@ tests/test-save.c \ tests/test-state.c \ tests/test-tileset.c \ - tests/test-util.c \ - tests/test-vfs-directory.c \ - -ifeq ($(WITH_ZIP),yes) -TESTS += tests/test-vfs-zip.c -endif + tests/test-util.c TESTS_EXE := $(TESTS:.c=) diff -r 35dd2068b4ab -r b12e13e7a385 tests/assets/vfs/data.zip Binary file tests/assets/vfs/data.zip has changed diff -r 35dd2068b4ab -r b12e13e7a385 tests/assets/vfs/directory/hello.txt --- a/tests/assets/vfs/directory/hello.txt Sat Oct 15 14:17:11 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -Hello World! diff -r 35dd2068b4ab -r b12e13e7a385 tests/test-vfs-directory.c --- a/tests/test-vfs-directory.c Sat Oct 15 14:17:11 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * test-vfs-directory.c -- test VFS directory - * - * Copyright (c) 2020-2022 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include - -static void -test_basics_read(void) -{ - struct vfs vfs; - struct vfs_file file; - char data[256] = {0}; - - vfs_directory(&vfs, DIRECTORY "/vfs/directory"); - - DT_EQ_INT(vfs_open(&vfs, &file, "hello.txt", "r"), 0); - DT_EQ_UINT(vfs_file_read(&file, data, sizeof (data)), 13U); - DT_EQ_STR(data, "Hello World!\n"); - - vfs_finish(&vfs); -} - -static void -test_error_notfound(void) -{ - struct vfs vfs; - struct vfs_file file; - - vfs_directory(&vfs, DIRECTORY "/vfs/directory"); - - DT_EQ_INT(vfs_open(&vfs, &file, "notfound.txt", "r"), -1); - - vfs_finish(&vfs); -} - -int -main(void) -{ - DT_RUN(test_basics_read); - DT_RUN(test_error_notfound); - DT_SUMMARY(); -} diff -r 35dd2068b4ab -r b12e13e7a385 tests/test-vfs-zip.c --- a/tests/test-vfs-zip.c Sat Oct 15 14:17:11 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * test-zip-directory.c -- test VFS zip - * - * Copyright (c) 2020-2022 David Demelier - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include - -static void -test_basics_read(void) -{ - struct vfs vfs; - struct vfs_file file; - char data[256] = {0}; - - vfs_zip(&vfs, DIRECTORY "/vfs/data.zip", "r"); - - DT_EQ_INT(vfs_open(&vfs, &file, "texts/hello.txt", "r"), 0); - DT_EQ_UINT(vfs_file_read(&file, data, sizeof (data)), 21U); - DT_EQ_STR(data, "Hello from zip file!\n"); - - vfs_finish(&vfs); -} - -static void -test_error_notfound(void) -{ - struct vfs vfs; - struct vfs_file file; - - vfs_zip(&vfs, DIRECTORY "/vfs/data.zip", "r"); - - DT_EQ_INT(vfs_open(&vfs, &file, "notfound.txt", "r"), -1); - - vfs_finish(&vfs); -} - -int -main(void) -{ - DT_RUN(test_basics_read); - DT_RUN(test_error_notfound); - DT_SUMMARY(); -}