Panda3D
 All Classes Functions Variables Enumerations
filename.I
1 // Filename: filename.I
2 // Created by: drose (18Jan99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 ////////////////////////////////////////////////////////////////////
16 // Function: Filename::Constructor
17 // Access: Published
18 // Description:
19 ////////////////////////////////////////////////////////////////////
20 INLINE Filename::
21 Filename(const string &filename) {
22  _flags = 0;
23  (*this) = filename;
24 }
25 
26 ////////////////////////////////////////////////////////////////////
27 // Function: Filename::Constructor
28 // Access: Published
29 // Description:
30 ////////////////////////////////////////////////////////////////////
31 INLINE Filename::
32 Filename(const wstring &filename) {
33  _flags = 0;
34  (*this) = filename;
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: Filename::Constructor
39 // Access: Published
40 // Description:
41 ////////////////////////////////////////////////////////////////////
42 INLINE Filename::
43 Filename(const char *filename) {
44  _flags = 0;
45  (*this) = filename;
46 }
47 
48 
49 ////////////////////////////////////////////////////////////////////
50 // Function: Filename::Copy Constructor
51 // Access: Published
52 // Description:
53 ////////////////////////////////////////////////////////////////////
54 INLINE Filename::
55 Filename(const Filename &copy) :
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),
63  _flags(copy._flags)
64 {
65 }
66 
67 #ifdef USE_MOVE_SEMANTICS
68 ////////////////////////////////////////////////////////////////////
69 // Function: Filename::Move Constructor
70 // Access: Published
71 // Description:
72 ////////////////////////////////////////////////////////////////////
73 INLINE Filename::
74 Filename(string &&filename) NOEXCEPT {
75  _flags = 0;
76  (*this) = move(filename);
77 }
78 #endif // USE_MOVE_SEMANTICS
79 
80 #ifdef USE_MOVE_SEMANTICS
81 ////////////////////////////////////////////////////////////////////
82 // Function: Filename::Move Constructor
83 // Access: Published
84 // Description:
85 ////////////////////////////////////////////////////////////////////
86 INLINE Filename::
87 Filename(Filename &&from) NOEXCEPT :
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),
95  _flags(from._flags)
96 {
97 }
98 #endif // USE_MOVE_SEMANTICS
99 
100 ////////////////////////////////////////////////////////////////////
101 // Function: Filename::text_filename named constructor
102 // Access: Published
103 // Description:
104 ////////////////////////////////////////////////////////////////////
105 INLINE Filename Filename::
106 text_filename(const Filename &filename) {
107  Filename result(filename);
108  result.set_text();
109  return result;
110 }
111 
112 ////////////////////////////////////////////////////////////////////
113 // Function: Filename::text_filename named constructor
114 // Access: Published
115 // Description:
116 ////////////////////////////////////////////////////////////////////
117 INLINE Filename Filename::
118 text_filename(const string &filename) {
119  Filename result(filename);
120  result.set_text();
121  return result;
122 }
123 
124 ////////////////////////////////////////////////////////////////////
125 // Function: Filename::binary_filename named constructor
126 // Access: Published
127 // Description:
128 ////////////////////////////////////////////////////////////////////
129 INLINE Filename Filename::
130 binary_filename(const Filename &filename) {
131  Filename result(filename);
132  result.set_binary();
133  return result;
134 }
135 
136 ////////////////////////////////////////////////////////////////////
137 // Function: Filename::binary_filename named constructor
138 // Access: Published
139 // Description:
140 ////////////////////////////////////////////////////////////////////
141 INLINE Filename Filename::
142 binary_filename(const string &filename) {
143  Filename result(filename);
144  result.set_binary();
145  return result;
146 }
147 
148 ////////////////////////////////////////////////////////////////////
149 // Function: Filename::dso_filename named constructor
150 // Access: Published
151 // Description:
152 ////////////////////////////////////////////////////////////////////
153 INLINE Filename Filename::
154 dso_filename(const string &filename) {
155  Filename result(filename);
156  result.set_type(T_dso);
157  return result;
158 }
159 
160 ////////////////////////////////////////////////////////////////////
161 // Function: Filename::executable_filename named constructor
162 // Access: Published
163 // Description:
164 ////////////////////////////////////////////////////////////////////
165 INLINE Filename Filename::
166 executable_filename(const string &filename) {
167  Filename result(filename);
168  result.set_type(T_executable);
169  return result;
170 }
171 
172 ////////////////////////////////////////////////////////////////////
173 // Function: Filename::pattern_filename named constructor
174 // Access: Published
175 // Description: Constructs a filename that represents a sequence of
176 // numbered files. See set_pattern().
177 ////////////////////////////////////////////////////////////////////
178 INLINE Filename Filename::
179 pattern_filename(const string &filename) {
180  Filename result(filename);
181  result.set_pattern(true);
182  return result;
183 }
184 
185 ////////////////////////////////////////////////////////////////////
186 // Function: Filename::Destructor
187 // Access: Published
188 // Description:
189 ////////////////////////////////////////////////////////////////////
190 INLINE Filename::
191 ~Filename() {
192 }
193 
194 
195 ////////////////////////////////////////////////////////////////////
196 // Function: Filename::Assignment operator
197 // Access: Published
198 // Description:
199 ////////////////////////////////////////////////////////////////////
200 INLINE Filename &Filename::
201 operator = (const string &filename) {
202  _filename = filename;
203 
204  locate_basename();
205  locate_extension();
206  locate_hash();
207  return *this;
208 }
209 
210 ////////////////////////////////////////////////////////////////////
211 // Function: Filename::Assignment operator
212 // Access: Published
213 // Description:
214 ////////////////////////////////////////////////////////////////////
215 INLINE Filename &Filename::
216 operator = (const wstring &filename) {
217  TextEncoder encoder;
219  encoder.set_wtext(filename);
220  return operator = (encoder.get_text());
221 }
222 
223 ////////////////////////////////////////////////////////////////////
224 // Function: Filename::Assignment operator
225 // Access: Published
226 // Description:
227 ////////////////////////////////////////////////////////////////////
228 INLINE Filename &Filename::
229 operator = (const char *filename) {
230  assert(filename != NULL);
231  return (*this) = string(filename);
232 }
233 
234 ////////////////////////////////////////////////////////////////////
235 // Function: Filename::Copy assignment operator
236 // Access: Published
237 // Description:
238 ////////////////////////////////////////////////////////////////////
239 INLINE Filename &Filename::
240 operator = (const Filename &copy) {
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;
249  return *this;
250 }
251 
252 #ifdef USE_MOVE_SEMANTICS
253 ////////////////////////////////////////////////////////////////////
254 // Function: Filename::Move assignment operator
255 // Access: Published
256 // Description:
257 ////////////////////////////////////////////////////////////////////
258 INLINE Filename &Filename::
259 operator = (string &&filename) NOEXCEPT {
260  _filename = move(filename);
261 
262  locate_basename();
263  locate_extension();
264  locate_hash();
265  return *this;
266 }
267 #endif // USE_MOVE_SEMANTICS
268 
269 #ifdef USE_MOVE_SEMANTICS
270 ////////////////////////////////////////////////////////////////////
271 // Function: Filename::Move assignment operator
272 // Access: Published
273 // Description:
274 ////////////////////////////////////////////////////////////////////
275 INLINE Filename &Filename::
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;
285  return *this;
286 }
287 #endif // USE_MOVE_SEMANTICS
288 
289 ////////////////////////////////////////////////////////////////////
290 // Function: Filename::string typecast operator
291 // Access: Published
292 // Description:
293 ////////////////////////////////////////////////////////////////////
294 INLINE Filename::
295 operator const string & () const {
296  return _filename;
297 }
298 
299 ////////////////////////////////////////////////////////////////////
300 // Function: Filename::c_str
301 // Access: Published
302 // Description:
303 ////////////////////////////////////////////////////////////////////
304 INLINE const char *Filename::
305 c_str() const {
306  return _filename.c_str();
307 }
308 
309 ////////////////////////////////////////////////////////////////////
310 // Function: Filename::empty
311 // Access: Published
312 // Description:
313 ////////////////////////////////////////////////////////////////////
314 INLINE bool Filename::
315 empty() const {
316  return _filename.empty();
317 }
318 
319 ////////////////////////////////////////////////////////////////////
320 // Function: Filename::length
321 // Access: Published
322 // Description:
323 ////////////////////////////////////////////////////////////////////
324 INLINE size_t Filename::
325 length() const {
326  return _filename.length();
327 }
328 
329 ////////////////////////////////////////////////////////////////////
330 // Function: Filename::Indexing operator
331 // Access: Published
332 // Description:
333 ////////////////////////////////////////////////////////////////////
334 INLINE char Filename::
335 operator [] (int n) const {
336  assert(n >= 0 && n < (int)_filename.length());
337  return _filename[n];
338 }
339 
340 ////////////////////////////////////////////////////////////////////
341 // Function: Filename::substr
342 // Access: Published
343 // Description:
344 ////////////////////////////////////////////////////////////////////
345 INLINE string Filename::
346 substr(size_t begin, size_t end) const {
347  return _filename.substr(begin, end);
348 }
349 
350 ////////////////////////////////////////////////////////////////////
351 // Function: Filename::operator +=
352 // Access: Published
353 // Description: Appends the other filename onto the end of this one.
354 // This does not introduce an intervening slash, but see
355 // the Filename constructor that takes two parameters.
356 ////////////////////////////////////////////////////////////////////
357 INLINE void Filename::
358 operator += (const string &other) {
359  _filename += other;
360  locate_basename();
361  locate_extension();
362  locate_hash();
363 }
364 
365 ////////////////////////////////////////////////////////////////////
366 // Function: Filename::operator +
367 // Access: Published
368 // Description: Returns a new Filename representing the concatenation
369 // of the two filenames.
370 ////////////////////////////////////////////////////////////////////
371 INLINE Filename Filename::
372 operator + (const string &other) const {
373  Filename a(*this);
374  a += other;
375  return a;
376 }
377 
378 ////////////////////////////////////////////////////////////////////
379 // Function: Filename::operator /
380 // Access: Published
381 // Description: Returns a new Filename that is composed of the
382 // other filename added to the end of this filename,
383 // with an intervening slash added if necessary.
384 ////////////////////////////////////////////////////////////////////
385 INLINE Filename Filename::
386 operator / (const Filename &other) const {
387  return Filename(*this, other);
388 }
389 
390 ////////////////////////////////////////////////////////////////////
391 // Function: Filename::get_fullpath
392 // Access: Published
393 // Description: Returns the entire filename: directory, basename,
394 // extension. This is the same thing returned by the
395 // string typecast operator.
396 ////////////////////////////////////////////////////////////////////
397 INLINE string Filename::
398 get_fullpath() const {
399  return _filename;
400 }
401 
402 ////////////////////////////////////////////////////////////////////
403 // Function: Filename::get_fullpath_w
404 // Access: Published
405 // Description: Returns the entire filename as a wide-character
406 // string.
407 ////////////////////////////////////////////////////////////////////
408 INLINE wstring Filename::
409 get_fullpath_w() const {
410  TextEncoder encoder;
412  encoder.set_text(get_fullpath());
413  return encoder.get_wtext();
414 }
415 
416 ////////////////////////////////////////////////////////////////////
417 // Function: Filename::get_dirname
418 // Access: Published
419 // Description: Returns the directory part of the filename. This is
420 // everything in the filename up to, but not including
421 // the rightmost slash.
422 ////////////////////////////////////////////////////////////////////
423 INLINE string Filename::
424 get_dirname() const {
425  return _filename.substr(0, _dirname_end);
426 }
427 
428 ////////////////////////////////////////////////////////////////////
429 // Function: Filename::get_basename
430 // Access: Published
431 // Description: Returns the basename part of the filename. This is
432 // everything in the filename after the rightmost slash,
433 // including any extensions.
434 ////////////////////////////////////////////////////////////////////
435 INLINE string Filename::
436 get_basename() const {
437  return _filename.substr(_basename_start);
438 }
439 
440 
441 ////////////////////////////////////////////////////////////////////
442 // Function: Filename::get_fullpath_wo_extension
443 // Access: Published
444 // Description: Returns the full filename--directory and basename
445 // parts--except for the extension.
446 ////////////////////////////////////////////////////////////////////
447 INLINE string Filename::
449  return _filename.substr(0, _basename_end);
450 }
451 
452 
453 ////////////////////////////////////////////////////////////////////
454 // Function: Filename::get_basename_wo_extension
455 // Access: Published
456 // Description: Returns the basename part of the filename, without
457 // the file extension.
458 ////////////////////////////////////////////////////////////////////
459 INLINE string Filename::
461  if (_basename_end == string::npos) {
462  return _filename.substr(_basename_start);
463  } else {
464  return _filename.substr(_basename_start, _basename_end - _basename_start);
465  }
466 }
467 
468 
469 ////////////////////////////////////////////////////////////////////
470 // Function: Filename::get_extension
471 // Access: Published
472 // Description: Returns the file extension. This is everything after
473 // the rightmost dot, if there is one, or the empty
474 // string if there is not.
475 ////////////////////////////////////////////////////////////////////
476 INLINE string Filename::
477 get_extension() const {
478  if (_extension_start == string::npos) {
479  return string();
480  } else {
481  return _filename.substr(_extension_start);
482  }
483 }
484 
485 ////////////////////////////////////////////////////////////////////
486 // Function: Filename::set_binary
487 // Access: Published
488 // Description: Indicates that the filename represents a binary file.
489 // This is primarily relevant to the read_file() and
490 // write_file() methods, so they can set the appropriate
491 // flags to the OS.
492 ////////////////////////////////////////////////////////////////////
493 INLINE void Filename::
495  _flags = (_flags & ~F_text) | F_binary;
496 }
497 
498 ////////////////////////////////////////////////////////////////////
499 // Function: Filename::set_text
500 // Access: Published
501 // Description: Indicates that the filename represents a text file.
502 // This is primarily relevant to the read_file() and
503 // write_file() methods, so they can set the appropriate
504 // flags to the OS.
505 ////////////////////////////////////////////////////////////////////
506 INLINE void Filename::
508  _flags = (_flags & ~F_binary) | F_text;
509 }
510 
511 ////////////////////////////////////////////////////////////////////
512 // Function: Filename::is_binary
513 // Access: Published
514 // Description: Returns true if the Filename has been indicated to
515 // represent a binary file via a previous call to
516 // set_binary(). It is possible that neither
517 // is_binary() nor is_text() will be true, if neither
518 // set_binary() nor set_text() was ever called.
519 ////////////////////////////////////////////////////////////////////
520 INLINE bool Filename::
521 is_binary() const {
522  return ((_flags & F_binary) != 0);
523 }
524 
525 ////////////////////////////////////////////////////////////////////
526 // Function: Filename::is_binary_or_text
527 // Access: Published
528 // Description: Returns true either is_binary() or is_text() is true;
529 // that is, that the filename has been specified as
530 // either binary or text. If this is false, the
531 // filename has not been specified.
532 ////////////////////////////////////////////////////////////////////
533 INLINE bool Filename::
535  return ((_flags & (F_binary | F_text)) != 0);
536 }
537 
538 ////////////////////////////////////////////////////////////////////
539 // Function: Filename::is_text
540 // Access: Published
541 // Description: Returns true if the Filename has been indicated to
542 // represent a text file via a previous call to
543 // set_text(). It is possible that neither is_binary()
544 // nor is_text() will be true, if neither set_binary()
545 // nor set_text() was ever called.
546 ////////////////////////////////////////////////////////////////////
547 INLINE bool Filename::
548 is_text() const {
549  return ((_flags & F_text) != 0);
550 }
551 
552 ////////////////////////////////////////////////////////////////////
553 // Function: Filename::set_type
554 // Access: Published
555 // Description: Sets the type of the file represented by the
556 // filename. This is useful for to_os_specific(),
557 // resolve_filename(), test_existence(), and all such
558 // real-world access functions. It helps the Filename
559 // know how to map the internal filename to the
560 // OS-specific filename (for instance, maybe executables
561 // should have an .exe extension).
562 ////////////////////////////////////////////////////////////////////
563 INLINE void Filename::
564 set_type(Filename::Type type) {
565  _flags = (_flags & ~F_type) | type;
566  switch (type) {
567  case T_dso:
568  case T_executable:
569  set_binary();
570 
571  case T_general:
572  break;
573  }
574 }
575 
576 ////////////////////////////////////////////////////////////////////
577 // Function: Filename::get_type
578 // Access: Published
579 // Description: Returns the type of the file represented by the
580 // filename, as previously set by set_type().
581 ////////////////////////////////////////////////////////////////////
582 INLINE Filename::Type Filename::
583 get_type() const {
584  return (Type)(_flags & (int)F_type);
585 }
586 
587 ////////////////////////////////////////////////////////////////////
588 // Function: Filename::set_pattern
589 // Access: Published
590 // Description: Sets the flag indicating whether this is a filename
591 // pattern. When this is true, the filename is
592 // understood to be a placeholder for a numbered
593 // sequence of filename, such as an image sequence. In
594 // this case, a sequence of one or more hash characters
595 // ("#") should appear in the filename string; these
596 // characters will be filled in with the corresponding
597 // number (or more) of digits representing the sequence
598 // number. Sequence numbers always begin counting at 0.
599 //
600 // When this is true, methods like has_hash() and
601 // get_hash_to_end() and get_filename_index() may be
602 // called. Methods like is_exists() will implicitly
603 // test for existance of filename sequence 0.
604 ////////////////////////////////////////////////////////////////////
605 INLINE void Filename::
606 set_pattern(bool pattern) {
607  if (pattern != get_pattern()) {
608  if (pattern) {
609  _flags |= F_pattern;
610  } else {
611  _flags &= ~F_pattern;
612  }
613  locate_hash();
614  }
615 }
616 
617 ////////////////////////////////////////////////////////////////////
618 // Function: Filename::get_pattern
619 // Access: Published
620 // Description: Returns the flag indicating whether this is a
621 // filename pattern. See set_pattern().
622 ////////////////////////////////////////////////////////////////////
623 INLINE bool Filename::
624 get_pattern() const {
625  return (_flags & F_pattern) != 0;
626 }
627 
628 ////////////////////////////////////////////////////////////////////
629 // Function: Filename::has_hash
630 // Access: Published
631 // Description: Returns true if the filename is indicated to be a
632 // filename pattern (that is, set_pattern(true) was
633 // called), and the filename pattern did include a
634 // sequence of hash marks, or false if it was not a
635 // filename pattern or did not include hash marks. If
636 // this is true, then get_filename_index() will return a
637 // different filename each time.
638 ////////////////////////////////////////////////////////////////////
639 INLINE bool Filename::
640 has_hash() const {
641  return (_hash_start != _hash_end);
642 }
643 
644 ////////////////////////////////////////////////////////////////////
645 // Function: Filename::get_hash_to_end
646 // Access: Published
647 // Description: Returns the part of the filename beginning at the
648 // hash sequence (if any), and continuing to the end of
649 // the filename.
650 ////////////////////////////////////////////////////////////////////
651 INLINE string Filename::
653  return _filename.substr(_hash_start);
654 }
655 
656 ////////////////////////////////////////////////////////////////////
657 // Function: Filename::is_local
658 // Access: Published
659 // Description: Returns true if the filename is local, e.g. does not
660 // begin with a slash, or false if the filename is fully
661 // specified from the root.
662 ////////////////////////////////////////////////////////////////////
663 INLINE bool Filename::
664 is_local() const {
665  return _filename.empty() || _filename[0] != '/';
666 }
667 
668 ////////////////////////////////////////////////////////////////////
669 // Function: Filename::is_fully_qualified
670 // Access: Published
671 // Description: Returns true if the filename is fully qualified,
672 // e.g. begins with a slash. This is almost, but not
673 // quite, the same thing as !is_local(). It's not
674 // exactly the same because a special case is made for
675 // filenames that begin with a single dot followed by a
676 // slash--these are considered to be fully qualified
677 // (they are explicitly relative to the current
678 // directory, and do not refer to a filename on a search
679 // path somewhere).
680 ////////////////////////////////////////////////////////////////////
681 INLINE bool Filename::
683  return
684  (_filename.size() > 2 && _filename[0] == '.' && _filename[1] == '/') ||
685  (!_filename.empty() && _filename[0] == '/');
686 }
687 
688 ////////////////////////////////////////////////////////////////////
689 // Function: Filename::Equality operator
690 // Access: Published
691 // Description:
692 ////////////////////////////////////////////////////////////////////
693 INLINE bool Filename::
694 operator == (const string &other) const {
695  return (*(string *)this) == other;
696 }
697 
698 ////////////////////////////////////////////////////////////////////
699 // Function: Filename::Inequality operator
700 // Access: Published
701 // Description:
702 ////////////////////////////////////////////////////////////////////
703 INLINE bool Filename::
704 operator != (const string &other) const {
705  return (*(string *)this) != other;
706 }
707 
708 ////////////////////////////////////////////////////////////////////
709 // Function: Filename::Ordering operator
710 // Access: Published
711 // Description:
712 ////////////////////////////////////////////////////////////////////
713 INLINE bool Filename::
714 operator < (const string &other) const {
715  return (*(string *)this) < other;
716 }
717 
718 ////////////////////////////////////////////////////////////////////
719 // Function: Filename::compare_to
720 // Access: Published
721 // Description:
722 ////////////////////////////////////////////////////////////////////
723 INLINE int Filename::
724 compare_to(const Filename &other) const {
725  return strcmp(_filename.c_str(), other._filename.c_str());
726 }
727 
728 
729 ////////////////////////////////////////////////////////////////////
730 // Function: Filename::__nonzero__
731 // Access: Published
732 // Description: Returns true if the Filename is valid (not empty),
733 // or false if it is an empty string.
734 //
735 // This implements the Python equivalent to operator
736 // bool. Defining an actual operator bool method for
737 // C++ use would work too, but it seems to cause too
738 // many ambiguities for the C++ compiler, so we use this
739 // Python-only approach instead.
740 ////////////////////////////////////////////////////////////////////
741 INLINE bool Filename::
742 __nonzero__() const {
743  return !_filename.empty();
744 }
745 
746 ////////////////////////////////////////////////////////////////////
747 // Function: Filename::output
748 // Access: Published
749 // Description:
750 ////////////////////////////////////////////////////////////////////
751 INLINE void Filename::
752 output(ostream &out) const {
753  out << _filename;
754 }
755 
756 ////////////////////////////////////////////////////////////////////
757 // Function: Filename::set_filesystem_encoding
758 // Access: Published, Static
759 // Description: Specifies the default encoding to be used for all
760 // subsequent Filenames. This is used to represent
761 // wide-character (Unicode) filenames internally. On
762 // non-Windows-based systems, the encoded filename is
763 // also passed to the underlying operating system.
764 ////////////////////////////////////////////////////////////////////
765 INLINE void Filename::
766 set_filesystem_encoding(TextEncoder::Encoding encoding) {
767  _filesystem_encoding = encoding;
768 }
769 
770 ////////////////////////////////////////////////////////////////////
771 // Function: Filename::get_filesystem_encoding
772 // Access: Published, Static
773 // Description: Specifies the default encoding to be used for all
774 // subsequent Filenames objects. See
775 // set_filesystem_encoding().
776 ////////////////////////////////////////////////////////////////////
777 INLINE TextEncoder::Encoding Filename::
779  return _filesystem_encoding;
780 }
string get_fullpath() const
Returns the entire filename: directory, basename, extension.
Definition: filename.I:398
const wstring & get_wtext() const
Returns the text associated with the TextEncoder, as a wide-character string.
Definition: textEncoder.I:530
string get_fullpath_wo_extension() const
Returns the full filename–directory and basename parts–except for the extension.
Definition: filename.I:448
This class can be used to convert text between multiple representations, e.g.
Definition: textEncoder.h:37
static Filename pattern_filename(const string &filename)
Constructs a filename that represents a sequence of numbered files.
Definition: filename.I:179
void set_type(Type type)
Sets the type of the file represented by the filename.
Definition: filename.I:564
void set_binary()
Indicates that the filename represents a binary file.
Definition: filename.I:494
void set_text()
Indicates that the filename represents a text file.
Definition: filename.I:507
string get_text() const
Returns the current text, as encoded via the current encoding system.
Definition: textEncoder.I:167
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...
Definition: filename.I:652
bool is_binary() const
Returns true if the Filename has been indicated to represent a binary file via a previous call to set...
Definition: filename.I:521
bool is_fully_qualified() const
Returns true if the filename is fully qualified, e.g.
Definition: filename.I:682
string get_dirname() const
Returns the directory part of the filename.
Definition: filename.I:424
bool is_local() const
Returns true if the filename is local, e.g.
Definition: filename.I:664
bool has_hash() const
Returns true if the filename is indicated to be a filename pattern (that is, set_pattern(true) was ca...
Definition: filename.I:640
static void set_filesystem_encoding(TextEncoder::Encoding encoding)
Specifies the default encoding to be used for all subsequent Filenames.
Definition: filename.I:766
Type get_type() const
Returns the type of the file represented by the filename, as previously set by set_type().
Definition: filename.I:583
static TextEncoder::Encoding get_filesystem_encoding()
Specifies the default encoding to be used for all subsequent Filenames objects.
Definition: filename.I:778
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
Filename operator+(const string &other) const
Returns a new Filename representing the concatenation of the two filenames.
Definition: filename.I:372
string get_basename_wo_extension() const
Returns the basename part of the filename, without the file extension.
Definition: filename.I:460
string get_basename() const
Returns the basename part of the filename.
Definition: filename.I:436
void set_encoding(Encoding encoding)
Specifies how the string set via set_text() is to be interpreted.
Definition: textEncoder.I:59
bool is_text() const
Returns true if the Filename has been indicated to represent a text file via a previous call to set_t...
Definition: filename.I:548
void set_text(const string &text)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:112
void set_wtext(const wstring &wtext)
Changes the text that is stored in the encoder.
Definition: textEncoder.I:516
bool get_pattern() const
Returns the flag indicating whether this is a filename pattern.
Definition: filename.I:624
string get_extension() const
Returns the file extension.
Definition: filename.I:477
wstring get_fullpath_w() const
Returns the entire filename as a wide-character string.
Definition: filename.I:409
void operator+=(const string &other)
Appends the other filename onto the end of this one.
Definition: filename.I:358
void set_pattern(bool pattern)
Sets the flag indicating whether this is a filename pattern.
Definition: filename.I:606
bool __nonzero__() const
Returns true if the Filename is valid (not empty), or false if it is an empty string.
Definition: filename.I:742
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...
Definition: filename.I:534
Filename operator/(const Filename &other) const
Returns a new Filename that is composed of the other filename added to the end of this filename...
Definition: filename.I:386