47 #include "EST_Pathname.h"
49 void EST_Pathname::setup(
void)
53 int EST_Pathname::is_absolute(
void)
const
55 return length()>0 && (*this)(0) ==
'/';
58 int EST_Pathname::is_dirname(
void)
const
69 if ((pos=
index(
"/", -1)) >=0)
115 return EST_Pathname::construct(dir, filename);
123 if ((dir = opendir(this->as_directory()))!=NULL)
125 struct dirent *entry;
127 while ((entry = readdir(dir)) != NULL)
132 if (check_for_directories &&
134 (buf.st_mode & S_IFDIR))
135 list.
append(name.as_directory());
146 {
return EST_Pathname::append(p, addition); }
149 {
return EST_Pathname::append(p, addition); }
153 {
EST_String q = EST_Pathname::append(p, addition);
return q; }
155 {
EST_String q = EST_Pathname::append(p, addition);
return q; }
160 if (addition.is_absolute())
173 EST_String EST_Pathname::extension(
void)
const
192 result = result.after(
index(
"/",-1));
196 EST_String EST_Pathname::basename(
int remove_all)
const
198 EST_String result(this->as_file().filename());
202 if (result.contains(
"."))
203 result = result.before(
".");
EST_String(void)
Construct an empty string.
int index(const char *s, int pos=0) const
Position of substring (starting at pos)
int length(void) const
Length of string ({not} length of underlying chunk)
EST_String basename(EST_String full, EST_String ext="")
This acts like the bourne shell basename command. By default, it strips any leading path from a strin...
void append(const T &item)
add item onto end of list
int contains(const char *s, int pos=-1) const
Does it contain this substring?
EST_String after(int pos, int len=1) const
Part after pos+len.
EST_String before(int pos, int len=0) const
Part before position.