feisty meow concerns codebase  2.140
filesystem::filename Class Reference

Provides operations commonly needed on file names. More...

#include <filename.h>

Inheritance diagram for filesystem::filename:
Collaboration diagram for filesystem::filename:

Public Types

enum  write_modes { ALLOW_NEITHER = 0x0 , ALLOW_READ = 0x1 , ALLOW_WRITE = 0x2 , ALLOW_BOTH = ALLOW_READ | ALLOW_WRITE }
 
enum  ownership_modes {
  NO_RIGHTS = 0x0 , USER_RIGHTS = 0x1 , GROUP_RIGHTS = 0x2 , OTHER_RIGHTS = 0x4 ,
  ALL_RIGHTS = USER_RIGHTS | GROUP_RIGHTS | OTHER_RIGHTS
}
 
enum  directory_separator { pc_separator = '\\' , unix_separator = '/' }
 the default separator for directories per operating system. More...
 
- Public Types inherited from basis::astring
enum  special_flag { UNTERMINATED = 62 , SPRINTF = 84 }
 
enum  how_to_strip { FROM_FRONT = 1 , FROM_END = 2 , FROM_BOTH_SIDES = 3 }
 

Public Member Functions

 filename ()
 blank constructor. More...
 
 filename (const basis::astring &name)
 creates a filename from any part of a full pathname, if possible. More...
 
 filename (const basis::astring &directory, const basis::astring &name_of_file)
 constructs a filename from a "directory" and the "name_of_file". More...
 
 filename (const filename &to_copy)
 copy constructor. More...
 
 DEFINE_CLASS_NAME ("filename")
 
virtual ~filename ()
 
bool good () const
 returns true if the filename seems to be valid. More...
 
void reset (const basis::astring &name)
 changes the file name held by the object. More...
 
const basis::astringraw () const
 returns the astring that we're holding onto for the path. More...
 
basis::astringraw ()
 accesses the astring that we're holding onto for the path. More...
 
filenameoperator= (const filename &to_copy)
 provides assignment for this object, plus a simple string. More...
 
filenameoperator= (const basis::astring &to_copy)
 provides assignment for this object, plus a simple string. More...
 
void canonicalize ()
 cleans up the filename as needed for the current operating system. More...
 
bool exists () const
 returns true if the file exists. More...
 
bool unlink () const
 actually removes the file, if possible. More...
 
filename parent () const
 returns the parent filename for this one. More...
 
basis::astring pop ()
 removes the deepest component of the pathname. More...
 
void push (const basis::astring &to_push)
 pushes a new filename onto the current pathname. More...
 
filename basename () const
 returns the base of the filename; no directory. More...
 
filename dirname () const
 returns the directory for the filename. More...
 
basis::astring dirname (bool add_slash) const
 returns the directory for the filename and optionally adds a slash. More...
 
bool had_directory () const
 returns true if the name that we were given had a non-empty directory. More...
 
char drive (bool interact_with_fs=false) const
 returns the drive letter for the file, without the colon. More...
 
basis::astring extension () const
 returns the extension for the file, if one is present. More...
 
basis::astring rootname () const
 returns the root part of the basename without an extension. More...
 
bool is_directory () const
 
bool is_writable () const
 
bool is_readable () const
 
bool is_executable () const
 
bool is_normal () const
 
bool chmod (int write_mode, int owner_mode) const
 changes the access rights on the file. More...
 
void separate (bool &rooted, structures::string_array &pieces) const
 breaks the filename into its component parts. More...
 
void join (bool rooted, const structures::string_array &pieces)
 undoes a separate() operation to get the filename back. More...
 
virtual void pack (basis::byte_array &packed_form) const
 Creates a packed form of the packable object in "packed_form". More...
 
virtual bool unpack (basis::byte_array &packed_form)
 Restores the packable from the "packed_form". More...
 
virtual int packed_size () const
 Estimates the space needed for the packed structure. More...
 
bool compare_prefix (const filename &to_compare, basis::astring &sequel)
 examines "this" filename to see if it's a prefix of "to_compare". More...
 
