1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxFileName
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 /** The various values for the path format: this mainly affects the path
11 separator but also whether or not the path has the drive part
14 See wxFileName for more info.
18 wxPATH_NATIVE
= 0, //!< the path format for the current platform.
20 wxPATH_BEOS
= wxPATH_UNIX
,
23 wxPATH_WIN
= wxPATH_DOS
,
24 wxPATH_OS2
= wxPATH_DOS
,
27 wxPATH_MAX
//!< Not a valid value for specifying path format
31 /** The kind of normalization to do with the file name: these values can be
32 or'd together to perform several operations at once.
33 See wxFileName::Normalize() for more info.
37 wxPATH_NORM_ENV_VARS
= 0x0001, //!< replace env vars with their values.
38 wxPATH_NORM_DOTS
= 0x0002, //!< squeeze all .. and . and prepend cwd.
39 wxPATH_NORM_TILDE
= 0x0004, //!< Unix only: replace ~ and ~user.
40 wxPATH_NORM_CASE
= 0x0008, //!< if case insensitive => tolower.
41 wxPATH_NORM_ABSOLUTE
= 0x0010, //!< make the path absolute.
42 wxPATH_NORM_LONG
= 0x0020, //!< make the path the long form.
43 wxPATH_NORM_SHORTCUT
= 0x0040, //!< resolve the shortcut, if it is a shortcut.
44 wxPATH_NORM_ALL
= 0x00ff & ~wxPATH_NORM_CASE
48 The return value of wxFileName::GetSize() in case of error.
50 wxULongLong wxInvalidSize
;
56 wxFileName encapsulates a file name. This class serves two purposes: first, it
57 provides the functions to split the file names into components and to recombine
58 these components in the full file name which can then be passed to the OS file
59 functions (and @ref overview_filefunctions "wxWidgets functions" wrapping them).
60 Second, it includes the functions for working with the files itself. Note that
61 to change the file data you should use wxFile class instead.
62 wxFileName provides functions for working with the file attributes.
64 When working with directory names (i.e. without filename and extension)
65 make sure not to misuse the file name part of this class with the last
66 directory. Instead initialize the wxFileName instance like this:
69 wxFileName dirname( "C:\mydir", "" );
70 MyMethod( dirname.GetPath() );
73 The same can be done using the static method wxFileName::DirName():
76 wxFileName dirname = wxFileName::DirName( "C:\mydir" );
77 MyMethod( dirname.GetPath() );
80 Accordingly, methods dealing with directories or directory names like
81 wxFileName::IsDirReadable() use wxFileName::GetPath() whereas methods dealing
82 with file names like wxFileName::IsFileReadable() use wxFileName::GetFullPath().
84 If it is not known wether a string contains a directory name or a complete
85 file name (such as when interpreting user input) you need to use the static
86 function wxFileName::DirExists() (or its identical variants wxDir::Exists() and
87 wxDirExists()) and construct the wxFileName instance accordingly.
88 This will only work if the directory actually exists, of course:
92 // get input from user
95 if (wxDirExists(user_input))
96 fname.AssignDir( user_input );
98 fname.Assign( user_input );
101 Please note that many wxFileName methods accept the path format argument
102 which is by @c wxPATH_NATIVE by default meaning to use the path format
103 native for the current platform.
104 The path format affects the operation of wxFileName functions in several ways:
105 first and foremost, it defines the path separator character to use, but it
106 also affects other things such as whether the path has the drive part or not.
107 See wxPathFormat for more info.
110 @section filename_format File name format
112 wxFileName currently supports the file names in the Unix, DOS/Windows,
113 Mac OS and VMS formats. Although these formats are quite different,
114 wxFileName tries to treat them all in the same generic way.
115 It supposes that all file names consist of the following parts: the volume
116 (also known as drive under Windows or device under VMS), the path which is
117 a sequence of directory names separated by the path separators and the full
118 filename itself which, in turn, is composed from the base file name and the
119 extension. All of the individual components of the file name may be empty
120 and, for example, the volume name is always empty under Unix, but if they
121 are all empty simultaneously, the filename object is considered to be in an
122 invalid state and wxFileName::IsOk() returns false for it.
124 File names can be case-sensitive or not, the function wxFileName::IsCaseSensitive()
125 allows to determine this. The rules for determining whether the file name is
126 absolute or relative also depend on the file name format and the only portable way
127 to answer this question is to use wxFileName::IsAbsolute() or wxFileName::IsRelative()
130 Note that on Windows,"X:" refers to the current working directory on drive X.
131 Therefore, a wxFileName instance constructed from for example "X:dir/file.ext"
132 treats the portion beyond drive separator as being relative to that directory.
133 To ensure that the filename is absolute, you may use wxFileName::MakeAbsolute().
134 There is also an inverse function wxFileName::MakeRelativeTo() which undoes
135 what wxFileName::Normalize(wxPATH_NORM_DOTS) does.
136 Other functions returning information about the file format provided by this
137 class are wxFileName::GetVolumeSeparator(), wxFileName::IsPathSeparator().
140 @section filename_construction File name construction
142 You can initialize a wxFileName instance using one of the following functions:
144 @li wxFileName::wxFileName()
145 @li wxFileName::Assign()
146 @li wxFileName::AssignCwd()
147 @li wxFileName::AssignDir()
148 @li wxFileName::AssignHomeDir()
149 @li wxFileName::DirName()
150 @li wxFileName::FileName()
151 @li wxFileName::operator=()
154 @section filename_tests File name tests
156 Before doing other tests, you should use wxFileName::IsOk() to verify that
157 the filename is well defined. If it is, FileExists() can be used to test whether
158 a file with such name exists and wxFileName::DirExists() can be used to test
159 for directory existence.
160 File names should be compared using the wxFileName::SameAs() method or
161 wxFileName::operator==(). For testing basic access modes, you can use:
163 @li wxFileName::IsDirWritable()
164 @li wxFileName::IsDirReadable()
165 @li wxFileName::IsFileWritable()
166 @li wxFileName::IsFileReadable()
167 @li wxFileName::IsFileExecutable()
170 @section filename_components File name components
172 These functions allow to examine and modify the individual directories
175 @li wxFileName::AppendDir()
176 @li wxFileName::InsertDir()
177 @li wxFileName::GetDirCount()
178 @li wxFileName::PrependDir()
179 @li wxFileName::RemoveDir()
180 @li wxFileName::RemoveLastDir()
182 To change the components of the file name individually you can use the
185 @li wxFileName::GetExt()
186 @li wxFileName::GetName()
187 @li wxFileName::GetVolume()
188 @li wxFileName::HasExt()
189 @li wxFileName::HasName()
190 @li wxFileName::HasVolume()
191 @li wxFileName::SetExt()
192 @li wxFileName::ClearExt()
193 @li wxFileName::SetEmptyExt()
194 @li wxFileName::SetName()
195 @li wxFileName::SetVolume()
197 You can initialize a wxFileName instance using one of the following functions:
200 @section filename_operations File name operations
202 These methods allow to work with the file creation, access and modification
203 times. Note that not all filesystems under all platforms implement these times
204 in the same way. For example, the access time under Windows has a resolution of
205 one day (so it is really the access date and not time). The access time may be
206 updated when the file is executed or not depending on the platform.
208 @li wxFileName::GetModificationTime()
209 @li wxFileName::GetTimes()
210 @li wxFileName::SetTimes()
211 @li wxFileName::Touch()
213 Other file system operations functions are:
215 @li wxFileName::Mkdir()
216 @li wxFileName::Rmdir()
233 wxFileName(const wxFileName
& filename
);
236 Constructor taking a full filename.
238 If it terminates with a '/', a directory path is constructed
239 (the name will be empty), otherwise a file name and extension
240 are extracted from it.
242 wxFileName(const wxString
& fullpath
,
243 wxPathFormat format
= wxPATH_NATIVE
);
246 Constructor a directory name and file name.
248 wxFileName(const wxString
& path
, const wxString
& name
,
249 wxPathFormat format
= wxPATH_NATIVE
);
252 Constructor from a directory name, base file name and extension.
254 wxFileName(const wxString
& path
, const wxString
& name
,
256 wxPathFormat format
= wxPATH_NATIVE
);
259 Constructor from a volume name, a directory name, base file name and extension.
261 wxFileName(const wxString
& volume
, const wxString
& path
,
262 const wxString
& name
,
264 wxPathFormat format
= wxPATH_NATIVE
);
267 Appends a directory component to the path. This component should contain a
268 single directory name level, i.e. not contain any path or volume separators nor
269 should it be empty, otherwise the function does nothing (and generates an
270 assert failure in debug build).
272 void AppendDir(const wxString
& dir
);
275 Creates the file name from another filename object.
277 void Assign(const wxFileName
& filepath
);
280 Creates the file name from a full file name with a path.
282 void Assign(const wxString
& fullpath
,
283 wxPathFormat format
= wxPATH_NATIVE
);
286 Creates the file name from volumne, path, name and extension.
288 void Assign(const wxString
& volume
, const wxString
& path
,
289 const wxString
& name
,
292 wxPathFormat format
= wxPATH_NATIVE
);
295 Creates the file name from volumne, path, name and extension.
297 void Assign(const wxString
& volume
, const wxString
& path
,
298 const wxString
& name
,
300 wxPathFormat format
= wxPATH_NATIVE
);
303 Creates the file name from file path and file name.
305 void Assign(const wxString
& path
, const wxString
& name
,
306 wxPathFormat format
= wxPATH_NATIVE
);
309 Creates the file name from path, name and extension.
311 void Assign(const wxString
& path
, const wxString
& name
,
313 wxPathFormat format
= wxPATH_NATIVE
);
316 Makes this object refer to the current working directory on the specified
317 volume (or current volume if @a volume is empty).
321 static void AssignCwd(const wxString
& volume
= wxEmptyString
);
324 Sets this file name object to the given directory name.
325 The name and extension will be empty.
327 void AssignDir(const wxString
& dir
,
328 wxPathFormat format
= wxPATH_NATIVE
);
331 Sets this file name object to the home directory.
333 void AssignHomeDir();
336 The function calls CreateTempFileName() to create a temporary file
337 and sets this object to the name of the file.
338 If a temporary file couldn't be created, the object is put into
339 an invalid state (see IsOk())
341 void AssignTempFileName(const wxString
& prefix
,
342 wxFile
* fileTemp
= NULL
);
345 Reset all components to default, uninitialized state.
350 Removes the extension from the file name resulting in a
351 file name with no trailing dot.
353 @see SetExt(), SetEmptyExt()
358 Returns a temporary file name starting with the given @e prefix.
359 If the @a prefix is an absolute path, the temporary file is created in this
360 directory, otherwise it is created in the default system directory for the
361 temporary files or in the current directory.
363 If the function succeeds, the temporary file is actually created.
364 If @a fileTemp is not @NULL, this file will be opened using the name of
365 the temporary file. When possible, this is done in an atomic way ensuring that
366 no race condition occurs between the temporary file name generation and opening
367 it which could often lead to security compromise on the multiuser systems.
368 If @a fileTemp is @NULL, the file is only created, but not opened.
369 Under Unix, the temporary file will have read and write permissions for the
370 owner only to minimize the security problems.
373 Prefix to use for the temporary file name construction
375 The file to open or @NULL to just get the name
377 @return The full temporary file name or an empty string on error.
379 static wxString
CreateTempFileName(const wxString
& prefix
,
380 wxFile
* fileTemp
= NULL
);
383 Returns @true if the directory with this name exists.
385 bool DirExists() const;
388 Returns @true if the directory with this name exists.
390 static bool DirExists(const wxString
& dir
);
393 Returns the object corresponding to the directory with the given name.
394 The @a dir parameter may have trailing path separator or not.
396 static wxFileName
DirName(const wxString
& dir
,
397 wxPathFormat format
= wxPATH_NATIVE
);
400 Returns @true if the file with this name exists.
404 bool FileExists() const;
407 Returns @true if the file with this name exists.
411 static bool FileExists(const wxString
& file
);
414 Returns the file name object corresponding to the given @e file. This
415 function exists mainly for symmetry with DirName().
417 static wxFileName
FileName(const wxString
& file
,
418 wxPathFormat format
= wxPATH_NATIVE
);
421 Retrieves the value of the current working directory on the specified volume.
422 If the volume is empty, the program's current working directory is returned for
425 @return The string containing the current working directory or an empty
430 static wxString
GetCwd(const wxString
& volume
= wxEmptyString
);
433 Returns the number of directories in the file name.
435 size_t GetDirCount() const;
438 Returns the directories in string array form.
440 const wxArrayString
& GetDirs() const;
443 Returns the file name extension.
445 wxString
GetExt() const;
448 Returns the characters that can't be used in filenames and directory names
449 for the specified format.
451 static wxString
GetForbiddenChars(wxPathFormat format
= wxPATH_NATIVE
);
454 Returns the canonical path format for this platform.
456 static wxPathFormat
GetFormat(wxPathFormat format
= wxPATH_NATIVE
);
459 Returns the full name (including extension but excluding directories).
461 wxString
GetFullName() const;
464 Returns the full path with name and extension.
466 wxString
GetFullPath(wxPathFormat format
= wxPATH_NATIVE
) const;
469 Returns the home directory.
471 static wxString
GetHomeDir();
474 Returns the size of the file in a human-readable form.
476 If the size could not be retrieved the @c failmsg string
477 is returned. In case of success, the returned string is
478 a floating-point number with @c precision decimal digits
479 followed by the size unit (B, kB, MB, GB, TB: respectively
480 bytes, kilobytes, megabytes, gigabytes, terabytes).
482 wxString
GetHumanReadableSize(const wxString
& failmsg
= "Not available",
483 int precision
= 1) const;
486 Returns the size of the given number of bytes in a human-readable form.
488 If @a bytes is ::wxInvalidSize or zero, then @a nullsize is returned.
490 In case of success, the returned string is a floating-point number with
491 @a precision decimal digits followed by the size unit (B, kB, MB, GB,
492 TB: respectively bytes, kilobytes, megabytes, gigabytes, terabytes).
494 static wxString
GetHumanReadableSize(const wxULongLong
& bytes
,
495 const wxString
& nullsize
= "Not available",
499 Return the long form of the path (returns identity on non-Windows platforms).
501 wxString
GetLongPath() const;
504 Returns the last time the file was last modified.
506 wxDateTime
GetModificationTime() const;
509 Returns the name part of the filename (without extension).
513 wxString
GetName() const;
516 Returns the path part of the filename (without the name or extension).
518 The possible flags values are:
520 - @b wxPATH_GET_VOLUME
521 Return the path with the volume (does nothing for the filename formats
522 without volumes), otherwise the path without volume part is returned.
524 - @b wxPATH_GET_SEPARATOR:
525 Return the path with the trailing separator, if this flag is not given
526 there will be no separator at the end of the path.
528 - @b wxPATH_NO_SEPARATOR:
529 Don't include the trailing separator in the returned string. This is
530 the default (the value of this flag is 0) and exists only for symmetry
531 with wxPATH_GET_SEPARATOR.
533 wxString
GetPath(int flags
= wxPATH_GET_VOLUME
,
534 wxPathFormat format
= wxPATH_NATIVE
) const;
537 Returns the usually used path separator for this format.
538 For all formats but @c wxPATH_DOS there is only one path separator anyhow,
539 but for DOS there are two of them and the native one, i.e. the backslash
540 is returned by this method.
542 @see GetPathSeparators()
544 static wxChar
GetPathSeparator(wxPathFormat format
= wxPATH_NATIVE
);
547 Returns the string containing all the path separators for this format.
548 For all formats but @c wxPATH_DOS this string contains only one character
549 but for DOS and Windows both @c '/' and @c '\' may be used as separators.
551 @see GetPathSeparator()
553 static wxString
GetPathSeparators(wxPathFormat format
= wxPATH_NATIVE
);
556 Returns the string of characters which may terminate the path part.
557 This is the same as GetPathSeparators() except for VMS
558 path format where ] is used at the end of the path part.
560 static wxString
GetPathTerminators(wxPathFormat format
= wxPATH_NATIVE
);
563 Returns the path with the trailing separator, useful for appending the name
566 This is the same as calling
568 GetPath(wxPATH_GET_VOLUME | wxPATH_GET_SEPARATOR, format)
571 wxString
GetPathWithSep(wxPathFormat format
= wxPATH_NATIVE
) const;
574 Return the short form of the path (returns identity on non-Windows platforms).
576 wxString
GetShortPath() const;
579 Returns the size of the file If the file does not exist or its size could
580 not be read (because e.g. the file is locked by another process) the returned
581 value is ::wxInvalidSize.
583 wxULongLong
GetSize() const;
586 Returns the size of the file If the file does not exist or its size could
587 not be read (because e.g. the file is locked by another process) the returned
588 value is ::wxInvalidSize.
590 const static wxULongLong
GetSize(const wxString
& filename
);
593 Returns the directory used for temporary files.
595 static wxString
GetTempDir();
598 Returns the last access, last modification and creation times.
599 The last access time is updated whenever the file is read or written
600 (or executed in the case of Windows), last modification time is only
601 changed when the file is written to.
602 Finally, the creation time is indeed the time when the file was created
603 under Windows and the inode change time under Unix (as it is impossible to
604 retrieve the real file creation time there anyhow) which can also be changed
605 by many operations after the file creation.
607 If no filename or extension is specified in this instance of wxFileName
608 (and therefore IsDir() returns @true) then this function will return the
609 directory times of the path specified by GetPath(), otherwise the file
610 times of the file specified by GetFullPath().
611 Any of the pointers may be @NULL if the corresponding time is not needed.
613 @return @true on success, @false if we failed to retrieve the times.
615 bool GetTimes(wxDateTime
* dtAccess
, wxDateTime
* dtMod
,
616 wxDateTime
* dtCreate
) const;
619 Returns the string containing the volume for this file name, empty if it
620 doesn't have one or if the file system doesn't support volumes at all
623 wxString
GetVolume() const;
626 Returns the string separating the volume from the path for this format.
628 static wxString
GetVolumeSeparator(wxPathFormat format
= wxPATH_NATIVE
);
631 This function builds a volume path string, for example "C:\\".
633 Implemented for the platforms which use drive letters, i.e. DOS, MSW
639 The drive letter, 'A' through 'Z' or 'a' through 'z'.
642 @c wxPATH_NO_SEPARATOR or @c wxPATH_GET_SEPARATOR to omit or include
643 the trailing path separator, the default is to include it.
645 @return Volume path string.
647 static wxString
GetVolumeString(char drive
, int flags
= wxPATH_GET_SEPARATOR
);
650 Returns @true if an extension is present.
655 Returns @true if a name is present.
657 bool HasName() const;
660 Returns @true if a volume specifier is present.
662 bool HasVolume() const;
665 Inserts a directory component before the zero-based position in the directory
666 list. Please see AppendDir() for important notes.
668 void InsertDir(size_t before
, const wxString
& dir
);
671 Returns @true if this filename is absolute.
673 bool IsAbsolute(wxPathFormat format
= wxPATH_NATIVE
) const;
676 Returns @true if the file names of this type are case-sensitive.
678 static bool IsCaseSensitive(wxPathFormat format
= wxPATH_NATIVE
);
681 Returns @true if this object represents a directory, @false otherwise
682 (i.e. if it is a file).
684 Note that this method doesn't test whether the directory or file really
685 exists, you should use DirExists() or FileExists() for this.
690 Returns @true if the directory component of this instance is an existing
691 directory and this process has read permissions on it. Read permissions
692 on a directory mean that you can list the directory contents but it
693 doesn't imply that you have read permissions on the files contained.
695 bool IsDirReadable() const;
698 Returns @true if the given @e dir is an existing directory and this process
699 has read permissions on it. Read permissions on a directory mean that you
700 can list the directory contents but it doesn't imply that you have read
701 permissions on the files contained.
703 static bool IsDirReadable(const wxString
& dir
);
706 Returns @true if the directory component of this instance
707 is an existing directory and this process has write permissions on it.
708 Write permissions on a directory mean that you can create new files in the
711 bool IsDirWritable() const;
714 Returns @true if the given @a dir is an existing directory and this
715 process has write permissions on it.
716 Write permissions on a directory mean that you can create new files in the
719 static bool IsDirWritable(const wxString
& dir
);
722 Returns @true if a file with this name exists and if this process has execute
725 bool IsFileExecutable() const;
728 Returns @true if a file with this name exists and if this process has execute
731 static bool IsFileExecutable(const wxString
& file
);
734 Returns @true if a file with this name exists and if this process has read
737 bool IsFileReadable() const;
740 Returns @true if a file with this name exists and if this process has read
743 static bool IsFileReadable(const wxString
& file
);
746 Returns @true if a file with this name exists and if this process has write
749 bool IsFileWritable() const;
752 Returns @true if a file with this name exists and if this process has write
755 static bool IsFileWritable(const wxString
& file
);
758 Returns @true if the filename is valid, @false if it is not initialized yet.
759 The assignment functions and Clear() may reset the object to the uninitialized,
760 invalid state (the former only do it on failure).
765 Returns @true if the char is a path separator for this format.
767 static bool IsPathSeparator(wxChar ch
,
768 wxPathFormat format
= wxPATH_NATIVE
);
771 Returns @true if this filename is not absolute.
773 bool IsRelative(wxPathFormat format
= wxPATH_NATIVE
) const;
776 On Mac OS, gets the common type and creator for the given extension.
778 static bool MacFindDefaultTypeAndCreator(const wxString
& ext
,
783 On Mac OS, registers application defined extensions and their default type
786 static void MacRegisterDefaultTypeAndCreator(const wxString
& ext
,
791 On Mac OS, looks up the appropriate type and creator from the registration
794 bool MacSetDefaultTypeAndCreator();
797 Make the file name absolute.
798 This is a shortcut for
800 wxFileName::Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE |
801 wxPATH_NORM_TILDE, cwd, format)
804 @see MakeRelativeTo(), Normalize(), IsAbsolute()
806 bool MakeAbsolute(const wxString
& cwd
= wxEmptyString
,
807 wxPathFormat format
= wxPATH_NATIVE
);
810 This function tries to put this file name in a form relative to
812 In other words, it returns the file name which should be used to access
813 this file if the current directory were pathBase.
816 The directory to use as root, current directory is used by default
818 The file name format, native by default
820 @return @true if the file name has been changed, @false if we failed to do
821 anything with it (currently this only happens if the file name
822 is on a volume different from the volume specified by @a pathBase).
826 bool MakeRelativeTo(const wxString
& pathBase
= wxEmptyString
,
827 wxPathFormat format
= wxPATH_NATIVE
);
833 The permissions for the newly created directory.
834 See wxPosixPermissions enumeration for more info.
836 If the flags contain @c wxPATH_MKDIR_FULL flag, try to create each
837 directory in the path and also don't return an error if the target
838 directory already exists.
840 @return Returns @true if the directory was successfully created, @false
843 bool Mkdir(int perm
= wxS_DIR_DEFAULT
, int flags
= 0);
849 The directory to create
851 The permissions for the newly created directory.
852 See wxPosixPermissions enumeration for more info.
854 If the flags contain @c wxPATH_MKDIR_FULL flag, try to create each
855 directory in the path and also don't return an error if the target
856 directory already exists.
858 @return Returns @true if the directory was successfully created, @false
861 static bool Mkdir(const wxString
& dir
, int perm
= wxS_DIR_DEFAULT
,
865 Normalize the path. With the default flags value, the path will be
866 made absolute, without any ".." and "." and all environment
867 variables will be expanded in it.
870 The kind of normalization to do with the file name. It can be
871 any or-combination of the wxPathNormalize enumeration values.
873 If not empty, this directory will be used instead of current
874 working directory in normalization (see @c wxPATH_NORM_ABSOLUTE).
876 The file name format to use when processing the paths, native by default.
878 @return @true if normalization was successfully or @false otherwise.
880 bool Normalize(int flags
= wxPATH_NORM_ALL
,
881 const wxString
& cwd
= wxEmptyString
,
882 wxPathFormat format
= wxPATH_NATIVE
);
885 Prepends a directory to the file path.
886 Please see AppendDir() for important notes.
888 void PrependDir(const wxString
& dir
);
891 Removes the specified directory component from the path.
895 void RemoveDir(size_t pos
);
898 Removes last directory component from the path.
900 void RemoveLastDir();
903 Deletes the specified directory from the file system.
908 Deletes the specified directory from the file system.
910 static bool Rmdir(const wxString
& dir
);
913 Compares the filename using the rules of this platform.
915 bool SameAs(const wxFileName
& filepath
,
916 wxPathFormat format
= wxPATH_NATIVE
) const;
919 Changes the current working directory.
924 Changes the current working directory.
926 static bool SetCwd(const wxString
& cwd
);
929 Sets the extension of the file name to be an empty extension.
930 This is different from having no extension at all as the file
931 name will have a trailing dot after a call to this method.
933 @see SetExt(), ClearExt()
938 Sets the extension of the file name.
940 Setting an empty string as the extension will remove the extension
941 resulting in a file name without a trailing dot, unlike a call to
944 @see SetEmptyExt(), ClearExt()
946 void SetExt(const wxString
& ext
);
949 The full name is the file name and extension (but without the path).
951 void SetFullName(const wxString
& fullname
);
954 Sets the name part (without extension).
958 void SetName(const wxString
& name
);
961 Sets the file creation and last access/modification times (any of the pointers
964 bool SetTimes(const wxDateTime
* dtAccess
,
965 const wxDateTime
* dtMod
,
966 const wxDateTime
* dtCreate
);
969 Sets the volume specifier.
971 void SetVolume(const wxString
& volume
);
975 This function splits a full file name into components: the volume (with the
976 first version) path (including the volume in the second version), the base name
979 Any of the output parameters (@e volume, @e path, @a name or @e ext) may
980 be @NULL if you are not interested in the value of a particular component.
981 Also, @a fullpath may be empty on entry.
982 On return, @a path contains the file path (without the trailing separator),
983 @a name contains the file name and @a ext contains the file extension
984 without leading dot. All three of them may be empty if the corresponding
985 component is. The old contents of the strings pointed to by these parameters
986 will be overwritten in any case (if the pointers are not @NULL).
988 Note that for a filename "foo." the extension is present, as indicated by the
989 trailing dot, but empty. If you need to cope with such cases, you should use
990 @a hasExt instead of relying on testing whether @a ext is empty or not.
992 static void SplitPath(const wxString
& fullpath
, wxString
* volume
,
997 wxPathFormat format
= wxPATH_NATIVE
);
998 static void SplitPath(const wxString
& fullpath
,
1003 wxPathFormat format
= wxPATH_NATIVE
);
1004 static void SplitPath(const wxString
& fullpath
,
1008 wxPathFormat format
= wxPATH_NATIVE
);
1012 Splits the given @a fullpath into the volume part (which may be empty) and
1013 the pure path part, not containing any volume.
1017 static void SplitVolume(const wxString
& fullpath
,
1020 wxPathFormat format
= wxPATH_NATIVE
);
1023 Sets the access and modification times to the current moment.
1028 Returns @true if the filenames are different. The string @e filenames
1029 is interpreted as a path in the native filename format.
1031 bool operator!=(const wxFileName
& filename
) const;
1034 Returns @true if the filenames are different. The string @e filenames
1035 is interpreted as a path in the native filename format.
1037 bool operator!=(const wxString
& filename
) const;
1040 Returns @true if the filenames are equal. The string @e filenames is
1041 interpreted as a path in the native filename format.
1043 bool operator==(const wxFileName
& filename
) const;
1046 Returns @true if the filenames are equal. The string @e filenames is
1047 interpreted as a path in the native filename format.
1049 bool operator==(const wxString
& filename
) const;
1052 Assigns the new value to this filename object.
1054 wxFileName
& operator=(const wxFileName
& filename
);
1057 Assigns the new value to this filename object.
1059 wxFileName
& operator=(const wxString
& filename
);