diff --git a/CMakeLists.txt b/CMakeLists.txt index d342209..d9b4ccb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/README.md b/README.md index c0db7ad..f7f489d 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ LICENSE CMakeLists.txt ``` +## Dependencies +* g++ `>=4.9` +* boost `>=1.54` + ## Build ```bash cmake . diff --git a/src/fnd.cpp b/src/fnd.cpp index 685079f..4199f1d 100644 --- a/src/fnd.cpp +++ b/src/fnd.cpp @@ -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); }