]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filename.h
use bool expression rather than implicit conversion
[wxWidgets.git] / include / wx / filename.h
CommitLineData
df5ddbca 1/////////////////////////////////////////////////////////////////////////////
097ead30
VZ
2// Name: wx/filename.h
3// Purpose: wxFileName - encapsulates a file path
844f90fb 4// Author: Robert Roebling, Vadim Zeitlin
df5ddbca
RR
5// Modified by:
6// Created: 28.12.00
7// RCS-ID: $Id$
8// Copyright: (c) 2000 Robert Roebling
65571936 9// Licence: wxWindows licence
df5ddbca
RR
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_FILENAME_H_
13#define _WX_FILENAME_H_
14
9e8d8607
VZ
15/*
16 TODO:
17
18 1. support for drives under Windows
19 2. more file operations:
20 a) chmod()
21 b) [acm]time() - get and set
3ff07edb 22 c) rename()?
9e8d8607
VZ
23 3. SameFileAs() function to compare inodes under Unix
24 */
25
20ceebaa 26#include "wx/arrstr.h"
ee66f092 27#include "wx/filefn.h"
ce16e5d7 28#include "wx/datetime.h"
98080d5c 29#include "wx/intl.h"
8e16c3f2 30#include "wx/longlong.h"
a18d02ec 31#include "wx/file.h"
df5ddbca 32
68351053 33#if wxUSE_FILE
b5dbe15d 34class WXDLLIMPEXP_FWD_BASE wxFile;
68351053 35#endif
df22f860 36
b70a2866 37#if wxUSE_FFILE
b5dbe15d 38class WXDLLIMPEXP_FWD_BASE wxFFile;
b70a2866
MW
39#endif
40
35c2aa4f
VZ
41// this symbol is defined for the platforms where file systems use volumes in
42// paths
43#if defined(__WXMSW__) || defined(__DOS__) || defined(__OS2__)
44 #define wxHAS_FILESYSTEM_VOLUMES
45#endif
46
097ead30
VZ
47// ----------------------------------------------------------------------------
48// constants
49// ----------------------------------------------------------------------------
50
51// the various values for the path format: this mainly affects the path
52// separator but also whether or not the path has the drive part (as under
53// Windows)
df5ddbca
RR
54enum wxPathFormat
55{
844f90fb 56 wxPATH_NATIVE = 0, // the path format for the current platform
097ead30 57 wxPATH_UNIX,
f363e05c 58 wxPATH_BEOS = wxPATH_UNIX,
097ead30
VZ
59 wxPATH_MAC,
60 wxPATH_DOS,
f363e05c
VZ
61 wxPATH_WIN = wxPATH_DOS,
62 wxPATH_OS2 = wxPATH_DOS,
3c621059 63 wxPATH_VMS,
ee66f092 64
f363e05c 65 wxPATH_MAX // Not a valid value for specifying path format
097ead30 66};
ee66f092 67
097ead30
VZ
68// the kind of normalization to do with the file name: these values can be
69// or'd together to perform several operations at once
70enum wxPathNormalize
71{
72 wxPATH_NORM_ENV_VARS = 0x0001, // replace env vars with their values
844f90fb 73 wxPATH_NORM_DOTS = 0x0002, // squeeze all .. and . and prepend cwd
097ead30 74 wxPATH_NORM_TILDE = 0x0004, // Unix only: replace ~ and ~user
844f90fb
VZ
75 wxPATH_NORM_CASE = 0x0008, // if case insensitive => tolower
76 wxPATH_NORM_ABSOLUTE = 0x0010, // make the path absolute
9e9b65c1 77 wxPATH_NORM_LONG = 0x0020, // make the path the long form
21f60945
JS
78 wxPATH_NORM_SHORTCUT = 0x0040, // resolve the shortcut, if it is a shortcut
79 wxPATH_NORM_ALL = 0x00ff & ~wxPATH_NORM_CASE
df5ddbca
RR
80};
81
33b97389
VZ
82// what exactly should GetPath() return?
83enum
84{
35c2aa4f 85 wxPATH_NO_SEPARATOR = 0x0000, // for symmetry with wxPATH_GET_SEPARATOR
33b97389
VZ
86 wxPATH_GET_VOLUME = 0x0001, // include the volume if applicable
87 wxPATH_GET_SEPARATOR = 0x0002 // terminate the path with the separator
88};
89
110c5094 90// Mkdir flags
1527281e
VZ
91enum
92{
93 wxPATH_MKDIR_FULL = 0x0001 // create directories recursively
94};
95
110c5094
VZ
96// Rmdir flags
97enum
98{
99 wxPATH_RMDIR_FULL = 0x0001, // delete with subdirectories if empty
100 wxPATH_RMDIR_RECURSIVE = 0x0002 // delete all recursively (dangerous!)
101};
102
bd08f2f7 103#if wxUSE_LONGLONG
98080d5c 104// error code of wxFileName::GetSize()
060668a1 105extern WXDLLIMPEXP_DATA_BASE(const wxULongLong) wxInvalidSize;
bd08f2f7 106#endif // wxUSE_LONGLONG
98080d5c
JS
107
108
3ff07edb 109
097ead30
VZ
110// ----------------------------------------------------------------------------
111// wxFileName: encapsulates a file path
112// ----------------------------------------------------------------------------
113
bddd7a8d 114class WXDLLIMPEXP_BASE wxFileName
df5ddbca
RR
115{
116public:
117 // constructors and assignment
844f90fb
VZ
118
119 // the usual stuff
fb969475 120 wxFileName() { Clear(); }
520200fd 121 wxFileName(const wxFileName& filepath) { Assign(filepath); }
844f90fb
VZ
122
123 // from a full filename: if it terminates with a '/', a directory path
124 // is contructed (the name will be empty), otherwise a file name and
125 // extension are extracted from it
126 wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE )
127 { Assign( fullpath, format ); }
128
129 // from a directory name and a file name
130 wxFileName(const wxString& path,
131 const wxString& name,
132 wxPathFormat format = wxPATH_NATIVE)
133 { Assign(path, name, format); }
134
81f25632
VZ
135 // from a volume, directory name, file base name and extension
136 wxFileName(const wxString& volume,
137 const wxString& path,
138 const wxString& name,
139 const wxString& ext,
140 wxPathFormat format = wxPATH_NATIVE)
141 { Assign(volume, path, name, ext, format); }
142
844f90fb
VZ
143 // from a directory name, file base name and extension
144 wxFileName(const wxString& path,
145 const wxString& name,
146 const wxString& ext,
147 wxPathFormat format = wxPATH_NATIVE)
148 { Assign(path, name, ext, format); }
149
844f90fb
VZ
150 // the same for delayed initialization
151
844f90fb 152 void Assign(const wxFileName& filepath);
04c943b1 153
844f90fb
VZ
154 void Assign(const wxString& fullpath,
155 wxPathFormat format = wxPATH_NATIVE);
04c943b1
VZ
156
157 void Assign(const wxString& volume,
158 const wxString& path,
159 const wxString& name,
160 const wxString& ext,
dfecbee5 161 bool hasExt,
04c943b1
VZ
162 wxPathFormat format = wxPATH_NATIVE);
163
dfecbee5
VZ
164 void Assign(const wxString& volume,
165 const wxString& path,
166 const wxString& name,
167 const wxString& ext,
168 wxPathFormat format = wxPATH_NATIVE)
169 { Assign(volume, path, name, ext, !ext.empty(), format); }
170
844f90fb
VZ
171 void Assign(const wxString& path,
172 const wxString& name,
173 wxPathFormat format = wxPATH_NATIVE);
04c943b1 174
844f90fb
VZ
175 void Assign(const wxString& path,
176 const wxString& name,
177 const wxString& ext,
4c2deb19 178 wxPathFormat format = wxPATH_NATIVE);
04c943b1 179
52dbd056 180 void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE);
844f90fb 181
788722ac
JS
182 // assorted assignment operators
183
184 wxFileName& operator=(const wxFileName& filename)
a09307ab 185 { if (this != &filename) Assign(filename); return *this; }
788722ac
JS
186
187 wxFileName& operator=(const wxString& filename)
188 { Assign(filename); return *this; }
189
844f90fb
VZ
190 // reset all components to default, uninitialized state
191 void Clear();
192
193 // static pseudo constructors
520200fd
VZ
194 static wxFileName FileName(const wxString& file,
195 wxPathFormat format = wxPATH_NATIVE);
196 static wxFileName DirName(const wxString& dir,
197 wxPathFormat format = wxPATH_NATIVE);
844f90fb 198
951cd180 199 // file tests
844f90fb
VZ
200
201 // is the filename valid at all?
a96b8d39 202 bool IsOk() const
a62848fd 203 {
a96b8d39 204 // we're fine if we have the path or the name or if we're a root dir
27b2dd53 205 return m_dirs.size() != 0 || !m_name.empty() || !m_relative ||
dfecbee5 206 !m_ext.empty() || m_hasExt;
a96b8d39 207 }
844f90fb
VZ
208
209 // does the file with this name exists?
8e41796c 210 bool FileExists() const;
a35b27b1 211 static bool FileExists( const wxString &file );
097ead30 212
844f90fb 213 // does the directory with this name exists?
8e41796c 214 bool DirExists() const;
a35b27b1 215 static bool DirExists( const wxString &dir );
097ead30 216
3ff07edb
RR
217 // checks on most common flags for files/directories;
218 // more platform-specific features (like e.g. Unix permissions) are not
219 // available in wxFileName
220
221 bool IsDirWritable() const { return wxIsWritable(GetPath()); }
222 static bool IsDirWritable(const wxString &path) { return wxDirExists(path) && wxIsWritable(path); }
223
224 bool IsDirReadable() const { return wxIsReadable(GetPath()); }
225 static bool IsDirReadable(const wxString &path) { return wxDirExists(path) && wxIsReadable(path); }
226
227 // NOTE: IsDirExecutable() is not present because the meaning of "executable"
228 // directory is very platform-dependent and also not so useful
229
230 bool IsFileWritable() const { return wxIsWritable(GetFullPath()); }
231 static bool IsFileWritable(const wxString &path) { return wxFileExists(path) && wxIsWritable(path); }
232
233 bool IsFileReadable() const { return wxIsReadable(GetFullPath()); }
234 static bool IsFileReadable(const wxString &path) { return wxFileExists(path) && wxIsReadable(path); }
235
236 bool IsFileExecutable() const { return wxIsExecutable(GetFullPath()); }
237 static bool IsFileExecutable(const wxString &path) { return wxFileExists(path) && wxIsExecutable(path); }
238
844f90fb 239
951cd180 240 // time functions
e2b87f38 241#if wxUSE_DATETIME
6dbb903b 242 // set the file last access/mod and creation times
951cd180 243 // (any of the pointers may be NULL)
6dbb903b
VZ
244 bool SetTimes(const wxDateTime *dtAccess,
245 const wxDateTime *dtMod,
246 const wxDateTime *dtCreate);
951cd180
VZ
247
248 // set the access and modification times to the current moment
249 bool Touch();
250
6dbb903b 251 // return the last access, last modification and create times
951cd180
VZ
252 // (any of the pointers may be NULL)
253 bool GetTimes(wxDateTime *dtAccess,
254 wxDateTime *dtMod,
6dbb903b 255 wxDateTime *dtCreate) const;
951cd180
VZ
256
257 // convenience wrapper: get just the last mod time of the file
258 wxDateTime GetModificationTime() const
259 {
260 wxDateTime dtMod;
261 (void)GetTimes(NULL, &dtMod, NULL);
262 return dtMod;
263 }
e2b87f38 264#endif // wxUSE_DATETIME
951cd180 265
ac9e3f1f 266#if defined( __WXOSX_MAC__ ) && wxOSX_USE_CARBON
4dfbcdd5
SC
267 bool MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) ;
268 bool MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) ;
269 // gets the 'common' type and creator for a certain extension
270 static bool MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator ) ;
271 // registers application defined extensions and their default type and creator
272 static void MacRegisterDefaultTypeAndCreator( const wxString& ext , wxUint32 type , wxUint32 creator ) ;
273 // looks up the appropriate type and creator from the registration and then sets
274 bool MacSetDefaultTypeAndCreator() ;
275#endif
fb969475 276
844f90fb
VZ
277 // various file/dir operations
278
279 // retrieve the value of the current working directory
6f91bc33
VZ
280 void AssignCwd(const wxString& volume = wxEmptyString);
281 static wxString GetCwd(const wxString& volume = wxEmptyString);
097ead30 282
844f90fb 283 // change the current working directory
a35b27b1
RR
284 bool SetCwd();
285 static bool SetCwd( const wxString &cwd );
097ead30 286
844f90fb 287 // get the value of user home (Unix only mainly)
a35b27b1
RR
288 void AssignHomeDir();
289 static wxString GetHomeDir();
097ead30 290
8d7d6dea
JS
291 // get the system temporary directory
292 static wxString GetTempDir();
293
b70a2866
MW
294#if wxUSE_FILE || wxUSE_FFILE
295 // get a temp file name starting with the specified prefix
296 void AssignTempFileName(const wxString& prefix);
297 static wxString CreateTempFileName(const wxString& prefix);
298#endif // wxUSE_FILE
299
68351053 300#if wxUSE_FILE
df22f860
VZ
301 // get a temp file name starting with the specified prefix and open the
302 // file passed to us using this name for writing (atomically if
303 // possible)
b70a2866 304 void AssignTempFileName(const wxString& prefix, wxFile *fileTemp);
df22f860 305 static wxString CreateTempFileName(const wxString& prefix,
b70a2866 306 wxFile *fileTemp);
68351053 307#endif // wxUSE_FILE
097ead30 308
b70a2866
MW
309#if wxUSE_FFILE
310 // get a temp file name starting with the specified prefix and open the
311 // file passed to us using this name for writing (atomically if
312 // possible)
313 void AssignTempFileName(const wxString& prefix, wxFFile *fileTemp);
314 static wxString CreateTempFileName(const wxString& prefix,
315 wxFFile *fileTemp);
316#endif // wxUSE_FFILE
317
f0ce3409 318 // directory creation and removal.
110c5094
VZ
319 bool Mkdir(int perm = wxS_DIR_DEFAULT, int flags = 0);
320 static bool Mkdir(const wxString &dir, int perm = wxS_DIR_DEFAULT,
321 int flags = 0);
097ead30 322
110c5094
VZ
323 bool Rmdir(int flags = 0);
324 static bool Rmdir(const wxString &dir, int flags = 0);
097ead30 325
844f90fb
VZ
326 // operations on the path
327
328 // normalize the path: with the default flags value, the path will be
329 // made absolute, without any ".." and "." and all environment
330 // variables will be expanded in it
331 //
332 // this may be done using another (than current) value of cwd
32a0d013 333 bool Normalize(int flags = wxPATH_NORM_ALL,
844f90fb
VZ
334 const wxString& cwd = wxEmptyString,
335 wxPathFormat format = wxPATH_NATIVE);
097ead30 336
f7d886af
VZ
337 // get a path path relative to the given base directory, i.e. opposite
338 // of Normalize
339 //
340 // pass an empty string to get a path relative to the working directory
341 //
f363e05c 342 // returns true if the file name was modified, false if we failed to do
f7d886af
VZ
343 // anything with it (happens when the file is on a different volume,
344 // for example)
fda7962d 345 bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
f7d886af
VZ
346 wxPathFormat format = wxPATH_NATIVE);
347
0894707e
VS
348 // make the path absolute
349 //
350 // this may be done using another (than current) value of cwd
351 bool MakeAbsolute(const wxString& cwd = wxEmptyString,
352 wxPathFormat format = wxPATH_NATIVE)
353 { return Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE |
354 wxPATH_NORM_TILDE, cwd, format); }
f7d886af 355
ff95fdbb 356#if defined(__WIN32__) && !defined(__WXWINCE__) && wxUSE_OLE
21f60945
JS
357 // if the path is a shortcut, return the target and optionally,
358 // the arguments
ff95fdbb
VS
359 bool GetShortcutTarget(const wxString& shortcutPath,
360 wxString& targetFilename,
361 wxString* arguments = NULL);
21f60945
JS
362#endif
363
395f3aa8
FM
364#ifndef __WXWINCE__
365 // if the path contains the value of the environment variable named envname
366 // then this function replaces it with the string obtained from
367 // wxString::Format(replacementFmtString, value_of_envname_variable)
368 //
369 // Example:
370 // wxFileName fn("/usr/openwin/lib/someFile");
371 // fn.ReplaceEnvVariable("OPENWINHOME");
372 // // now fn.GetFullPath() == "$OPENWINHOME/lib/someFile"
373 bool ReplaceEnvVariable(const wxString& envname,
374 const wxString& replacementFmtString = "$%s",
375 wxPathFormat format = wxPATH_NATIVE);
376#endif
377
378 // replaces, if present in the path, the home directory for the given user
379 // (see wxGetHomeDir) with a tilde
380 bool ReplaceHomeDir(wxPathFormat format = wxPATH_NATIVE);
381
382
df5ddbca 383 // Comparison
844f90fb 384
2b5f62a0
VZ
385 // compares with the rules of the given platforms format
386 bool SameAs(const wxFileName& filepath,
387 wxPathFormat format = wxPATH_NATIVE) const;
388
389 // compare with another filename object
390 bool operator==(const wxFileName& filename) const
391 { return SameAs(filename); }
392 bool operator!=(const wxFileName& filename) const
393 { return !SameAs(filename); }
394
395 // compare with a filename string interpreted as a native file name
396 bool operator==(const wxString& filename) const
397 { return SameAs(wxFileName(filename)); }
398 bool operator!=(const wxString& filename) const
399 { return !SameAs(wxFileName(filename)); }
844f90fb 400
04c943b1 401 // are the file names of this type cases sensitive?
844f90fb 402 static bool IsCaseSensitive( wxPathFormat format = wxPATH_NATIVE );
04c943b1
VZ
403
404 // is this filename absolute?
6d3d1c2e 405 bool IsAbsolute(wxPathFormat format = wxPATH_NATIVE) const;
844f90fb 406
04c943b1 407 // is this filename relative?
6d3d1c2e
VZ
408 bool IsRelative(wxPathFormat format = wxPATH_NATIVE) const
409 { return !IsAbsolute(format); }
04c943b1 410
f363e05c
VZ
411 // Returns the characters that aren't allowed in filenames
412 // on the specified platform.
413 static wxString GetForbiddenChars(wxPathFormat format = wxPATH_NATIVE);
414
04c943b1
VZ
415 // Information about path format
416
6d3d1c2e
VZ
417 // get the string separating the volume from the path for this format,
418 // return an empty string if this format doesn't support the notion of
419 // volumes at all
04c943b1
VZ
420 static wxString GetVolumeSeparator(wxPathFormat format = wxPATH_NATIVE);
421
844f90fb
VZ
422 // get the string of path separators for this format
423 static wxString GetPathSeparators(wxPathFormat format = wxPATH_NATIVE);
424
f1e77933
VZ
425 // get the string of path terminators, i.e. characters which terminate the
426 // path
427 static wxString GetPathTerminators(wxPathFormat format = wxPATH_NATIVE);
428
6d3d1c2e 429 // get the canonical path separator for this format
c9f78968 430 static wxUniChar GetPathSeparator(wxPathFormat format = wxPATH_NATIVE)
6d3d1c2e
VZ
431 { return GetPathSeparators(format)[0u]; }
432
844f90fb
VZ
433 // is the char a path separator for this format?
434 static bool IsPathSeparator(wxChar ch, wxPathFormat format = wxPATH_NATIVE);
435
df5ddbca 436 // Dir accessors
df5168c4 437 size_t GetDirCount() const { return m_dirs.size(); }
2458d90b
VZ
438 void AppendDir(const wxString& dir);
439 void PrependDir(const wxString& dir);
440 void InsertDir(size_t before, const wxString& dir);
441 void RemoveDir(size_t pos);
442 void RemoveLastDir() { RemoveDir(GetDirCount() - 1); }
097ead30 443
df5ddbca 444 // Other accessors
0b40f3d8
RR
445 void SetExt( const wxString &ext ) { m_ext = ext; m_hasExt = !m_ext.empty(); }
446 void ClearExt() { m_ext = wxEmptyString; m_hasExt = false; }
447 void SetEmptyExt() { m_ext = wxT(""); m_hasExt = true; }
df5ddbca 448 wxString GetExt() const { return m_ext; }
4d4edca3 449 bool HasExt() const { return m_hasExt; }
097ead30 450
df5ddbca
RR
451 void SetName( const wxString &name ) { m_name = name; }
452 wxString GetName() const { return m_name; }
04c943b1
VZ
453 bool HasName() const { return !m_name.empty(); }
454
455 void SetVolume( const wxString &volume ) { m_volume = volume; }
456 wxString GetVolume() const { return m_volume; }
457 bool HasVolume() const { return !m_volume.empty(); }
097ead30 458
7124df9b
VZ
459 // full name is the file name + extension (but without the path)
460 void SetFullName(const wxString& fullname);
844f90fb 461 wxString GetFullName() const;
097ead30 462
04c943b1 463 const wxArrayString& GetDirs() const { return m_dirs; }
097ead30 464
33b97389 465 // flags are combination of wxPATH_GET_XXX flags
93fa67c0
VZ
466 wxString GetPath(int flags = wxPATH_GET_VOLUME,
467 wxPathFormat format = wxPATH_NATIVE) const;
33b97389 468
a7b51bc8
RR
469 // Replace current path with this one
470 void SetPath( const wxString &path, wxPathFormat format = wxPATH_NATIVE );
097ead30 471
df5ddbca
RR
472 // Construct full path with name and ext
473 wxString GetFullPath( wxPathFormat format = wxPATH_NATIVE ) const;
097ead30 474
9e9b65c1
JS
475 // Return the short form of the path (returns identity on non-Windows platforms)
476 wxString GetShortPath() const;
477
478 // Return the long form of the path (returns identity on non-Windows platforms)
479 wxString GetLongPath() const;
480
2db991f4
VZ
481 // Is this a file or directory (not necessarily an existing one)
482 bool IsDir() const { return m_name.empty() && m_ext.empty(); }
483
9e8d8607
VZ
484 // various helpers
485
486 // get the canonical path format for this platform
df5ddbca 487 static wxPathFormat GetFormat( wxPathFormat format = wxPATH_NATIVE );
097ead30 488
04c943b1
VZ
489 // split a fullpath into the volume, path, (base) name and extension
490 // (all of the pointers can be NULL)
9e8d8607 491 static void SplitPath(const wxString& fullpath,
04c943b1 492 wxString *volume,
9e8d8607
VZ
493 wxString *path,
494 wxString *name,
495 wxString *ext,
dfecbee5 496 bool *hasExt = NULL,
9e8d8607
VZ
497 wxPathFormat format = wxPATH_NATIVE);
498
dfecbee5
VZ
499 static void SplitPath(const wxString& fullpath,
500 wxString *volume,
501 wxString *path,
502 wxString *name,
503 wxString *ext,
1a6255e6 504 wxPathFormat format)
dfecbee5
VZ
505 {
506 SplitPath(fullpath, volume, path, name, ext, NULL, format);
507 }
508
509 // compatibility version: volume is part of path
04c943b1
VZ
510 static void SplitPath(const wxString& fullpath,
511 wxString *path,
512 wxString *name,
513 wxString *ext,
6f91bc33 514 wxPathFormat format = wxPATH_NATIVE);
04c943b1 515
f1e77933
VZ
516 // split a path into volume and pure path part
517 static void SplitVolume(const wxString& fullpathWithVolume,
518 wxString *volume,
519 wxString *path,
520 wxPathFormat format = wxPATH_NATIVE);
33b97389 521
35c2aa4f
VZ
522#ifdef wxHAS_FILESYSTEM_VOLUMES
523 // return the string representing a file system volume, or drive
524 static wxString GetVolumeString(char drive, int flags = wxPATH_GET_SEPARATOR);
525#endif // wxHAS_FILESYSTEM_VOLUMES
526
527 // File size
98080d5c 528
bd08f2f7 529#if wxUSE_LONGLONG
98080d5c
JS
530 // returns the size of the given filename
531 wxULongLong GetSize() const;
532 static wxULongLong GetSize(const wxString &file);
533
534 // returns the size in a human readable form
64fb0e20 535 wxString GetHumanReadableSize(const wxString &nullsize = wxGetTranslation(_T("Not available")),
98080d5c
JS
536 int precision = 1) const;
537 static wxString GetHumanReadableSize(const wxULongLong &sz,
64fb0e20 538 const wxString &nullsize = wxGetTranslation(_T("Not available")),
98080d5c 539 int precision = 1);
bd08f2f7 540#endif // wxUSE_LONGLONG
98080d5c
JS
541
542
33b97389
VZ
543 // deprecated methods, don't use any more
544 // --------------------------------------
545
4ce1efe1 546#ifndef __DIGITALMARS__
33b97389
VZ
547 wxString GetPath( bool withSep, wxPathFormat format = wxPATH_NATIVE ) const
548 { return GetPath(withSep ? wxPATH_GET_SEPARATOR : 0, format); }
4ce1efe1 549#endif
33b97389 550 wxString GetPathWithSep(wxPathFormat format = wxPATH_NATIVE ) const
ab9a58f4 551 { return GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR, format); }
33b97389 552
df5ddbca 553private:
5bb9aeb2
VZ
554 // check whether this dir is valid for Append/Prepend/InsertDir()
555 static bool IsValidDirComponent(const wxString& dir);
556
04c943b1
VZ
557 // the drive/volume/device specification (always empty for Unix)
558 wxString m_volume;
559
844f90fb 560 // the path components of the file
df5ddbca 561 wxArrayString m_dirs;
844f90fb
VZ
562
563 // the file name and extension (empty for directories)
564 wxString m_name,
565 m_ext;
6d3d1c2e
VZ
566
567 // when m_dirs is empty it may mean either that we have no path at all or
568 // that our path is '/', i.e. the root directory
569 //
570 // we use m_relative to distinguish between these two cases, it will be
f363e05c 571 // true in the former and false in the latter
6d3d1c2e 572 //
f363e05c 573 // NB: the path is not absolute just because m_relative is false, it still
6d3d1c2e 574 // needs the drive (i.e. volume) in some formats (Windows)
353f41cb 575 bool m_relative;
dfecbee5
VZ
576
577 // when m_ext is empty, it may be because we don't have any extension or
578 // because we have an empty extension
579 //
580 // the difference is important as file with name "foo" and without
581 // extension has full name "foo" while with empty extension it is "foo."
582 bool m_hasExt;
df5ddbca
RR
583};
584
097ead30 585#endif // _WX_FILENAME_H_
df5ddbca 586