anothertest
anothertest

Reputation: 979

Indexing file names and its content

I would like to write a program that index file names and its content in a given directory. If they match a given regular expression, then I would like to index them. I will use regex functions.

I don't really know how to start this.

I would use a polymorphic approach:

  1. A class Base (virtual), with basic information (name, parent directory...).
  2. A class File, a child of Base, which would represent a file.
  3. A class Folder/directoy which would represent a directory.

I am also thinking about using map to build trees.

May you tell me your opinion about this please?

Upvotes: 0

Views: 132

Answers (1)

Christian Hackl
Christian Hackl

Reputation: 27528

For filesystem functionality, use Boost.Filesystem.

For regular expressions, use <regex> for C++11, Boost.Regex otherwise.

Any initial(!) trouble you might have when installing and learning Boost will very quickly pay off.

For your map, use std::map.

In any case, do not reinvent the wheel.

Upvotes: 2

Related Questions