bool compare_prefix (const filename &to_compare)
 this simpler form doesn't bother with computing the sequel. More...
 
bool compare_suffix (const filename &to_compare, basis::astring &prequel)
 compares the back end of a filename to this. More...
 
bool compare_suffix (const filename &to_compare)
 
- Public Member Functions inherited from basis::astring
 astring ()
 constructs an empty string. More...
 
 astring (const char *initial)
 constructs a copy of the string passed in "initial". More...
 
 astring (char c, int repeat)
 constructs a string with "repeat" characters of "c" in it. More...
 
 astring (const astring &s)
 Constructs a copy of the string "s". More...
 
 astring (const base_string &initial)
 constructs a string from the base class. More...
 
 astring (special_flag way, const char *s,...)
 constructor that sports a few variable parameter constructions. More...
 
virtual ~astring ()
 destroys any storage for the string. More...
 
 DEFINE_CLASS_NAME ("astring")
 
virtual int comparator (const astring &s2) const
 helps to fulfill orderable contract. More...
 
int length () const
 Returns the current length of the string. More...
 
int end () const
 returns the index of the last (non-null) character in the string. More...
 
bool empty () const
 empty() reports if the string is empty, that is, of zero length(). More...
 
bool non_empty () const
 non_empty() reports if the string has some contents. More...
 
bool operator! () const
 the negation operator returns true if the string is empty. More...
 
bool t () const
 t() is a shortcut for the string being "true", as in non-empty. More...
 
virtual const char * observe () const
 observes the underlying pointer to the zero-terminated string. More...
 
const char * c_str () const
 synonym for observe. mimics the STL method name. More...
 
const char * s () const
 synonym for observe. the 's' stands for "string", if that helps. More...
 
virtual char get (int index) const
 a constant peek at the string's internals at the specified index. More...
 
virtual char * access ()
 provides access to the actual string held. More...
 
char * c_str ()
 synonym for access. mimics the STL method. More...
 
char * s ()
 synonym for access. More...
 
char & operator[] (int position)
 accesses individual characters in "this" string. More...
 
const char & operator[] (int position) const
 observes individual characters in "this" string. More...
 
virtual void put (int position, char to_put)
 stores the character "to_put" at index "position" in the string. More...
 
astringsprintf (const char *s,...)
 similar to the SPRINTF constructor, but works on an existing string. More...
 
int convert (int default_value) const
 Converts the string into a corresponding integer. More...
 
long convert (long default_value) const
 converts the string to a long integer. More...
 
float convert (float default_value) const
 converts the string to a floating point number. More...
 
double convert (double default_value) const
 converts the string to a double precision floating point number. More...
 
bool equal_to (const char *that) const
 returns true if "that" is equal to this. More...
 
bool iequals (const astring &that) const
 returns true if this is case-insensitively equal to "that". More...
 
bool iequals (const char *that) const
 returns true if this is case-insensitively equal to "that". More...
 
bool compare (const astring &to_compare, int start_first, int start_second, int count, bool case_sensitive) const
 Compares "this" string with "to_compare". More...
 
bool begins (const astring &maybe_prefix) const
 Returns true if "this" string begins with "maybe_prefix". More...
 
bool ibegins (const astring &maybe_prefix) const
 a case-insensitive method similar to begins(). More...
 
bool ends (const astring &maybe_suffix) const
 returns true if this string ends with "maybe_suffix". More...
 
bool iends (const astring &maybe_suffix) const
 
astringoperator= (const astring &s)
 Sets the contents of this string to "s". More...
 
astringoperator= (const char *s)
 Sets the contents of this string to "s". More...
 
void reset ()
 clears out the contents string. More...
 
void reset (special_flag way, const char *s,...)
 operates like the constructor that takes a 'special_flag'. More...
 
void copy (char *to_stuff, int count) const
 Copies a maximum of "count" characters from this into "to_stuff". More...
 
void stuff (char *to_stuff, int count) const
 a synonym for copy(). More...
 
