57 INLINE
Filename(
const char *filename);
58 INLINE
Filename(
const std::string &filename);
59 INLINE
Filename(
const std::wstring &filename);
61 INLINE
Filename(std::string &&filename) noexcept;
71 EXTENSION(PyObject *__reduce__(PyObject *
self)
const);
78 INLINE
static Filename text_filename(
const std::string &filename);
80 INLINE
static Filename binary_filename(
const std::string &filename);
81 INLINE
static Filename dso_filename(
const std::string &filename);
82 INLINE
static Filename executable_filename(
const std::string &filename);
84 INLINE
static Filename pattern_filename(
const std::string &filename);
86 static Filename from_os_specific(
const std::string &os_specific,
87 Type type = T_general);
88 static Filename from_os_specific_w(
const std::wstring &os_specific,
89 Type type = T_general);
90 static Filename expand_from(
const std::string &user_string,
91 Type type = T_general);
92 static Filename temporary(
const std::string &dirname,
const std::string &prefix,
93 const std::string &suffix = std::string(),
94 Type type = T_general);
96 static const Filename &get_home_directory();
97 static const Filename &get_temp_directory();
98 static const Filename &get_user_appdata_directory();
99 static const Filename &get_common_appdata_directory();
102 INLINE
Filename &operator = (
const std::string &filename);
103 INLINE
Filename &operator = (
const std::wstring &filename);
104 INLINE
Filename &operator = (
const char *filename);
106 INLINE
Filename &operator = (std::string &&filename) noexcept;
110 INLINE
operator const std::string & ()
const;
111 INLINE
const char *c_str()
const;
112 INLINE
bool empty()
const;
113 INLINE
size_t length()
const;
114 INLINE
char operator [] (
size_t n)
const;
116 EXTENSION(PyObject *__repr__()
const);
117 EXTENSION(PyObject *__fspath__()
const);
119 INLINE std::string substr(
size_t begin)
const;
120 INLINE std::string substr(
size_t begin,
size_t end)
const;
121 INLINE
void operator += (
const std::string &other);
122 INLINE
Filename operator + (
const std::string &other)
const;
127 INLINE std::string get_fullpath()
const;
128 INLINE std::wstring get_fullpath_w()
const;
129 INLINE std::string get_dirname()
const;
130 INLINE std::string get_basename()
const;
131 INLINE std::string get_fullpath_wo_extension()
const;
132 INLINE std::string get_basename_wo_extension()
const;
133 INLINE std::string get_extension()
const;
136 void set_fullpath(
const std::string &s);
137 void set_dirname(
const std::string &s);
138 void set_basename(
const std::string &s);
139 void set_fullpath_wo_extension(
const std::string &s);
140 void set_basename_wo_extension(
const std::string &s);
141 void set_extension(
const std::string &s);
147 INLINE
void set_binary();
148 INLINE
void set_text();
149 INLINE
bool is_binary()
const;
150 INLINE
bool is_text()
const;
151 INLINE
bool is_binary_or_text()
const;
153 INLINE
void set_type(Type type);
154 INLINE Type get_type()
const;
156 INLINE
void set_pattern(
bool pattern);
157 INLINE
bool get_pattern()
const;
159 INLINE
bool has_hash()
const;
160 Filename get_filename_index(
int index)
const;
162 INLINE std::string get_hash_to_end()
const;
163 void set_hash_to_end(
const std::string &s);
165 void extract_components(vector_string &components)
const;
170 INLINE
bool is_local()
const;
171 INLINE
bool is_fully_qualified()
const;
172 void make_absolute();
173 void make_absolute(
const Filename &start_directory);
175 bool make_canonical();
176 bool make_true_case();
178 std::string to_os_specific()
const;
179 std::wstring to_os_specific_w()
const;
180 std::string to_os_generic()
const;
181 std::string to_os_short_name()
const;
182 std::string to_os_long_name()
const;
185 bool is_regular_file()
const;
186 bool is_writable()
const;
187 bool is_directory()
const;
188 bool is_executable()
const;
189 int compare_timestamps(
const Filename &other,
190 bool this_missing_is_old =
true,
191 bool other_missing_is_old =
true)
const;
192 time_t get_timestamp()
const;
193 time_t get_access_timestamp()
const;
194 std::streamsize get_file_size()
const;
196 bool resolve_filename(
const DSearchPath &searchpath,
197 const std::string &default_extension = std::string());
198 bool make_relative_to(
Filename directory,
bool allow_backups =
true);
199 int find_on_searchpath(
const DSearchPath &searchpath);
201 bool scan_directory(vector_string &contents)
const;
203 EXTENSION(PyObject *scan_directory()
const);
206 bool open_read(std::ifstream &stream)
const;
207 bool open_write(std::ofstream &stream,
bool truncate =
true)
const;
208 bool open_append(std::ofstream &stream)
const;
209 bool open_read_write(std::fstream &stream,
bool truncate =
false)
const;
210 bool open_read_append(std::fstream &stream)
const;
212 #ifdef USE_PANDAFILESTREAM
213 bool open_read(pifstream &stream)
const;
214 bool open_write(pofstream &stream,
bool truncate =
true)
const;
215 bool open_append(pofstream &stream)
const;
216 bool open_read_write(pfstream &stream,
bool truncate =
false)
const;
217 bool open_read_append(pfstream &stream)
const;
218 #endif // USE_PANDAFILESTREAM
223 BLOCKING
bool rename_to(
const Filename &other)
const;
224 BLOCKING
bool copy_to(
const Filename &other)
const;
226 bool make_dir()
const;
231 INLINE
bool operator == (
const std::string &other)
const;
232 INLINE
bool operator != (
const std::string &other)
const;
233 INLINE
bool operator < (
const std::string &other)
const;
235 INLINE
bool __nonzero__()
const;
236 int get_hash()
const;
238 INLINE
void output(std::ostream &out)
const;
240 INLINE
static void set_filesystem_encoding(TextEncoder::Encoding encoding);
241 INLINE
static TextEncoder::Encoding get_filesystem_encoding();
244 bool atomic_compare_and_exchange_contents(std::string &orig_contents,
const std::string &old_contents,
const std::string &new_contents)
const;
245 bool atomic_read_contents(std::string &contents)
const;
248 void locate_basename();
249 void locate_extension();
251 size_t get_common_prefix(
const std::string &other)
const;
252 static int count_slashes(
const std::string &str);
253 bool r_make_canonical(
const Filename &cwd);
255 std::string _filename;
259 size_t _basename_start;
260 size_t _basename_end;
261 size_t _extension_start;
267 static TextEncoder::Encoding _filesystem_encoding;
268 static TVOLATILE AtomicAdjust::Pointer _home_directory;
269 static TVOLATILE AtomicAdjust::Pointer _temp_directory;
270 static TVOLATILE AtomicAdjust::Pointer _user_appdata_directory;
271 static TVOLATILE AtomicAdjust::Pointer _common_appdata_directory;
275 static std::string _internal_data_dir;
282 static void init_type() {
290 INLINE std::ostream &operator << (std::ostream &out,
const Filename &n) {