mirror of https://github.com/zeldaret/tmc.git
added util lib with file helpers
will have more stuff in the future
This commit is contained in:
parent
794d5fc97c
commit
3bda4ba3e8
|
@ -1,3 +1,6 @@
|
||||||
|
# libraries
|
||||||
|
add_subdirectory(util)
|
||||||
|
# binaries
|
||||||
add_subdirectory(agb2mid)
|
add_subdirectory(agb2mid)
|
||||||
add_subdirectory(aif2pcm)
|
add_subdirectory(aif2pcm)
|
||||||
add_subdirectory(asset_processor)
|
add_subdirectory(asset_processor)
|
||||||
|
|
|
@ -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)
|
|
@ -0,0 +1,4 @@
|
||||||
|
#include "util/file.h"
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
}
|
|
@ -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
|
Loading…
Reference in New Issue