diff --git a/FileToCArray.hpp b/FileToCArray.hpp index 8a429b5..8c82cba 100644 --- a/FileToCArray.hpp +++ b/FileToCArray.hpp @@ -227,7 +227,11 @@ class ftca_form : public nana::form { working = true; if(!std::filesystem::exists(inpath)) +#ifdef _MSC_VER throw(std::exception{"Input file does not exist!"}); +#else + throw std::runtime_error("Input file does not exist!"); +#endif auto insize = std::filesystem::file_size(inpath); unsigned width = sizeof(uint64_t); while(insize % width) width /= 2; @@ -244,9 +248,19 @@ class ftca_form : public nana::form } std::ifstream infile{inpath, std::ios::binary}; - if(!infile.good()) throw(std::exception{"Failed to open the input file!"}); + if(!infile.good()) +#ifdef _MSC_VER + throw(std::exception{"Failed to open the input file!"}); +#else + throw std::runtime_error("Failed to open the input file!"); +#endif std::ofstream outfile{outpath}; - if(!outfile.good()) throw(std::exception{"Failed to open the output file!"}); + if(!outfile.good()) +#ifdef _MSC_VER + throw(std::exception{"Failed to open the output file!"}); +#else + throw std::runtime_error("Failed to open the output file!"); +#endif auto name{"arr_" + inpath.filename().u8string()}; for(auto &c : name) if(!isalnum(c)) c = '_'; @@ -276,10 +290,20 @@ class ftca_form : public nana::form prog.inc(); } if(abort) { working = false; return; } - if(outfile.bad()) throw(std::exception{"Failed trying to write to the output file!"}); + if(outfile.bad()) +#ifdef _MSC_VER + throw(std::exception{"Failed trying to write to the output file!"}); +#else + throw std::runtime_error("Failed trying to write to the output file!"); +#endif } - if(infile.bad()) throw(std::exception{"Failed trying to read the input file!"}); + if(infile.bad()) +#ifdef _MSC_VER + throw(std::exception{"Failed trying to read the input file!"}); +#else + throw std::runtime_error("Failed trying to read the input file!"); +#endif outfile.seekp(static_cast(outfile.tellp())-1); if(line_chars_max) outfile << '\n'; diff --git a/FileToCArray_main.cpp b/FileToCArray_main.cpp index 88ebe7d..67c385d 100644 --- a/FileToCArray_main.cpp +++ b/FileToCArray_main.cpp @@ -1,8 +1,11 @@ #include "FileToCArray.hpp" -int main() +int main(int argc, char** argv) { ftca_form fm; +#if defined(__WIN32) || defined(_MSC_VER) + nana::API::window_icon(fm.handle(), nana::paint::image(argv[0])); +#endif fm.show(); nana::exec(); } \ No newline at end of file diff --git a/README.md b/README.md index 50a55c2..3873890 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,27 @@ Protip: if the output file that you choose is the same as the input file, it wil ## Windows binary https://github.com/ErrorFlynn/FileToCArray/releases/download/v1.1/FileToCArray_11.7z + +## Building + +### GNU GCC + +``` +g++ --std=c++17 FileToCArray_main.cpp -lnana -lpng -ljpeg -o FileToCArray +``` + +#### Building on Windows with MinGW/GCC + +If compiling on Windows you will also need to link to some Windows standard libraries: + +``` +g++ --std=c++17 FileToCArray_main.cpp -lnana -lpng -ljpeg -lgdi32 -lcomdlg32 -mwindows -o FileToCArray +``` + +To add an icon resource do the following: + +``` +windres icon_resource.rc -o icon_resource.o + +g++ --std=c++17 FileToCArray_main.cpp icon_resource.o -lnana -lpng -ljpeg -lgdi32 -lcomdlg32 -mwindows -o FileToCArray +``` diff --git a/icon_resource.rc b/icon_resource.rc new file mode 100755 index 0000000..5602376 --- /dev/null +++ b/icon_resource.rc @@ -0,0 +1 @@ +ID_ICON1 ICON "images/icon.ico" diff --git a/images/icon.ico b/images/icon.ico new file mode 100644 index 0000000..63dd9ef Binary files /dev/null and b/images/icon.ico differ diff --git a/images/icon.svg b/images/icon.svg new file mode 100644 index 0000000..df4664d --- /dev/null +++ b/images/icon.svg @@ -0,0 +1,31 @@ + + + + + + + + +