astring operator+ (const astring &s) const
 Returns the concatenation of "this" and "s". More...
 
astringoperator+= (const astring &s)
 Modifies "this" by concatenating "s" onto it. More...
 
astringoperator+= (const char *s)
 
astring operator+ (const char *s) const
 < synonym for the concatenation operator but uses a char pointer instead. More...
 
astringoperator+= (char c)
 concatenater for single characters. More...
 
int find (char to_find, int position=0, bool reverse=false) const
 Locates "to_find" in "this". More...
 
int find (const astring &to_find, int posn=0, bool reverse=false) const
 finds "to_find" in this string. More...
 
int ifind (char to_find, int position=0, bool reverse=false) const
 like the find() methods above, but case-insensitive. More...
 
int ifind (const astring &to_find, int posn=0, bool reverse=false) const
 like the find() methods above, but case-insensitive. More...
 
int find_any (const char *to_find, int position=0, bool reverse=false) const
 searches for any of the characters in "to_find". More...
 
int ifind_any (const char *to_find, int position=0, bool reverse=false) const
 searches case-insensitively for any of the characters in "to_find". More...
 
int find_non_match (const char *to_find, int position=0, bool reverse=false) const
 searches for any character that is not in "to_find" and returns index. More...
 
bool contains (const astring &to_find) const
 Returns true if "to_find" is contained in this string or false if not. More...
 
bool substring (astring &target, int start, int end) const
 a version that stores the substring in an existing "target" string. More...
 
astring substring (int start, int end) const
 Returns the segment of "this" between the indices "start" and "end". More...
 
astring middle (int start, int count)
 returns the middle of the string from "start" with "count" characters. More...
 
astring left (int count)
 returns the left "count" characters from the string. More...
 
astring right (int count)
 returns the right "count" characters from the string. More...
 
void pad (int length, char padding=' ')
 makes the string "length" characters long. More...
 
void trim (int length)
 shortens the string to "length" if it's longer than that. More...
 
void insert (int position, const astring &to_insert)
 Copies "to_insert" into "this" at the "position". More...
 
virtual void zap (int start, int end)
 Deletes the characters between "start" and "end" inclusively. More...
 
void to_lower ()
 to_lower modifies "this" by replacing capitals with lower-case. More...
 
void to_upper ()
 to_upper does the opposite of to_lower (that is, q becomes Q). More...
 
astring lower () const
 like to_lower(), but returns a new string rather than modifying this. More...
 
astring upper () const
 like to_upper(), but returns a new string rather than modifying this. More...
 
bool replace (const astring &tag, const astring &replacement)
 replaces the first occurrence of "tag" text with the "replacement". More...
 
bool replace_all (char to_replace, char new_char)
 changes all occurrences of "to_replace" with "new_char". More...
 
bool replace_all (const astring &to_replace, const astring &new_string)
 
void shrink ()
 changes all occurrences of "to_replace" into "new_string". More...
 
void strip (const astring &strip_list, how_to_strip way=FROM_BOTH_SIDES)
 strips all chars from "strip_list" out of "this" given the "way". More...
 
void strip_spaces (how_to_strip way=FROM_BOTH_SIDES)
 removes excess space characters from string's beginning, end or both. More...
 
void strip_white_spaces (how_to_strip way=FROM_BOTH_SIDES)
 like strip_spaces, but includes tabs in the list to strip. More...
 
int packed_size () const
 Reports the size required to pack this string into a byte array. More...
 
void pack (byte_array &target) const
 stores this string in the "target". it can later be unpacked again. More...
 
bool unpack (byte_array &source)
 retrieves a string (packed with pack()) from "source" into this string. More...
 
virtual bool equal_to (const equalizable &s2) const
 < provides a case insensitive comparison routine. More...
 
virtual bool less_than (const orderable &s2) const
 
virtual base_stringconcatenate_string (const base_string &s)
 Modifies "this" by concatenating "s" onto it. More...
 
virtual base_stringconcatenate_char (char c)
 concatenater for single characters. More...
 
