feisty meow concerns codebase
2.140
|
Implements a scanner that finds all filenames in the directory specified. More...
#include <directory.h>
Public Member Functions | |
directory (const basis::astring &path, const char *pattern="*") | |
opens up the "path" specified and scans for files and subdirectories. More... | |
directory (const directory &to_copy) | |
virtual | ~directory () |
directory & | operator= (const directory &to_copy) |
DEFINE_CLASS_NAME ("directory") | |
bool | good () const |
true if the directory existed and its contents were readable. More... | |
const basis::astring & | path () const |
returns the directory that we manage. More... | |
const basis::astring & | pattern () const |
returns the pattern that the directory class scans for. More... | |
bool | reset (const basis::astring &path, const char *pattern="*") |
gets rid of any current files and rescans the directory at "path". More... | |
bool | move_up (const char *pattern="*") |
resets the directory to be its own parent. More... | |
bool | move_down (const basis::astring &subdir, const char *pattern="*") |
changes down into a "subdir" of this directory. More... | |
bool | rescan () |
reads our current directory's contents over again. More... | |
const structures::string_array & | files () const |
returns the list of files that we found in this directory. More... | |
const structures::string_array & | directories () const |
these are the directory names from the folder. More... | |
Static Public Member Functions | |
static basis::astring | absolute_path (const basis::astring &relative_path) |
returns the absolute path to a file with "relative_path". More... | |
static basis::astring | current () |
returns the current directory, as reported by the operating system. More... | |
static bool | make_directory (const basis::astring &path) |
returns true if the directory "path" could be created. More... | |
static bool | remove_directory (const basis::astring &path) |
returns true if the directory "path" could be removed. More... | |
static bool | recursive_create (const basis::astring &directory_name) |
returns true if the "directory_name" can be created or already exists. More... | |
Implements a scanner that finds all filenames in the directory specified.
Definition at line 26 of file directory.h.
filesystem::directory::directory | ( | const basis::astring & | path, |
const char * | pattern = "*" |
||
) |
opens up the "path" specified and scans for files and subdirectories.
if the location was accessible, then the good() method returns true. note that the "path" should just be a bare directory without any wildcards attached. the "pattern" can be specified if you wish to strain out just a subset of the files in the directory. it must meet the same requirements that the operating system places on wildcard patterns.
Definition at line 64 of file directory.cpp.
filesystem::directory::directory | ( | const directory & | to_copy | ) |
Definition at line 72 of file directory.cpp.
References basis::astring::observe(), and reset().
|
virtual |
Definition at line 80 of file directory.cpp.
References basis::WHACK().
|
static |
returns the absolute path to a file with "relative_path".
an empty string is returned on failure.
Definition at line 101 of file directory.cpp.
References MAX_ABS_PATH, and basis::astring::s().
|
static |
returns the current directory, as reported by the operating system.
Definition at line 114 of file directory.cpp.
References MAX_ABS_PATH.
Referenced by move_down(), and move_up().
filesystem::directory::DEFINE_CLASS_NAME | ( | "directory" | ) |
const string_array & filesystem::directory::directories | ( | ) | const |
these are the directory names from the folder.
they can also be examined using the filename object. note that this does not include the entry for the current directory (.) or the parent (..).
Definition at line 145 of file directory.cpp.
Referenced by whacking_spider().
const string_array & filesystem::directory::files | ( | ) | const |
returns the list of files that we found in this directory.
these are all assumed to be located in our given path. to find out more information about the files themselves, construct a filename object with the path() and the file of interest.
Definition at line 143 of file directory.cpp.
Referenced by fix_project_references.fix_project_references::replace_all_occurrences(), phrase_replacer.phrase_replacer::replace_all_occurrences(), stamping_spider(), whacking_spider(), and versions::version_ini::write_assembly().
|
inline |
true if the directory existed and its contents were readable.
Definition at line 46 of file directory.h.
Referenced by filesystem::directory_tree::reset().
|
static |
returns true if the directory "path" could be created.
Definition at line 237 of file directory.cpp.
References mkdir, path(), and basis::astring::s().
Referenced by recursive_create().
bool filesystem::directory::move_down | ( | const basis::astring & | subdir, |
const char * | pattern = "*" |
||
) |
changes down into a "subdir" of this directory.
the "subdir" should be just the file name component to change into. absolute paths will not work. for example, if a directory "/l/jed" has a subdirectory named "clampett", then use:
Definition at line 137 of file directory.cpp.
bool filesystem::directory::move_up | ( | const char * | pattern = "*" | ) |
resets the directory to be its own parent.
Definition at line 131 of file directory.cpp.
Definition at line 93 of file directory.cpp.
References basis::astring::observe(), and reset().
const astring & filesystem::directory::path | ( | ) | const |
returns the directory that we manage.
Definition at line 89 of file directory.cpp.
Referenced by directory(), make_directory(), remove_directory(), reset(), stamping_spider(), and whacking_spider().
const astring & filesystem::directory::pattern | ( | ) | const |
returns the pattern that the directory class scans for.
Definition at line 91 of file directory.cpp.
Referenced by directory(), move_down(), move_up(), and reset().
|
static |
returns true if the "directory_name" can be created or already exists.
false returns indicate that the operating system wouldn't let us make the directory, or that we didn't have sufficient permissions to access an existing directory to view it or move into it.
Definition at line 257 of file directory.cpp.
References basis::astring::end(), filesystem::filename::exists(), FUNCDEF, filesystem::filename::is_directory(), filesystem::filename::join(), basis::array< contents >::length(), make_directory(), filesystem::filename::raw(), filesystem::filename::separate(), and basis::array< contents >::subarray().
Referenced by filesystem::heavy_file_operations::copy_file(), filesystem::directory_tree::make_directories(), and filesystem::heavy_file_operations::write_file_chunk().
|
static |
returns true if the directory "path" could be removed.
Definition at line 247 of file directory.cpp.
References path(), rmdir, and basis::astring::s().
bool filesystem::directory::rescan | ( | ) |
reads our current directory's contents over again.
Definition at line 147 of file directory.cpp.
References basis::array< contents >::access(), basis::array< contents >::concatenate(), FUNCDEF, filesystem::filename::is_directory(), filesystem::filename::is_normal(), basis::array< contents >::length(), LOG, basis::array< contents >::reset(), basis::astring::s(), and algorithms::shell_sort().
Referenced by reset().
bool filesystem::directory::reset | ( | const basis::astring & | path, |
const char * | pattern = "*" |
||
) |
gets rid of any current files and rescans the directory at "path".
a new "pattern" can be specified at this time also.
Definition at line 128 of file directory.cpp.
References path(), pattern(), and rescan().
Referenced by directory(), move_down(), move_up(), and operator=().