diff options
-rw-r--r-- | tools/msgenc/Makefile | 18 | ||||
-rw-r--r-- | tools/msgenc/msgenc.cpp | 23 |
2 files changed, 9 insertions, 32 deletions
diff --git a/tools/msgenc/Makefile b/tools/msgenc/Makefile index 05253e8b..2fc4f3a9 100644 --- a/tools/msgenc/Makefile +++ b/tools/msgenc/Makefile @@ -1,20 +1,6 @@ CXXFLAGS := -std=c++17 -O2 -Wall -Wno-switch CFLAGS := -O2 -Wall -Wno-switch -ifeq ($(OS),Windows_NT) -LDFLAGS += -lstdc++fs -else -UNAME_S := $(shell uname -s) -ifeq ($(UNAME_S),Darwin) -LDFLAGS += -lstdc++ -lc++ -lc -else -LDFLAGS += -lstdc++fs -endif -endif - -CXX_SRCS := msgenc.cpp -HEADERS := - .PHONY: all clean all: msgenc @@ -23,5 +9,5 @@ all: msgenc clean: $(RM) msgenc msgenc.exe -msgenc: $(CXX_SRCS) $(HEADERS) - $(CXX) -o $@ $^ $(LDFLAGS) $(CXXFLAGS) +msgenc: msgenc.cpp + $(CXX) $(CXXFLAGS) -o $@ $^ diff --git a/tools/msgenc/msgenc.cpp b/tools/msgenc/msgenc.cpp index cd6cec0c..e28232a6 100644 --- a/tools/msgenc/msgenc.cpp +++ b/tools/msgenc/msgenc.cpp @@ -13,14 +13,6 @@ #include <vector> #include <algorithm> -#if (__GNUC__ <= 7) && !defined _MSC_VER -#include <experimental/filesystem> -namespace fs = std::experimental::filesystem; -#else -#include <filesystem> -namespace fs = std::filesystem; -#endif - struct MsgArcHeader { uint16_t count; @@ -34,9 +26,8 @@ struct MsgAlloc }; using namespace std; -using namespace fs; -string ReadTextFile(path filename) { +string ReadTextFile(string filename) { fstream file(filename); stringstream ss; ss << file.rdbuf(); @@ -46,7 +37,7 @@ string ReadTextFile(path filename) { static map<string, uint16_t> charmap; -void read_charmap(path filename) { +void read_charmap(string filename) { string raw = ReadTextFile(filename); size_t pos, eqpos, last_pos = 0; while (last_pos != string::npos && (pos = raw.find_first_of("\r\n", last_pos)) != string::npos) { @@ -68,14 +59,14 @@ void read_charmap(path filename) { static MsgArcHeader header; vector<MsgAlloc> alloc_table; static vector<string> files; -static vector<string> outfiles; +static vector<u16string> outfiles; -void read_key(path keyfname) { +void read_key(string keyfname) { fstream keyfile(keyfname, ios_base::in | ios_base::binary); keyfile.read((char *)&header.key, 2); } -void read_msgs(path fname) { +void read_msgs(string fname) { string text = ReadTextFile(fname); size_t pos = 0; do { @@ -101,7 +92,7 @@ uint16_t enc_short(uint16_t value, uint16_t & seed) { void encode_messages() { int i = 1; for (auto message : files) { - string encoded; + u16string encoded; uint16_t seed = i * 596947; for (size_t j = 0; j < message.size(); j++) { if (message[j] == '{') { @@ -162,7 +153,7 @@ void encode_messages() { } } -void write_messages(path filename) { +void write_messages(string filename) { ofstream outfile(filename, ios_base::binary); outfile.write((char *)&header, sizeof(header)); outfile.write((char *)alloc_table.data(), sizeof(MsgAlloc) * alloc_table.size()); |