|FBB::Glob(3bobcat)||Files matching a pattern||FBB::Glob(3bobcat)|
FBB::Glob - Wrapper around glob(3) to find files matching a pattern
Linking option: -lbobcat
The FBB::Glob class is a wrapper around the C function glob(3). It returns a list of files matching a certain pattern provided to FBB::Glob’s constructors or members.
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
This enumeration, which is identical to the stat(3bobcat) Type enumeration, defines the following values:
- BLOCK_DEVICE (0060000): the object is a block device;
- CHARACTER_DEVICE (0020000): the object is a character device;
- DIRECTORY (0040000): the object is a directory;
- FIFO (0010000): the object is a named pipe (a queue);
- REGULAR_FILE (0100000): the object is a regular file;
- SOCKET (0140000): the object is a socket;
- SYMBOLIC_LINK (0120000): the object is a symbolic link;
- ANY: any of the above types.
These values are also used by stat(2) and lstat(2). Although they can be combined using the bitor operator, they are not uniquely recognizable when combined. E.g., the value of CHARACTER_DEVICE | DIRECTORY is equal to the value of BLOCK_DEVICE. It’s also possible to combine Type values in a std::unordered_set, which avoids the confusion that may result from using the bitor operator.
- NO_FLAG: Equals 0, and can be used to avoid having to specify 0. It has no further use.
- ERR: Return on read errors;
- MARK: Append a slash to each name.
- NOSORT: Don’t sort the names.
- NOESCAPE: Backslashes don’t quote metacharacters.
- PERIOD: Leading .-characters can be matched by metachars (i.e., * and ?).
- NOMATCH: When specified the constructors won’t throw exceptions when no files matching their glob-patterns could be found. Instead they will return normally, and Glob’s size() member (see below) will return 0.
- Glob(std::string const &pattern = "*", int flags =
PERIOD, Dots dots = FIRST):
This constructor (which can also be used as the default constructor) determines all elements matching pattern.
- An Exception exception is thrown if the constructor could not properly complete it tasks.
- Multiple flags may be specified, separated by the bitor operator.
- This constructor properly completes its task if only defined Flag values were specified and if the glob(3) function returned without errors;
- Glob(Type type, std::string const &pattern = "*", int
flags = PERIOD, Dots dots = FIRST):
This constructor determines all elements of pattern when their types `elementType’ are equal to the value of elementType & type. The specified type value may consist of any bitor-ed combination of enum values defined by the Type enum. Note that this may produce confusing results. E.g., when specifying DIRECTORY, elements that are BLOCK_DEVICEs or SOCKETs are also accepted. The next constructor can be used to avoid this confusion;
- Glob(std::unordered_set<Type> const &typeSet,
std::string const &pattern = "*", int flags = PERIOD,
Dots dots = FIRST):
This constructor determines all elements of pattern when their types are found in typeSet. Different from the previous constructor, for an element to be accepted its type must exactly match a type value in the typeSet set.
Copy and move constructors (and assignment operators) are available.
- char const *operator(size_t idx) const:
The element at index position idx is returns as a C string. It returns an empty string if idx is or exceeds size().
- size_t size() const:
Returns the number of elements that were detected;
- char const *const *begin() const:
Returns a pointer to the first element that was detected. This pointer can be used in generic algorithms as an output-iterator supporting pointer arithmetic;
- char const *const *end() const:
Returns a pointer beyond the last element that was detected. This pointer can be used in generic algorithms as an output-iterator supporting pointer arithmetic;
- void swap(Glob &other):
Swaps the content of the other object with the current object.
int main(int argc, char **argv)
if (argc == 1)
cout << "Provide glob-expression as 1st arg\n";
cout << "General:\n";
for (size_t idx = 0; idx < general.size(); idx++)
cout << idx << ": " << general[idx] << endl;
cout << "Pattern: " << argv << "\n";
Glob pattern(argv, Glob::PERIOD, Glob::DEFAULT);
for (size_t idx = 0; idx < pattern.size(); idx++)
cout << idx << ": " << pattern[idx] << endl;
bobcat/glob - defines the class interface
No Reported Bugs.
BOBCAT PROJECT FILES¶
- https://fbb-git.gitlab.io/bobcat/: gitlab project page;
- bobcat_5.09.01-x.dsc: detached signature;
- bobcat_5.09.01-x.tar.gz: source archive;
- bobcat_5.09.01-x_i386.changes: change log;
- libbobcat1_5.09.01-x_*.deb: debian package containing the libraries;
- libbobcat1-dev_5.09.01-x_*.deb: debian package containing the libraries, headers and manual pages;
Bobcat is an acronym of `Brokken’s Own Base Classes And Templates’.
This is free software, distributed under the terms of the GNU General Public License (GPL).
Frank B. Brokken (email@example.com).