mirror of https://github.com/sharkdp/fd.git
Updates for older compiler/boost version
This commit is contained in:
parent
3ee77feddc
commit
43adfc8e61
|
@ -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})
|
||||
|
|
|
@ -25,6 +25,10 @@ LICENSE
|
|||
CMakeLists.txt
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
* g++ `>=4.9`
|
||||
* boost `>=1.54`
|
||||
|
||||
## Build
|
||||
```bash
|
||||
cmake .
|
||||
|
|
12
src/fnd.cpp
12
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue