#include <directory.h>
Collaboration diagram for directory:

Public Member Functions | |
| directory (const istring &path, const char *pattern="*") | |
| opens up the "path" specified and scans for files and subdirectories. | |
| directory (const directory &to_copy) | |
| virtual | ~directory () |
| directory & | operator= (const directory &to_copy) |
| IMPLEMENT_CLASS_NAME ("directory") | |
| bool | good () const |
| true if the directory existed and its contents were readable. | |
| const istring & | path () const |
| returns the directory that we manage. | |
| const istring & | pattern () const |
| returns the pattern that the directory class scans for. | |
| bool | reset (const istring &path, const char *pattern="*") |
| gets rid of any current files and rescans the directory at "path". | |
| bool | move_up (const char *pattern="*") |
| resets the directory to be its own parent. | |
| bool | move_down (const istring &subdir, const char *pattern="*") |
| changes down into a "subdir" of this directory. | |
| bool | rescan () |
| reads our current directory's contents over again. | |
| const string_array & | files () const |
| returns the list of files that we found in this directory. | |
| const string_array & | directories () const |
| these are the directory names from the folder. | |
Static Public Member Functions | |
| static istring | absolute_path (const istring &relative_path) |
| returns the absolute path to a file with "relative_path". | |
| static istring | current () |
| returns the current directory, as reported by the operating system. | |
| static bool | make_directory (const istring &path) |
| returns true if the directory "path" could be created. | |
| static bool | remove_directory (const istring &path) |
| returns true if the directory "path" could be removed. | |
| static bool | recursive_create (const istring &directory_name) |
| returns true if the "directory_name" can be created or already exists. | |
Definition at line 24 of file directory.h.
| directory::directory | ( | const istring & | 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 50 of file directory.cpp.
| directory::directory | ( | const directory & | to_copy | ) |
Definition at line 58 of file directory.cpp.
References _path, _pattern, istring::observe(), and reset().
| directory::~directory | ( | ) | [virtual] |
Definition at line 79 of file directory.cpp.
References _path, _pattern, istring::observe(), and reset().
| directory::IMPLEMENT_CLASS_NAME | ( | "directory" | ) |
| bool directory::good | ( | ) | const [inline] |
true if the directory existed and its contents were readable.
Definition at line 44 of file directory.h.
Referenced by main(), and directory_tree::reset().
| const istring & directory::path | ( | ) | const |
returns the directory that we manage.
Definition at line 75 of file directory.cpp.
Referenced by directory(), main(), make_directory(), grid_processor::process_grid_files(), remove_directory(), reset(), stamping_spider(), and whacking_spider().
| const istring & directory::pattern | ( | ) | const |
returns the pattern that the directory class scans for.
Definition at line 77 of file directory.cpp.
returns the absolute path to a file with "relative_path".
an empty string is returned on failure.
Definition at line 87 of file directory.cpp.
References MAX_ABS_PATH, and istring::s().
Referenced by command_line::command_line().
| bool directory::reset | ( | const istring & | 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 114 of file directory.cpp.
References path(), and rescan().
Referenced by directory(), move_down(), move_up(), and operator=().
| bool directory::move_up | ( | const char * | pattern = "*" |
) |
| bool directory::move_down | ( | const istring & | 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:
my_dir->move_down("clampett")
Definition at line 123 of file directory.cpp.
| bool directory::rescan | ( | ) |
reads our current directory's contents over again.
Definition at line 133 of file directory.cpp.
References array< contents >::access(), array< contents >::concatenate(), FUNCDEF, filename::is_directory(), array< contents >::length(), LOG, array< contents >::reset(), istring::s(), and shell_sort().
Referenced by reset().
| const string_array & 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 129 of file directory.cpp.
Referenced by main(), grid_processor::process_grid_files(), stamping_spider(), whacking_spider(), and version_ini::write_assembly().
| const string_array & 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 131 of file directory.cpp.
Referenced by whacking_spider().
| istring directory::current | ( | ) | [static] |
returns the current directory, as reported by the operating system.
Definition at line 100 of file directory.cpp.
References MAX_ABS_PATH.
Referenced by move_down(), and move_up().
| bool directory::make_directory | ( | const istring & | path | ) | [static] |
returns true if the directory "path" could be created.
Definition at line 212 of file directory.cpp.
References mkdir, path(), and istring::s().
Referenced by ini_configurator::name(), and recursive_create().
| bool directory::remove_directory | ( | const istring & | path | ) | [static] |
returns true if the directory "path" could be removed.
Definition at line 223 of file directory.cpp.
References path(), rmdir, and istring::s().
| bool directory::recursive_create | ( | const istring & | directory_name | ) | [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 234 of file directory.cpp.
References istring::end(), filename::exists(), FUNCDEF, filename::is_directory(), filename::join(), array< contents >::length(), make_directory(), filename::raw(), filename::separate(), and array< contents >::subarray().
Referenced by heavy_file_operations::copy_file(), and heavy_file_operations::write_file_chunk().
1.5.1