virtual base_stringassign (const base_string &s)
 Sets the contents of this string to "s". More...
 
virtual base_stringupgrade (const char *s)
 Sets the contents of this string to "s". More...
 
virtual bool sub_string (base_string &target, int start, int end) const
 Gets the segment of "this" between the indices "start" and "end". More...
 
virtual bool sub_compare (const base_string &to_compare, int start_first, int start_second, int count, bool case_sensitive) const
 Compares "this" string with "to_compare". More...
 
virtual void insert (int position, const base_string &to_insert)
 Copies "to_insert" into "this" at the "position". More...
 
virtual void text_form (base_string &state_fill) const
 Provides a text view of all the important info owned by this object. More...
 
astringbase_sprintf (const char *s, va_list &args)
 
byte_arrayget_implementation ()
 
- Public Member Functions inherited from basis::base_string
virtual base_stringoperator= (const base_string &to_copy)
 sets this string's contents equal to the contents of "to_copy". More...
 
- Public Member Functions inherited from basis::orderable
virtual bool operator< (const orderable &s2) const
 the virtual method for object ordering. More...
 
- Public Member Functions inherited from basis::equalizable
virtual bool operator== (const equalizable &s2) const
 the virtual method for object equality. More...
 
- Public Member Functions inherited from basis::text_formable
virtual const char * class_name () const =0
 Returns the bare name of this class as a constant character pointer. More...
 

Static Public Member Functions

static bool separator (char is_it)
 returns true if the character "is_it" in question is a separator. More...
 
static basis::astring default_separator ()
 returns the default separator character for this OS. More...
 
static bool legal_character (char to_check)
 returns true if "to_check" is a valid character in a filename. More...
 
static void detooth_filename (basis::astring &to_clean, char replacement='_')
 takes any known illegal file system characters out of "to_clean". More...
 
static basis::astring null_device ()
 returns the name for the black hole device that consumes all input, i.e. /dev/null. More...
 
- Static Public Member Functions inherited from basis::astring
static const astringempty_string ()
 useful wherever empty strings are needed, e.g., function defaults. More...
 
static bool matches (const astring &match_list, char to_match)
 returns true if "to_match" is found in the "match_list" string. More...
 

Detailed Description

Provides operations commonly needed on file names.

Definition at line 63 of file filename.h.

Member Enumeration Documentation

◆ directory_separator

the default separator for directories per operating system.

the PC uses the backward slash to separate file and directory names from each other, while Unix uses the forward slash.

Enumerator
pc_separator 
unix_separator 

Definition at line 186 of file filename.h.

◆ ownership_modes

Enumerator
NO_RIGHTS 
USER_RIGHTS 
GROUP_RIGHTS 
OTHER_RIGHTS 
ALL_RIGHTS 

Definition at line 174 of file filename.h.

◆ write_modes

Enumerator
ALLOW_NEITHER 
ALLOW_READ 
ALLOW_WRITE 
ALLOW_BOTH 

Definition at line 168 of file filename.h.

Constructor & Destructor Documentation

◆ filename() [1/4]

filesystem::filename::filename ( )

blank constructor.

Definition at line 57 of file filename.cpp.

Referenced by push().

◆ filename() [2/4]

filesystem::filename::filename ( const basis::astring name)

creates a filename from any part of a full pathname, if possible.

if the name contains quotes, they are stripped out.

Definition at line 62 of file filename.cpp.

References canonicalize().

◆ filename() [3/4]

filesystem::filename::filename ( const basis::astring directory,
const basis::astring name_of_file 
)

constructs a filename from a "directory" and the "name_of_file".

the "name_of_file" can itself be a directory.

Definition at line 67 of file filename.cpp.

References basis::astring::astring(), canonicalize(), filesystem::DEFAULT_SEPARATOR, and filesystem::NO_PARENT_DEFAULT.

◆ filename() [4/4]

filesystem::filename::filename ( const filename to_copy)

copy constructor.

Definition at line 86 of file filename.cpp.

References canonicalize().

◆ ~filename()

filesystem::filename::~filename ( )
virtual

