Updates for older compiler/boost version

This commit is contained in:
David Peter 2017-05-10 09:56:25 +02:00
parent 3ee77feddc
commit 43adfc8e61
3 changed files with 14 additions and 6 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1.0)
project(fnd CXX)
find_package(Boost 1.56 REQUIRED COMPONENTS filesystem)
find_package(Boost 1.54 REQUIRED COMPONENTS system filesystem)
include_directories( ${Boost_INCLUDE_DIR} )
file(GLOB SOURCES "src/*.cpp")
@ -11,4 +11,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
add_executable(fnd ${SOURCES})
target_compile_features(fnd PRIVATE cxx_range_for)
target_link_libraries(fnd ${Boost_LIBRARIES})

View File

@ -25,6 +25,10 @@ LICENSE
CMakeLists.txt
```
## Dependencies
* g++ `>=4.9`
* boost `>=1.54`
## Build
```bash
cmake .

View File

@ -18,14 +18,15 @@ void printPath(const fs::path& path) {
std::cout << path.string();
std::cout << ANSI_RESET << std::endl;
}
void findFiles(const std::regex& pattern) {
const fs::path& currentPath = fs::current_path();
for (auto& entry: fs::recursive_directory_iterator(currentPath)) {
const fs::path& path = entry.path().lexically_relative(currentPath);
fs::recursive_directory_iterator entry;
for (entry = fs::recursive_directory_iterator(currentPath);
entry != fs::recursive_directory_iterator(); ++entry) {
const fs::path& path = entry->path();
if (std::regex_search(path.string(), pattern)) {
printPath(path);
@ -49,8 +50,9 @@ int main(int argc, char* argv[]) {
// try to parse the argument as a regex
try {
std::regex re(argument, std::regex_constants::ECMAScript
| std::regex_constants::icase );
std::regex::flag_type flags = std::regex_constants::ECMAScript
| std::regex_constants::icase;
std::regex re(argument, flags);
findFiles(re);
}