21 Filename(
const string &filename) {
32 Filename(
const wstring &filename) {
43 Filename(
const char *filename) {
56 _filename(copy._filename.c_str()),
57 _dirname_end(copy._dirname_end),
58 _basename_start(copy._basename_start),
59 _basename_end(copy._basename_end),
60 _extension_start(copy._extension_start),
61 _hash_start(copy._hash_start),
62 _hash_end(copy._hash_end),
67 #ifdef USE_MOVE_SEMANTICS 74 Filename(
string &&filename) NOEXCEPT {
76 (*this) = move(filename);
78 #endif // USE_MOVE_SEMANTICS 80 #ifdef USE_MOVE_SEMANTICS 88 _filename(move(from._filename)),
89 _dirname_end(from._dirname_end),
90 _basename_start(from._basename_start),
91 _basename_end(from._basename_end),
92 _extension_start(from._extension_start),
93 _hash_start(from._hash_start),
94 _hash_end(from._hash_end),
98 #endif // USE_MOVE_SEMANTICS 106 text_filename(
const Filename &filename) {
118 text_filename(
const string &filename) {
130 binary_filename(
const Filename &filename) {
142 binary_filename(
const string &filename) {
154 dso_filename(
const string &filename) {
156 result.set_type(T_dso);
166 executable_filename(
const string &filename) {
168 result.set_type(T_executable);
201 operator = (
const string &filename) {
202 _filename = filename;
216 operator = (
const wstring &filename) {
220 return operator = (encoder.
get_text());
229 operator = (
const char *filename) {
230 assert(filename != NULL);
231 return (*
this) = string(filename);
241 _filename = copy._filename;
242 _dirname_end = copy._dirname_end;
243 _basename_start = copy._basename_start;
244 _basename_end = copy._basename_end;
245 _extension_start = copy._extension_start;
246 _hash_start = copy._hash_start;
247 _hash_end = copy._hash_end;
248 _flags = copy._flags;
252 #ifdef USE_MOVE_SEMANTICS 259 operator = (
string &&filename) NOEXCEPT {
260 _filename = move(filename);
267 #endif // USE_MOVE_SEMANTICS 269 #ifdef USE_MOVE_SEMANTICS 276 operator = (
Filename &&from) NOEXCEPT {
277 _filename = MOVE(from._filename);
278 _dirname_end = from._dirname_end;
279 _basename_start = from._basename_start;
280 _basename_end = from._basename_end;
281 _extension_start = from._extension_start;
282 _hash_start = from._hash_start;
283 _hash_end = from._hash_end;
284 _flags = from._flags;
287 #endif // USE_MOVE_SEMANTICS 295 operator
const string & ()
const {
304 INLINE
const char *Filename::
306 return _filename.c_str();
314 INLINE
bool Filename::
316 return _filename.empty();
324 INLINE
size_t Filename::
326 return _filename.length();
334 INLINE
char Filename::
335 operator [] (
int n)
const {
336 assert(n >= 0 && n < (
int)_filename.length());
345 INLINE
string Filename::
346 substr(
size_t begin,
size_t end)
const {
347 return _filename.substr(begin, end);
425 return _filename.substr(0, _dirname_end);
437 return _filename.substr(_basename_start);
449 return _filename.substr(0, _basename_end);
461 if (_basename_end == string::npos) {
462 return _filename.substr(_basename_start);
464 return _filename.substr(_basename_start, _basename_end - _basename_start);
478 if (_extension_start == string::npos) {
481 return _filename.substr(_extension_start);
495 _flags = (_flags & ~F_text) | F_binary;
508 _flags = (_flags & ~F_binary) | F_text;
522 return ((_flags & F_binary) != 0);
535 return ((_flags & (F_binary | F_text)) != 0);
549 return ((_flags & F_text) != 0);
565 _flags = (_flags & ~F_type) | type;
584 return (Type)(_flags & (int)F_type);
611 _flags &= ~F_pattern;
625 return (_flags & F_pattern) != 0;
641 return (_hash_start != _hash_end);
653 return _filename.substr(_hash_start);
665 return _filename.empty() || _filename[0] !=
'/';
684 (_filename.size() > 2 && _filename[0] ==
'.' && _filename[1] ==
'/') ||
685 (!_filename.empty() && _filename[0] ==
'/');
693 INLINE
bool Filename::
694 operator == (
const string &other)
const {
695 return (*(
string *)
this) == other;
703 INLINE
bool Filename::
704 operator != (
const string &other)
const {
705 return (*(
string *)
this) != other;
713 INLINE
bool Filename::
714 operator < (
const string &other)
const {
715 return (*(
string *)
this) < other;
723 INLINE
int Filename::
724 compare_to(
const Filename &other)
const {
725 return strcmp(_filename.c_str(), other._filename.c_str());
743 return !_filename.empty();
751 INLINE
void Filename::
752 output(ostream &out)
const {
767 _filesystem_encoding = encoding;
779 return _filesystem_encoding;
string get_dirname() const
Returns the directory part of the filename.
string get_basename() const
Returns the basename part of the filename.
bool get_pattern() const
Returns the flag indicating whether this is a filename pattern.
Filename operator/(const Filename &other) const
Returns a new Filename that is composed of the other filename added to the end of this filename...
string get_fullpath() const
Returns the entire filename: directory, basename, extension.
This class can be used to convert text between multiple representations, e.g.
static Filename pattern_filename(const string &filename)
Constructs a filename that represents a sequence of numbered files.
void set_type(Type type)
Sets the type of the file represented by the filename.
wstring get_fullpath_w() const
Returns the entire filename as a wide-character string.
void set_binary()
Indicates that the filename represents a binary file.
void set_text()
Indicates that the filename represents a text file.
string get_hash_to_end() const
Returns the part of the filename beginning at the hash sequence (if any), and continuing to the end o...
bool __nonzero__() const
Returns true if the Filename is valid (not empty), or false if it is an empty string.
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
string get_extension() const
Returns the file extension.
bool is_binary() const
Returns true if the Filename has been indicated to represent a binary file via a previous call to set...
Type get_type() const
Returns the type of the file represented by the filename, as previously set by set_type().
const wstring & get_wtext() const
Returns the text associated with the TextEncoder, as a wide-character string.
static void set_filesystem_encoding(TextEncoder::Encoding encoding)
Specifies the default encoding to be used for all subsequent Filenames.
static TextEncoder::Encoding get_filesystem_encoding()
Specifies the default encoding to be used for all subsequent Filenames objects.
The name of a file, such as a texture file or an Egg file.
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
bool is_local() const
Returns true if the filename is local, e.g.
bool is_text() const
Returns true if the Filename has been indicated to represent a text file via a previous call to set_t...
void set_encoding(Encoding encoding)
Specifies how the string set via set_text() is to be interpreted.
void set_text(const string &text)
Changes the text that is stored in the encoder.
string get_fullpath_wo_extension() const
Returns the full filename–directory and basename parts–except for the extension.
void set_wtext(const wstring &wtext)
Changes the text that is stored in the encoder.
bool has_hash() const
Returns true if the filename is indicated to be a filename pattern (that is, set_pattern(true) was ca...
void operator+=(const string &other)
Appends the other filename onto the end of this one.
void set_pattern(bool pattern)
Sets the flag indicating whether this is a filename pattern.
bool is_binary_or_text() const
Returns true either is_binary() or is_text() is true; that is, that the filename has been specified a...
string get_text() const
Returns the current text, as encoded via the current encoding system.
Filename operator+(const string &other) const
Returns a new Filename representing the concatenation of the two filenames.