Definition at line 91 of file filename.cpp.

Member Function Documentation

◆ basename()

◆ canonicalize()

void filesystem::filename::canonicalize ( )

cleans up the filename as needed for the current operating system.

reforms the name by replacing any alternate directory separators with the operating system's preferred character.

Definition at line 157 of file filename.cpp.

References basis::astring::astring(), basis::astring::compare(), filesystem::DEFAULT_SEPARATOR, basis::astring::end(), FUNCDEF, basis::astring::get(), basis::astring::insert(), textual::parser_bits::is_alpha(), textual::parser_bits::is_alphanumeric(), basis::astring::length(), basis::astring::put(), separator(), and basis::astring::zap().

Referenced by filename(), operator=(), and reset().

◆ chmod()

bool filesystem::filename::chmod ( int  write_mode,
int  owner_mode 
) const

changes the access rights on the file.

Definition at line 624 of file filename.cpp.

References ALLOW_READ, ALLOW_WRITE, GROUP_RIGHTS, OTHER_RIGHTS, raw(), basis::astring::s(), and USER_RIGHTS.

Referenced by versions::version_ini::write_assembly(), and versions::version_ini::write_rc().

◆ compare_prefix() [1/2]

bool filesystem::filename::compare_prefix ( const filename to_compare)

this simpler form doesn't bother with computing the sequel.

Definition at line 563 of file filename.cpp.

◆ compare_prefix() [2/2]

bool filesystem::filename::compare_prefix ( const filename to_compare,
basis::astring sequel 
)

examines "this" filename to see if it's a prefix of "to_compare".

this returns true if all of "this" is the same as the first portion of "to_compare". that is, if "this" is a prefix of "to_compare", then true is returned. this will always fail if there are fewer components in "to_compare". it will always succeed if the two filenames are identical. on success, the "sequel" is set to the portion of "to_compare" that's not included in this filename.

Definition at line 545 of file filename.cpp.

References filesystem::DEFAULT_SEPARATOR, and basis::array< contents >::length().

Referenced by filesystem::directory_tree::jump_to().

◆ compare_suffix() [1/2]

bool filesystem::filename::compare_suffix ( const filename to_compare)

Definition at line 617 of file filename.cpp.

◆ compare_suffix() [2/2]

bool filesystem::filename::compare_suffix ( const filename to_compare,
basis::astring prequel 
)

compares the back end of a filename to this.

this is similar to compare_prefix() but it checks to see if the back end of "this" filename is the same as "to_compare". if "this" is longer than "to_compare", then failure occurs. only if all of the bits in "this" are seen in the back of "to_compare" is true returned.

Definition at line 600 of file filename.cpp.

References filesystem::DEFAULT_SEPARATOR, and basis::array< contents >::length().

◆ default_separator()

astring filesystem::filename::default_separator ( )
static

returns the default separator character for this OS.

Definition at line 93 of file filename.cpp.

References basis::astring::astring(), and filesystem::DEFAULT_SEPARATOR.

Referenced by filesystem::directory_tree::compare_trees(), filesystem::directory_tree::jump_to(), and filesystem::directory_tree::seek().

◆ DEFINE_CLASS_NAME()

filesystem::filename::DEFINE_CLASS_NAME ( "filename"  )

◆ detooth_filename()

void filesystem::filename::detooth_filename ( basis::astring to_clean,
char  replacement = '_' 
)
static

takes any known illegal file system characters out of "to_clean".

this prepares "to_clean" for use as a component in a larger filename by ensuring that the file system will not reject the name (as long as a suitable directory path is prepended to the name and permissions allow the file to be created or accessed). the "replacement" is used as the character that is substituted instead of illegal characters.

Definition at line 452 of file filename.cpp.

References legal_character(), and basis::astring::length().

◆ dirname() [1/2]

◆ dirname() [2/2]

astring filesystem::filename::dirname ( bool  add_slash) const

returns the directory for the filename and optionally adds a slash.

if "add_slash" is true, then the default directory separator will be present on the end of the string.

