18 #include "dtoolbase.h"
19 #include "pandaFileStream.h"
20 #include "typeHandle.h"
21 #include "register_type.h"
22 #include "vector_string.h"
23 #include "textEncoder.h"
63 INLINE
Filename(
const char *filename);
66 INLINE Filename(
const string &filename =
"");
67 INLINE Filename(
const wstring &filename);
68 INLINE Filename(
const Filename ©);
69 Filename(
const Filename &dirname,
const Filename &basename);
72 #ifdef USE_MOVE_SEMANTICS
73 INLINE Filename(
string &&filename) NOEXCEPT;
74 INLINE Filename(Filename &&from) NOEXCEPT;
78 EXTENSION(PyObject *__reduce__(PyObject *
self)
const);
84 INLINE
static Filename text_filename(
const Filename &filename);
85 INLINE
static Filename text_filename(
const string &filename);
86 INLINE
static Filename binary_filename(
const Filename &filename);
87 INLINE
static Filename binary_filename(
const string &filename);
88 INLINE
static Filename dso_filename(
const string &filename);
89 INLINE
static Filename executable_filename(
const string &filename);
91 INLINE
static Filename pattern_filename(
const string &filename);
93 static Filename from_os_specific(
const string &os_specific,
94 Type type = T_general);
95 static Filename from_os_specific_w(
const wstring &os_specific,
96 Type type = T_general);
97 static Filename expand_from(
const string &user_string,
98 Type type = T_general);
99 static Filename temporary(
const string &dirname,
const string &prefix,
100 const string &suffix =
string(),
101 Type type = T_general);
103 static const Filename &get_home_directory();
104 static const Filename &get_temp_directory();
105 static const Filename &get_user_appdata_directory();
106 static const Filename &get_common_appdata_directory();
109 INLINE Filename &operator = (
const string &filename);
110 INLINE Filename &operator = (
const wstring &filename);
111 INLINE Filename &operator = (
const char *filename);
112 INLINE Filename &operator = (
const Filename ©);
114 #ifdef USE_MOVE_SEMANTICS
115 INLINE Filename &operator = (
string &&filename) NOEXCEPT;
116 INLINE Filename &operator = (Filename &&from) NOEXCEPT;
120 INLINE
operator const string & ()
const;
121 INLINE
const char *c_str()
const;
122 INLINE
bool empty()
const;
123 INLINE
size_t length()
const;
124 INLINE
char operator [] (
int n)
const;
126 EXTENSION(PyObject *__repr__()
const);
128 INLINE
string substr(
size_t begin,
size_t end = string::npos)
const;
129 INLINE
void operator += (
const string &other);
130 INLINE Filename operator + (
const string &other)
const;
132 INLINE Filename operator / (
const Filename &other)
const;
135 INLINE
string get_fullpath()
const;
136 INLINE wstring get_fullpath_w()
const;
137 INLINE
string get_dirname()
const;
138 INLINE
string get_basename()
const;
139 INLINE
string get_fullpath_wo_extension()
const;
140 INLINE
string get_basename_wo_extension()
const;
141 INLINE
string get_extension()
const;
144 void set_fullpath(
const string &s);
145 void set_dirname(
const string &s);
146 void set_basename(
const string &s);
147 void set_fullpath_wo_extension(
const string &s);
148 void set_basename_wo_extension(
const string &s);
149 void set_extension(
const string &s);
155 INLINE
void set_binary();
156 INLINE
void set_text();
157 INLINE
bool is_binary()
const;
158 INLINE
bool is_text()
const;
159 INLINE
bool is_binary_or_text()
const;
161 INLINE
void set_type(Type type);
162 INLINE Type get_type()
const;
164 INLINE
void set_pattern(
bool pattern);
165 INLINE
bool get_pattern()
const;
167 INLINE
bool has_hash()
const;
168 Filename get_filename_index(
int index)
const;
170 INLINE
string get_hash_to_end()
const;
171 void set_hash_to_end(
const string &s);
173 void extract_components(vector_string &components)
const;
178 INLINE
bool is_local()
const;
179 INLINE
bool is_fully_qualified()
const;
180 void make_absolute();
181 void make_absolute(
const Filename &start_directory);
183 bool make_canonical();
184 bool make_true_case();
186 string to_os_specific()
const;
187 wstring to_os_specific_w()
const;
188 string to_os_generic()
const;
189 string to_os_short_name()
const;
190 string to_os_long_name()
const;
193 bool is_regular_file()
const;
194 bool is_writable()
const;
195 bool is_directory()
const;
196 bool is_executable()
const;
197 int compare_timestamps(
const Filename &other,
198 bool this_missing_is_old =
true,
199 bool other_missing_is_old =
true)
const;
200 time_t get_timestamp()
const;
201 time_t get_access_timestamp()
const;
202 streamsize get_file_size()
const;
204 bool resolve_filename(
const DSearchPath &searchpath,
205 const string &default_extension =
string());
206 bool make_relative_to(Filename directory,
bool allow_backups =
true);
207 int find_on_searchpath(
const DSearchPath &searchpath);
209 bool scan_directory(vector_string &contents)
const;
211 EXTENSION(PyObject *scan_directory()
const);
214 bool open_read(ifstream &stream)
const;
215 bool open_write(ofstream &stream,
bool truncate =
true)
const;
216 bool open_append(ofstream &stream)
const;
217 bool open_read_write(fstream &stream,
bool truncate =
false)
const;
218 bool open_read_append(fstream &stream)
const;
220 #ifdef USE_PANDAFILESTREAM
221 bool open_read(pifstream &stream)
const;
222 bool open_write(pofstream &stream,
bool truncate =
true)
const;
223 bool open_append(pofstream &stream)
const;
224 bool open_read_write(pfstream &stream,
bool truncate =
false)
const;
225 bool open_read_append(pfstream &stream)
const;
226 #endif // USE_PANDAFILESTREAM
231 BLOCKING
bool rename_to(
const Filename &other)
const;
232 BLOCKING
bool copy_to(
const Filename &other)
const;
234 bool make_dir()
const;
239 INLINE
bool operator == (
const string &other)
const;
240 INLINE
bool operator != (
const string &other)
const;
241 INLINE
bool operator < (
const string &other)
const;
242 INLINE
int compare_to(
const Filename &other)
const;
243 INLINE
bool __nonzero__()
const;
244 int get_hash()
const;
246 INLINE
void output(ostream &out)
const;
248 INLINE
static void set_filesystem_encoding(TextEncoder::Encoding encoding);
249 INLINE
static TextEncoder::Encoding get_filesystem_encoding();
252 bool atomic_compare_and_exchange_contents(
string &orig_contents,
const string &old_contents,
const string &new_contents)
const;
253 bool atomic_read_contents(
string &contents)
const;
256 void locate_basename();
257 void locate_extension();
259 size_t get_common_prefix(
const string &other)
const;
260 static int count_slashes(
const string &str);
261 bool r_make_canonical(
const Filename &cwd);
267 size_t _basename_start;
268 size_t _basename_end;
269 size_t _extension_start;
275 static TextEncoder::Encoding _filesystem_encoding;
276 static TVOLATILE AtomicAdjust::Pointer _home_directory;
277 static TVOLATILE AtomicAdjust::Pointer _temp_directory;
278 static TVOLATILE AtomicAdjust::Pointer _user_appdata_directory;
279 static TVOLATILE AtomicAdjust::Pointer _common_appdata_directory;
283 static string _internal_data_dir;
290 static void init_type() {
291 register_type(_type_handle,
"Filename");
298 INLINE ostream &operator << (ostream &out,
const Filename &n) {
303 #include "filename.I"
The name of a file, such as a texture file or an Egg file.
An STL function object class, this is intended to be used on any ordered collection of class objects ...
This class stores a list of directories that can be searched, in order, to locate a particular file...
TypeHandle is the identifier used to differentiate C++ class types.