Skip to content

Commit

Permalink
fix a issue not working zip version
Browse files Browse the repository at this point in the history
  • Loading branch information
pit-ray committed Feb 23, 2021
1 parent bb53373 commit e6e0b0b
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
cmake --build . --config Debug
xcopy /e /Y ".\\Debug" .
) else (
cmake -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles" -DBIT_TYPE=64 ..
cmake -DCMAKE_BUILD_TYPE=Debug -G "MinGW Makefiles" -DBIT_TYPE=64 -DCCACHE_ENABLE=ON ..
cmake --build . --config Debug
)
cd ..
Expand Down
6 changes: 3 additions & 3 deletions build_resources/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "pit-ray\0"
VALUE "FileDescription", "win-vind (64-bit)\0"
VALUE "FileDescription", "win-vind (32-bit)\0"
VALUE "LegalCopyright", "Copyright (c) 2020 pit-ray\0"
VALUE "InternalName", "win-vind (64-bit)\0"
VALUE "InternalName", "win-vind (32-bit)\0"
VALUE "OriginalFilename", "win-vind.exe\0"
VALUE "ProductName", "win-vind (64bit)\0"
VALUE "ProductName", "win-vind (32bit)\0"
VALUE "ProductVersion", "3.2.1\0"
END
END
Expand Down
21 changes: 16 additions & 5 deletions core/include/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@

#include <string>
#include <fstream>

#if defined(_MSC_VER) && _MSC_VER >= 1500
#include <filesystem>
#endif

#include <windows.h>

#include "i_params.hpp"
#include "utility.hpp"

namespace Path
{
template <typename T>
inline static auto to_u8path(T&& str) {
#if defined(_MSC_VER) && _MSC_VER >= 1500
#pragma warning(disable : 4996)
return std::filesystem::u8path(std::forward<T>(str)) ;
#pragma warning(default : 4996)
#else
return std::forward<T>(str) ;
#endif
}

static inline const auto _get_home_path() {
WCHAR home_path[MAX_PATH] = {0} ;
if(!GetEnvironmentVariableW(L"HOMEPATH", home_path, MAX_PATH)) {
Expand Down Expand Up @@ -43,13 +58,12 @@ namespace Path
return module_path_str.substr(0, root_dir_pos + 1) ;
}() ;
#endif
std::cout << path << std::endl ;
return path ;
}

inline static auto& _is_installer_used() {
static const auto flag = [] {
std::ifstream ifs{std::filesystem::u8path(MODULE_ROOT_PATH() + "default_config\\is_installer_used")} ;
std::ifstream ifs{Path::to_u8path(MODULE_ROOT_PATH() + "default_config\\is_installer_used")} ;
std::string str{} ;
std::getline(ifs, str) ;
return str.front() == 'y' || str.front() == 'Y' ;
Expand Down Expand Up @@ -83,17 +97,14 @@ namespace Path
namespace Default {
inline static const auto& BINDINGS() {
static const auto& obj = MODULE_ROOT_PATH() + "default_config\\bindings.json" ;
std::cout << obj << std::endl ;
return obj ;
}
inline static const auto& SETTINGS() {
static const auto obj = MODULE_ROOT_PATH() + "default_config\\settings.json" ;
std::cout << obj << std::endl ;
return obj ;
}
inline static const auto& UI() {
static const auto& obj = MODULE_ROOT_PATH() + "default_config\\ui.json" ;
std::cout << obj << std::endl ;
return obj ;
}
}
Expand Down
1 change: 0 additions & 1 deletion core/include/utility.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "disable_gcc_warning.hpp"
#include <algorithm>
#include <array>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <stdexcept>
Expand Down
3 changes: 1 addition & 2 deletions core/src/common_bindings/external_app.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "external_app.hpp"

#include <filesystem>
#include <fstream>
#include <iostream>
#include <string>
Expand All @@ -27,7 +26,7 @@ namespace ExAppUtility
mss_t map{} ;

nlohmann::json j ;
std::ifstream ifs(std::filesystem::u8path(Path::SETTINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::SETTINGS())) ;
ifs >> j ;

for(const auto& i : j.at("exapps").at("choices")) {
Expand Down
2 changes: 1 addition & 1 deletion core/src/gui_bindings/jump_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ namespace JumpCursor
_yposs.fill(0) ;
const auto filename = Path::KEYBRD_MAP() ;

std::ifstream ifs(std::filesystem::u8path(filename), ios::in) ;
std::ifstream ifs(Path::to_u8path(filename), ios::in) ;
string buf ;
int lnum = 0 ;

Expand Down
3 changes: 1 addition & 2 deletions core/src/i_params.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "i_params.hpp"

#include <filesystem>
#include <fstream>

#include "disable_gcc_warning.hpp"
Expand All @@ -15,7 +14,7 @@ namespace iParams
static nlohmann::json jp ;
void load_config() {
jp.clear() ;
std::ifstream ifs(std::filesystem::u8path(Path::SETTINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::SETTINGS())) ;
ifs >> jp ;
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/key_binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ namespace KeyBinder
}

void load_config() {
std::ifstream ifs(std::filesystem::u8path(Path::BINDINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::BINDINGS())) ;
nlohmann::json jp ;
ifs >> jp ;
if(jp.empty()) {
Expand Down
8 changes: 4 additions & 4 deletions core/src/msg_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ namespace Logger
const auto efile = log_dir + "error_" + ss.str() + ".log" ;
const auto mfile = log_dir + "message_" + ss.str() + ".log" ;

_init_error_stream.open(std::filesystem::u8path(efile), std::ios::trunc) ;
error_stream.open(std::filesystem::u8path(efile), std::ios::app) ;
_init_error_stream.open(Path::to_u8path(efile), std::ios::trunc) ;
error_stream.open(Path::to_u8path(efile), std::ios::app) ;

_init_msg_stream.open(std::filesystem::u8path(mfile), std::ios::trunc) ;
msg_stream.open(std::filesystem::u8path(mfile), std::ios::app) ;
_init_msg_stream.open(Path::to_u8path(mfile), std::ios::trunc) ;
msg_stream.open(Path::to_u8path(mfile), std::ios::app) ;

//If the log files exists over five, remove old files.
remove_files_over(log_dir + "error_*.log", KEEPING_LOG_COUNT) ;
Expand Down
6 changes: 3 additions & 3 deletions create_bin.bat
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ cpack . -C Release
cd ..
copy /Y ".\\release_32\\setup*" ".\\bin\\*_%1_32bit.exe"

powershell Compress-Archive -Path ".\\bin\\setup_win-vind_%1_64bit.exe" -DestinationPath ".\\bin\\setup_win-vind_%1_64bit.exe.zip"
powershell Compress-Archive -Path ".\\bin\\setup_win-vind_%1_32bit.exe" -DestinationPath ".\\bin\\setup_win-vind_%1_32bit.exe.zip"

@echo Create Zip Version ----------------------------------------------------------
echo n> ".\\default_config\\is_installer_used"

Expand All @@ -46,3 +43,6 @@ powershell Compress-Archive -Path ".\\bin\\win-vind" -DestinationPath ".\\bin\\w

copy /Y ".\\release_32\\win-vind.exe" ".\\bin\\win-vind\\win-vind.exe"
powershell Compress-Archive -Path ".\\bin\\win-vind" -DestinationPath ".\\bin\\win-vind_%1_32bit.zip"

powershell Compress-Archive -Path ".\\bin\\setup_win-vind_%1_64bit.exe" -DestinationPath ".\\bin\\setup_win-vind_%1_64bit.exe.zip"
powershell Compress-Archive -Path ".\\bin\\setup_win-vind_%1_32bit.exe" -DestinationPath ".\\bin\\setup_win-vind_%1_32bit.exe.zip"
7 changes: 3 additions & 4 deletions wxgui/src/io_params.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "io_params.hpp"

#include <fstream>
#include <filesystem>
#include <iomanip>

#include "disable_gcc_warning.hpp"
Expand All @@ -20,7 +19,7 @@ namespace ioParams
static json def_parser{} ;
bool initialize() {
try {
std::ifstream ifs(std::filesystem::u8path(Path::Default::SETTINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::Default::SETTINGS())) ;
ifs >> def_parser ;

load_config() ;
Expand All @@ -35,7 +34,7 @@ namespace ioParams
bool load_config() {
parser.clear() ;
try {
std::ifstream ifs(std::filesystem::u8path(Path::SETTINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::SETTINGS())) ;
ifs >> parser ;
}
catch(const std::exception& e) {
Expand All @@ -47,7 +46,7 @@ namespace ioParams

bool save_config() {
try {
std::ofstream ofs(std::filesystem::u8path(Path::SETTINGS())) ;
std::ofstream ofs(Path::to_u8path(Path::SETTINGS())) ;
ofs << std::setw(4) << parser << std::endl ;
}
catch(const std::exception& e) {
Expand Down
3 changes: 1 addition & 2 deletions wxgui/src/ui_translator.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "ui_translator.hpp"

#include <fstream>
#include <filesystem>

#include "disable_gcc_warning.hpp"
#include <nlohmann/json.hpp>
Expand All @@ -19,7 +18,7 @@ namespace UITrans
static const auto init = [](auto&& filepath) {
json j ;
try {
std::ifstream ifs(std::filesystem::u8path(std::forward<decltype(filepath)>(filepath))) ;
std::ifstream ifs(Path::to_u8path(std::forward<decltype(filepath)>(filepath))) ;
ifs >> j ;
}
catch(const std::exception& e) {
Expand Down
13 changes: 6 additions & 7 deletions wxgui/src/wx_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <unordered_set>
#include <vector>
#include <chrono>
#include <filesystem>

#include "disable_gcc_warning.hpp"
#include <wx/arrstr.h>
Expand Down Expand Up @@ -646,7 +645,7 @@ namespace wxGUI
const auto index = pimpl->func_list->GetSelection() ;
if(index == wxNOT_FOUND) return ;

std::ifstream ifs(std::filesystem::u8path(Path::Default::BINDINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::Default::BINDINGS())) ;
nlohmann::json p{} ;
ifs >> p ;

Expand Down Expand Up @@ -684,7 +683,7 @@ namespace wxGUI
}

const auto& temp_path = temp_dir + "edit_with_vim.json" ;
std::ofstream ofs(std::filesystem::u8path(temp_path)) ;
std::ofstream ofs(Path::to_u8path(temp_path)) ;
ofs << "[\n" ;
write_pretty_one(ofs, target_json) ;
write_usage(ofs) ;
Expand Down Expand Up @@ -728,7 +727,7 @@ namespace wxGUI
}

nlohmann::json new_json ;
std::ifstream ifs(std::filesystem::u8path(temp_path)) ;
std::ifstream ifs(Path::to_u8path(temp_path)) ;
ifs >> new_json ;
target_json = new_json[0] ; //overwrite the inner json object

Expand All @@ -742,7 +741,7 @@ namespace wxGUI
}
BindingsPanel::~BindingsPanel() noexcept = default ;
void BindingsPanel::do_load_config() {
std::ifstream ifs(std::filesystem::u8path(Path::BINDINGS())) ;
std::ifstream ifs(Path::to_u8path(Path::BINDINGS())) ;
ifs >> pimpl->parser ;
}

Expand All @@ -761,7 +760,7 @@ namespace wxGUI
}
}

std::ofstream ofs(std::filesystem::u8path(Path::BINDINGS())) ;
std::ofstream ofs(Path::to_u8path(Path::BINDINGS())) ;
write_pretty_all(ofs, pimpl->parser) ;
}

Expand Down Expand Up @@ -834,7 +833,7 @@ namespace wxGUI
inline static void write_usage(std::ofstream& ofs) {
ofs << ",\n" ;

std::ifstream ifs(std::filesystem::u8path(Path::MODULE_ROOT_PATH() + "resources\\usage.json")) ;
std::ifstream ifs(Path::to_u8path(Path::MODULE_ROOT_PATH() + "resources\\usage.json")) ;
nlohmann::json usage ;
ifs >> usage ;

Expand Down
13 changes: 6 additions & 7 deletions wxgui/src/wxgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <iomanip>
#include <iostream>
#include <string>
#include <filesystem>

#include "disable_gcc_warning.hpp"
#include <wx/cmdline.h>
Expand Down Expand Up @@ -37,7 +36,7 @@ namespace wxGUI
}

inline static bool is_pre_initialized() {
std::ifstream ifs(std::filesystem::u8path(Path::ROOT_PATH() + "is_initialized")) ;
std::ifstream ifs(Path::to_u8path(Path::ROOT_PATH() + "is_initialized")) ;
if(!ifs.is_open()) {
return false ;
}
Expand All @@ -47,7 +46,7 @@ namespace wxGUI
}

inline static void finish_pre_initialization() {
std::ofstream ofs(std::filesystem::u8path(Path::ROOT_PATH() + "is_initialized"), std::ios::trunc) ;
std::ofstream ofs(Path::to_u8path(Path::ROOT_PATH() + "is_initialized"), std::ios::trunc) ;
ofs << "y" ;
}

Expand Down Expand Up @@ -220,7 +219,7 @@ namespace wxGUI
using json = nlohmann::json ;

json dfj ;
std::ifstream def_ifs(std::filesystem::u8path(default_path)) ;
std::ifstream def_ifs(Path::to_u8path(default_path)) ;
def_ifs >> dfj ; //keep old

json olj ;
Expand Down Expand Up @@ -248,12 +247,12 @@ namespace wxGUI
throw std::runtime_error("The format of " + new_path + " is not supported.") ;
}

std::ofstream ofs(std::filesystem::u8path(new_path)) ;
std::ofstream ofs(Path::to_u8path(new_path)) ;
ofs << std::setw(4) << dfj << std::endl ;
} ;

//bindings.json
std::ifstream bindings_ifs(std::filesystem::u8path(Path::BINDINGS())) ;
std::ifstream bindings_ifs(Path::to_u8path(Path::BINDINGS())) ;
if(!bindings_ifs.is_open()) {
overwrite_bindings() ; //does not exist
}
Expand All @@ -265,7 +264,7 @@ namespace wxGUI
}

//settings.json
std::ifstream settings_ifs(std::filesystem::u8path(Path::SETTINGS())) ;
std::ifstream settings_ifs(Path::to_u8path(Path::SETTINGS())) ;
if(!settings_ifs.is_open()) {
overwrite_settings() ; //does not exist
}
Expand Down

0 comments on commit e6e0b0b

Please sign in to comment.