Definition at line 419 of file filename.cpp.

References filesystem::DEFAULT_SEPARATOR, dirname(), and raw().

◆ drive()

char filesystem::filename::drive ( bool  interact_with_fs = false) const

returns the drive letter for the file, without the colon.

this only makes sense for a fully qualified MS-DOS style name. if no drive letter is found, then '\0' is returned. if "interact_with_fs" is true, then the file system will be checked for the actual drive if no drive letter was found in the contents.

Definition at line 282 of file filename.cpp.

References basis::astring::get(), and basis::astring::length().

◆ exists()

◆ extension()

astring filesystem::filename::extension ( ) const

returns the extension for the file, if one is present.

Definition at line 299 of file filename.cpp.

References basename(), basis::astring::end(), basis::astring::find(), basis::astring::length(), basis::negative(), raw(), and basis::astring::substring().

Referenced by main().

◆ good()

bool filesystem::filename::good ( ) const

returns true if the filename seems to be valid.

this means that not only was the pathname parsed and found valid, but the file actually exists.

Definition at line 99 of file filename.cpp.

References exists().

Referenced by filesystem::directory_tree::add_path().

◆ had_directory()

bool filesystem::filename::had_directory ( ) const
inline

returns true if the name that we were given had a non-empty directory.

this allows one to distinguish between a file with the current directory (.) attached and a file with no directory specified.

Definition at line 139 of file filename.h.

Referenced by configuration::application_configuration::get_cmdline_from_proc().

◆ is_directory()

bool filesystem::filename::is_directory ( ) const

◆ is_executable()

bool filesystem::filename::is_executable ( ) const

Definition at line 349 of file filename.cpp.

References S_IEXEC.

◆ is_normal()

bool filesystem::filename::is_normal ( ) const

◆ is_readable()

bool filesystem::filename::is_readable ( ) const

Definition at line 341 of file filename.cpp.

References S_IREAD.

Referenced by exists().

◆ is_writable()

bool filesystem::filename::is_writable ( ) const

Definition at line 333 of file filename.cpp.

References S_IWRITE.

Referenced by versions::version_ini::writable().

◆ join()

void filesystem::filename::join ( bool  rooted,
const structures::string_array pieces 
)

undoes a separate() operation to get the filename back.

"this" is set to a filename made from each of the "pieces". if there are any directory separators inside the pieces themselves, then they will be removed by canonicalize(). if separate() said the path was rooted, then join needs to be told that.

Definition at line 503 of file filename.cpp.

References filesystem::DEFAULT_SEPARATOR, and basis::array< contents >::length().

Referenced by filesystem::directory_tree::compare_trees(), filesystem::directory_tree::jump_to(), and filesystem::directory::recursive_create().

◆ legal_character()

bool filesystem::filename::legal_character ( char  to_check)
static

returns true if "to_check" is a valid character in a filename.

this does not consider separator characters; it only looks at the the name components. also, it is appropriate for the union of the operating systems we support.

Definition at line 436 of file filename.cpp.

Referenced by detooth_filename().

◆ null_device()

astring filesystem::filename::null_device ( )
static

returns the name for the black hole device that consumes all input, i.e. /dev/null.

Definition at line 109 of file filename.cpp.

◆ operator=() [1/2]

filename & filesystem::filename::operator= ( const basis::astring to_copy)

provides assignment for this object, plus a simple string.

the latter version invokes canonicalize to clean the string up.

Definition at line 129 of file filename.cpp.

References canonicalize().

◆ operator=() [2/2]

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

provides assignment for this object, plus a simple string.

Definition at line 121 of file filename.cpp.

◆ pack()

void filesystem::filename::pack ( basis::byte_array packed_form) const
virtual

Creates a packed form of the packable object in "packed_form".

This must append to the data in "packed_form" rather than clearing prior contents.

Implements basis::packable.

Reimplemented in filesystem::file_info.

Definition at line 465 of file filename.cpp.

References basis::attach(), and structures::pack().

Referenced by filesystem::file_info::pack(), and filesystem::filename_tree::pack().

