diff options
| author | Henny022p <info@henny022.de> | 2021-11-27 06:50:37 +0100 |
|---|---|---|
| committer | Henny022p <info@henny022.de> | 2021-11-27 06:50:37 +0100 |
| commit | 3bda4ba3e8191a2ae1567eb1832f831ec525731f (patch) | |
| tree | df43b577fb49ce26783547c5fb1ece8ef1b1fe78 /tools/src | |
| parent | 794d5fc97cb01a70c8579dc08962b667edf5a29e (diff) | |
added util lib with file helpers
will have more stuff in the future
Diffstat (limited to 'tools/src')
| -rw-r--r-- | tools/src/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | tools/src/util/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | tools/src/util/dummy.cpp | 4 | ||||
| -rw-r--r-- | tools/src/util/util/file.h | 18 |
4 files changed, 30 insertions, 0 deletions
diff --git a/tools/src/CMakeLists.txt b/tools/src/CMakeLists.txt index eacaa7ff..2b3043d4 100644 --- a/tools/src/CMakeLists.txt +++ b/tools/src/CMakeLists.txt @@ -1,3 +1,6 @@ +# libraries +add_subdirectory(util) +# binaries add_subdirectory(agb2mid) add_subdirectory(aif2pcm) add_subdirectory(asset_processor) diff --git a/tools/src/util/CMakeLists.txt b/tools/src/util/CMakeLists.txt new file mode 100644 index 00000000..eb28af93 --- /dev/null +++ b/tools/src/util/CMakeLists.txt @@ -0,0 +1,5 @@ +add_library(util INTERFACE) +target_include_directories(util INTERFACE .) + +# dummy target to make sure headers compile +add_executable(util_dummy dummy.cpp) diff --git a/tools/src/util/dummy.cpp b/tools/src/util/dummy.cpp new file mode 100644 index 00000000..e64e616c --- /dev/null +++ b/tools/src/util/dummy.cpp @@ -0,0 +1,4 @@ +#include "util/file.h" + +int main() { +} diff --git a/tools/src/util/util/file.h b/tools/src/util/util/file.h new file mode 100644 index 00000000..e7054826 --- /dev/null +++ b/tools/src/util/util/file.h @@ -0,0 +1,18 @@ +#ifndef TOOLS_FILE_H +#define TOOLS_FILE_H + +#include <cstdio> +#include <memory> +#include <string_view> +namespace util { +namespace { +auto file_ptr_deleter = [](std::FILE* file) { std::fclose(file); }; +} + +using file_ptr_t = std::unique_ptr<std::FILE, decltype(file_ptr_deleter)>; + +file_ptr_t open_file(std::string_view filename, std::string_view mode) { + return { std::fopen(filename.data(), mode.data()), file_ptr_deleter }; +} +} // namespace util +#endif // TOOLS_FILE_H |
