filesystem::directory Class Reference

Implements a scanner that finds all filenames in the directory specified. More...

#include <directory.h>

Inheritance diagram for filesystem::directory:
Inheritance graph
[legend]
Collaboration diagram for filesystem::directory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 directory (const basis::astring &path, const char *pattern="*")
 opens up the "path" specified and scans for files and subdirectories.
 directory (const directory &to_copy)
virtual ~directory ()
directoryoperator= (const directory &to_copy)
 DEFINE_CLASS_NAME ("directory")
bool good () const
 true if the directory existed and its contents were readable.
const basis::astringpath () const
 returns the directory that we manage.
const basis::astringpattern () const
 returns the pattern that the directory class scans for.
bool reset (const basis::astring &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 basis::astring &subdir, const char *pattern="*")
 changes down into a "subdir" of this directory.
bool rescan ()
 reads our current directory's contents over again.
const structures::string_arrayfiles () const
 returns the list of files that we found in this directory.
const structures::string_arraydirectories () const
 these are the directory names from the folder.

Static Public Member Functions

static basis::astring absolute_path (const basis::astring &relative_path)
 returns the absolute path to a file with "relative_path".
static basis::astring current ()
 returns the current directory, as reported by the operating system.
static bool make_directory (const basis::astring &path)
 returns true if the directory "path" could be created.
static bool remove_directory (const basis::astring &path)
 returns true if the directory "path" could be removed.
static bool recursive_create (const basis::astring &directory_name)
 returns true if the "directory_name" can be created or already exists.

Detailed Description

Implements a scanner that finds all filenames in the directory specified.

Definition at line 26 of file directory.h.


Constructor & Destructor Documentation

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 60 of file directory.cpp.

References reset().

filesystem::directory::directory ( const directory to_copy  ) 

Definition at line 68 of file directory.cpp.

References basis::astring::observe(), and reset().

filesystem::directory::~directory (  )  [virtual]

Definition at line 76 of file directory.cpp.

References basis::WHACK().


Member Function Documentation

astring filesystem::directory::absolute_path ( const basis::astring relative_path  )  [static]

returns the absolute path to a file with "relative_path".

an empty string is returned on failure.

Definition at line 97 of file directory.cpp.

References MAX_ABS_PATH, and basis::astring::s().

astring filesystem::directory::current (  )  [static]

returns the current directory, as reported by the operating system.

Definition at line 110 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 141 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 139 of file directory.cpp.

Referenced by stamping_spider(), whacking_spider(), and versions::version_ini::write_assembly().

bool filesystem::directory::good (  )  const [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().

bool filesystem::directory::make_directory ( const basis::astring path  )  [static]

returns true if the directory "path" could be created.

Definition at line 222 of file directory.cpp.

References mkdir, 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:

      my_dir->move_down("clampett") 

Definition at line 133 of file directory.cpp.

References current(), and reset().

bool filesystem::directory::move_up ( const char *  pattern = "*"  ) 

resets the directory to be its own parent.

Definition at line 127 of file directory.cpp.

References current(), and reset().

directory & filesystem::directory::operator= ( const directory to_copy  ) 

Definition at line 89 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 85 of file directory.cpp.

Referenced by stamping_spider(), and whacking_spider().

const astring & filesystem::directory::pattern (  )  const

returns the pattern that the directory class scans for.

Definition at line 87 of file directory.cpp.

bool filesystem::directory::recursive_create ( const basis::astring 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 244 of file directory.cpp.

References basis::astring::end(), filesystem::filename::exists(), 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(), and filesystem::heavy_file_operations::write_file_chunk().

bool filesystem::directory::remove_directory ( const basis::astring path  )  [static]

returns true if the directory "path" could be removed.

Definition at line 233 of file directory.cpp.

References rmdir, and basis::astring::s().

bool filesystem::directory::rescan (  ) 
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 124 of file directory.cpp.

References rescan().

Referenced by directory(), move_down(), move_up(), and operator=().


The documentation for this class was generated from the following files:
Generated on Sat Jan 28 04:25:30 2012 for hoople2 project by  doxygen 1.6.3