◆ packed_size()

int filesystem::filename::packed_size ( ) const
virtual

Estimates the space needed for the packed structure.

Implements basis::packable.

Reimplemented in filesystem::file_info.

Definition at line 460 of file filename.cpp.

References structures::packed_size(), and structures::PACKED_SIZE_INT32.

Referenced by filesystem::file_info::packed_size(), and filesystem::filename_tree::packed_size().

◆ parent()

filename filesystem::filename::parent ( ) const

returns the parent filename for this one.

Definition at line 150 of file filename.cpp.

References dirname().

Referenced by pop().

◆ pop()

astring filesystem::filename::pop ( )

removes the deepest component of the pathname.

the component might be a file or directory name, but popping beyond the top-level directory will not succeed. the returned string contains the component that was removed. it will be a blank string if nothing could be popped.

Definition at line 138 of file filename.cpp.

References basename(), basis::astring::equal_to(), filesystem::NO_PARENT_DEFAULT, parent(), and raw().

◆ push()

void filesystem::filename::push ( const basis::astring to_push)

pushes a new filename onto the current pathname.

this only makes sense as a real pathname if this is currently a directory name and the component "to_push" is a child of that directory (or one intends to create that component as a child). this is the opposite of pop.

Definition at line 152 of file filename.cpp.

References filename().

◆ raw() [1/2]

astring & filesystem::filename::raw ( )

accesses the astring that we're holding onto for the path.

important note: if you change the string with this non-const raw() method, you MUST call canonicalize() on it again afterwards.

Definition at line 95 of file filename.cpp.

◆ raw() [2/2]

◆ reset()

void filesystem::filename::reset ( const basis::astring name)

changes the file name held by the object.

Definition at line 103 of file filename.cpp.

References canonicalize().

Referenced by filesystem::byte_filer::close(), and filesystem::byte_filer::open().

◆ rootname()

astring filesystem::filename::rootname ( ) const

returns the root part of the basename without an extension.

Definition at line 308 of file filename.cpp.

References basename(), basis::astring::end(), basis::astring::find(), basis::negative(), raw(), and basis::astring::substring().

Referenced by loggers::file_logger::log_file_for_app_name().

◆ separate()

void filesystem::filename::separate ( bool &  rooted,
structures::string_array pieces 
) const

breaks the filename into its component parts.

this returns an array containing the component names for the path in this filename object. if the "rooted" flag is set to true, then the path was absolute (i.e. started at '/' in unix. this notion is not needed for dos/windoze, as the first component will be something like 'a:').

Definition at line 482 of file filename.cpp.

References basis::astring::length(), raw(), basis::array< contents >::reset(), and separator().

Referenced by filesystem::directory_tree::add_path(), filesystem::directory_tree::compare_trees(), filesystem::directory_tree::jump_to(), and filesystem::directory::recursive_create().

◆ separator()

bool filesystem::filename::separator ( char  is_it)
static

returns true if the character "is_it" in question is a separator.

Definition at line 118 of file filename.cpp.

References pc_separator, and unix_separator.

Referenced by canonicalize(), and separate().

◆ unlink()

bool filesystem::filename::unlink ( ) const

actually removes the file, if possible.

if the file was successfully deleted, then true is returned.

Definition at line 101 of file filename.cpp.

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

Referenced by whacking_spider().

◆ unpack()

bool filesystem::filename::unpack ( basis::byte_array packed_form)
virtual

Restores the packable from the "packed_form".

This object becomes the unpacked form, and therefore must lose any of its prior contents that depend on the data in "packed_form". This is up to the derived unpack function to figure out. The "packed_form" is modified by extracting all of the pieces that are used for this object; the remainder stays in "packed_form". true is returned if the unpacking was successful.

Implements basis::packable.

Reimplemented in filesystem::file_info.

Definition at line 471 of file filename.cpp.

References basis::detach(), and structures::unpack().

Referenced by filesystem::file_info::unpack(), and filesystem::filename_tree::unpack().


The documentation for this class was generated from the following files: