Skip to content

42tm/wfind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wfind

wfind is a library providing the function to look for files whose contents match the specified regular expression (regex).

The library is in lib/, and a simple program which has the same name that uses this library is main.cpp.

Build

Requirement

  • C++ Version: C++ 17 (__has_include, <filesystem>)

  • Tested compiler:

    • GNU C++ Compiler 5.3 or later
    • MS Visual C++ Compiler 15.3 or later

Older versions of g++ and other C++ compilers are yet to be tested, the build might fail.

In MinGW-w64 g++ 8.1.0, due to a bug, you can't compile <filesystem> library. It is recommended to use other version of MinGW-w64 (7.3.0) on Windows.

Command

mkdir build
cd build
cmake ..
cmake --build .

This will compile main.cpp and link wfind.cpp.

Run

./wfind [regex] [directory]
  • regex : The regular expression to be used to find in files
  • directory : (Optional) Directory that contains the files to look up for

If the directory is omitted, the location is set to current working directory.

Example

(There are prepared files for this example in example/)

Run the following command:

./wfind '\bbooks\b' example/

You should see something like this as part of the output:

Looking up directory: "example/"
Regex: "\bbooks\b"
"example/file3"
"example/file1"
wfind: 2 file(s) found.

License

This work is licensed under The Unlicense, meaning it is dedicated to the Public Domain.