-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix crash bug in windows and add new filesystem
- Loading branch information
1 parent
acb9dc5
commit 097651d
Showing
8 changed files
with
57 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "3rdparty/filesystem"] | ||
path = 3rdparty/filesystem | ||
url = https://github.com/gulrak/filesystem.git |
Submodule filesystem
added at
3605e8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
cmake_minimum_required(VERSION 2.9) | ||
project(qmc-decoder) | ||
|
||
set(CMAKE_FIND_ROOT_PATH "${PROJECT_SOURCE_DIR}/usr") | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -pipe -std=c++11") | ||
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Android" AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") | ||
|
||
if (MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Od") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17") | ||
else(MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -pipe -std=c++11") | ||
endif() | ||
|
||
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static -pthread -static-libgcc -static-libstdc++") | ||
endif() | ||
find_package(Boost 1.56 REQUIRED COMPONENTS | ||
filesystem) | ||
include_directories(${Boost_INCLUDE_DIRS}) | ||
|
||
include_directories(3rdparty/filesystem/include) | ||
aux_source_directory(src SRC) | ||
add_executable(decoder ${SRC}) | ||
target_link_libraries(decoder Boost::filesystem) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
cd $(dirname $0) | ||
if [ -f decoder ]; then | ||
./decoder | ||
fi |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,31 @@ | ||
/* | ||
* Author: mayusheng - [email protected] | ||
* Last modified: 2020-06-29 10:56 | ||
* Filename: decoder.cpp | ||
* | ||
* Description: qmc file auto decode | ||
* | ||
* | ||
*/ | ||
#include <algorithm> | ||
#include <boost/filesystem.hpp> | ||
#include <iostream> | ||
#include <memory> | ||
#include <regex> | ||
#include <vector> | ||
|
||
#include "seed.hpp" | ||
|
||
namespace fs = boost::filesystem; | ||
#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include) | ||
#if __has_include(<filesystem>) | ||
#define GHC_USE_STD_FS | ||
#include <filesystem> | ||
namespace fs = std::filesystem; | ||
#endif | ||
#endif | ||
#ifndef GHC_USE_STD_FS | ||
#include <ghc/filesystem.hpp> | ||
namespace fs = ghc::filesystem; | ||
#endif | ||
|
||
namespace { | ||
void close_file(std::FILE* fp) { std::fclose(fp); } | ||
|
@@ -31,9 +49,9 @@ smartFilePtr openFile(const std::string& aPath, openMode aOpenMode) { | |
int newSize = MultiByteToWideChar(CP_UTF8, 0, aPath.c_str(), aPath.length(), | ||
const_cast<wchar_t*>(aPath_w.c_str()), | ||
aPath_w.size()); | ||
filePathW.resize(newSize); | ||
std::FILE* fp = | ||
_wfopen(aPath_w.c_str(), aOpenMode == openMode::read ? L"rb" : L"wb"); | ||
aPath_w.resize(newSize); | ||
std::FILE* fp = NULL; | ||
_wfopen_s(&fp, aPath_w.c_str(), aOpenMode == openMode::read ? L"rb" : L"wb"); | ||
#endif | ||
return smartFilePtr(fp, &close_file); | ||
} | ||
|
@@ -114,7 +132,7 @@ int main(int argc, char** argv) { | |
} | ||
|
||
if ((fs::status(fs::path(".")).permissions() & fs::perms::owner_write) == | ||
fs::perms::no_perms) { | ||
fs::perms::none) { | ||
std::cerr << "please check if you have the write permissions on this dir." | ||
<< std::endl; | ||
return -1; | ||
|
@@ -125,7 +143,7 @@ int main(int argc, char** argv) { | |
auto file_path = p.path().string(); | ||
|
||
if ((fs::status(p).permissions() & fs::perms::owner_read) != | ||
fs::perms::no_perms && | ||
fs::perms::none && | ||
fs::is_regular_file(p) && regex_match(file_path, qmc_regex)) { | ||
qmc_paths.emplace_back(std::move(file_path)); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
/* | ||
* Author: mayusheng - [email protected] | ||
* Last modified: 2020-06-29 10:57 | ||
* Filename: seed.hpp | ||
* | ||
* Description: | ||
* | ||
* | ||
*/ | ||
#ifndef SEED_H | ||
#define SEED_H | ||
|
||
#include <array> | ||
#include <cstdio> | ||
|
||
namespace qmc_decoder { | ||
class seed { | ||
|