+
+ // the usual stuff
+ wxFileName() { Clear(); }
+ wxFileName(const wxFileName& filepath) { Assign(filepath); }
+
+ // from a full filename: if it terminates with a '/', a directory path
+ // is contructed (the name will be empty), otherwise a file name and
+ // extension are extracted from it
+ wxFileName( const wxString& fullpath, wxPathFormat format = wxPATH_NATIVE )
+ { Assign( fullpath, format ); }
+
+ // from a directory name and a file name
+ wxFileName(const wxString& path,
+ const wxString& name,
+ wxPathFormat format = wxPATH_NATIVE)
+ { Assign(path, name, format); }
+
+ // from a volume, directory name, file base name and extension
+ wxFileName(const wxString& volume,
+ const wxString& path,
+ const wxString& name,
+ const wxString& ext,
+ wxPathFormat format = wxPATH_NATIVE)
+ { Assign(volume, path, name, ext, format); }
+
+ // from a directory name, file base name and extension
+ wxFileName(const wxString& path,
+ const wxString& name,
+ const wxString& ext,
+ wxPathFormat format = wxPATH_NATIVE)
+ { Assign(path, name, ext, format); }
+
+ // the same for delayed initialization
+
+ void Assign(const wxFileName& filepath);
+
+ void Assign(const wxString& fullpath,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ void Assign(const wxString& volume,
+ const wxString& path,
+ const wxString& name,
+ const wxString& ext,
+ bool hasExt,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ void Assign(const wxString& volume,
+ const wxString& path,
+ const wxString& name,
+ const wxString& ext,
+ wxPathFormat format = wxPATH_NATIVE)
+ { Assign(volume, path, name, ext, !ext.empty(), format); }
+
+ void Assign(const wxString& path,
+ const wxString& name,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ void Assign(const wxString& path,
+ const wxString& name,
+ const wxString& ext,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE);
+
+ // assorted assignment operators
+
+ wxFileName& operator=(const wxFileName& filename)
+ { if (this != &filename) Assign(filename); return *this; }
+
+ wxFileName& operator=(const wxString& filename)
+ { Assign(filename); return *this; }
+
+ // reset all components to default, uninitialized state
+ void Clear();
+
+ // static pseudo constructors
+ static wxFileName FileName(const wxString& file,
+ wxPathFormat format = wxPATH_NATIVE);
+ static wxFileName DirName(const wxString& dir,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ // file tests
+
+ // is the filename valid at all?
+ bool IsOk() const
+ {
+ // we're fine if we have the path or the name or if we're a root dir
+ return m_dirs.size() != 0 || !m_name.empty() || !m_relative ||
+ !m_ext.empty() || m_hasExt;
+ }
+
+ // does the file with this name exists?
+ bool FileExists() const;
+ static bool FileExists( const wxString &file );
+
+ // does the directory with this name exists?
+ bool DirExists() const;
+ static bool DirExists( const wxString &dir );
+
+ // checks on most common flags for files/directories;
+ // more platform-specific features (like e.g. Unix permissions) are not
+ // available in wxFileName
+
+ bool IsDirWritable() const { return wxIsWritable(GetPath()); }
+ static bool IsDirWritable(const wxString &path) { return wxDirExists(path) && wxIsWritable(path); }
+
+ bool IsDirReadable() const { return wxIsReadable(GetPath()); }
+ static bool IsDirReadable(const wxString &path) { return wxDirExists(path) && wxIsReadable(path); }
+
+ // NOTE: IsDirExecutable() is not present because the meaning of "executable"
+ // directory is very platform-dependent and also not so useful
+
+ bool IsFileWritable() const { return wxIsWritable(GetFullPath()); }
+ static bool IsFileWritable(const wxString &path) { return wxFileExists(path) && wxIsWritable(path); }
+
+ bool IsFileReadable() const { return wxIsReadable(GetFullPath()); }
+ static bool IsFileReadable(const wxString &path) { return wxFileExists(path) && wxIsReadable(path); }
+
+ bool IsFileExecutable() const { return wxIsExecutable(GetFullPath()); }
+ static bool IsFileExecutable(const wxString &path) { return wxFileExists(path) && wxIsExecutable(path); }
+
+
+ // time functions
+#if wxUSE_DATETIME
+ // set the file last access/mod and creation times
+ // (any of the pointers may be NULL)
+ bool SetTimes(const wxDateTime *dtAccess,
+ const wxDateTime *dtMod,
+ const wxDateTime *dtCreate);
+
+ // set the access and modification times to the current moment
+ bool Touch();
+
+ // return the last access, last modification and create times
+ // (any of the pointers may be NULL)
+ bool GetTimes(wxDateTime *dtAccess,
+ wxDateTime *dtMod,
+ wxDateTime *dtCreate) const;
+
+ // convenience wrapper: get just the last mod time of the file
+ wxDateTime GetModificationTime() const
+ {
+ wxDateTime dtMod;
+ (void)GetTimes(NULL, &dtMod, NULL);
+ return dtMod;
+ }
+#endif // wxUSE_DATETIME
+
+#if defined( __WXOSX_MAC__ ) && wxOSX_USE_CARBON
+ bool MacSetTypeAndCreator( wxUint32 type , wxUint32 creator ) ;
+ bool MacGetTypeAndCreator( wxUint32 *type , wxUint32 *creator ) ;
+ // gets the 'common' type and creator for a certain extension
+ static bool MacFindDefaultTypeAndCreator( const wxString& ext , wxUint32 *type , wxUint32 *creator ) ;
+ // registers application defined extensions and their default type and creator
+ static void MacRegisterDefaultTypeAndCreator( const wxString& ext , wxUint32 type , wxUint32 creator ) ;
+ // looks up the appropriate type and creator from the registration and then sets
+ bool MacSetDefaultTypeAndCreator() ;
+#endif
+
+ // various file/dir operations
+
+ // retrieve the value of the current working directory
+ void AssignCwd(const wxString& volume = wxEmptyString);
+ static wxString GetCwd(const wxString& volume = wxEmptyString);
+
+ // change the current working directory
+ bool SetCwd();
+ static bool SetCwd( const wxString &cwd );
+
+ // get the value of user home (Unix only mainly)
+ void AssignHomeDir();
+ static wxString GetHomeDir();
+
+ // get the system temporary directory
+ static wxString GetTempDir();
+
+#if wxUSE_FILE || wxUSE_FFILE
+ // get a temp file name starting with the specified prefix
+ void AssignTempFileName(const wxString& prefix);
+ static wxString CreateTempFileName(const wxString& prefix);
+#endif // wxUSE_FILE
+
+#if wxUSE_FILE
+ // get a temp file name starting with the specified prefix and open the
+ // file passed to us using this name for writing (atomically if
+ // possible)
+ void AssignTempFileName(const wxString& prefix, wxFile *fileTemp);
+ static wxString CreateTempFileName(const wxString& prefix,
+ wxFile *fileTemp);
+#endif // wxUSE_FILE
+
+#if wxUSE_FFILE
+ // get a temp file name starting with the specified prefix and open the
+ // file passed to us using this name for writing (atomically if
+ // possible)
+ void AssignTempFileName(const wxString& prefix, wxFFile *fileTemp);
+ static wxString CreateTempFileName(const wxString& prefix,
+ wxFFile *fileTemp);
+#endif // wxUSE_FFILE
+
+ // directory creation and removal.
+ bool Mkdir(int perm = wxS_DIR_DEFAULT, int flags = 0);
+ static bool Mkdir(const wxString &dir, int perm = wxS_DIR_DEFAULT,
+ int flags = 0);
+
+ bool Rmdir(int flags = 0);
+ static bool Rmdir(const wxString &dir, int flags = 0);
+
+ // operations on the path
+
+ // normalize the path: with the default flags value, the path will be
+ // made absolute, without any ".." and "." and all environment
+ // variables will be expanded in it
+ //
+ // this may be done using another (than current) value of cwd
+ bool Normalize(int flags = wxPATH_NORM_ALL,
+ const wxString& cwd = wxEmptyString,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ // get a path path relative to the given base directory, i.e. opposite
+ // of Normalize
+ //
+ // pass an empty string to get a path relative to the working directory
+ //
+ // returns true if the file name was modified, false if we failed to do
+ // anything with it (happens when the file is on a different volume,
+ // for example)
+ bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
+ wxPathFormat format = wxPATH_NATIVE);
+
+ // make the path absolute
+ //
+ // this may be done using another (than current) value of cwd
+ bool MakeAbsolute(const wxString& cwd = wxEmptyString,
+ wxPathFormat format = wxPATH_NATIVE)
+ { return Normalize(wxPATH_NORM_DOTS | wxPATH_NORM_ABSOLUTE |
+ wxPATH_NORM_TILDE, cwd, format); }
+
+#if defined(__WIN32__) && !defined(__WXWINCE__) && wxUSE_OLE
+ // if the path is a shortcut, return the target and optionally,
+ // the arguments
+ bool GetShortcutTarget(const wxString& shortcutPath,
+ wxString& targetFilename,
+ wxString* arguments = NULL);
+#endif
+
+#ifndef __WXWINCE__
+ // if the path contains the value of the environment variable named envname
+ // then this function replaces it with the string obtained from
+ // wxString::Format(replacementFmtString, value_of_envname_variable)
+ //
+ // Example:
+ // wxFileName fn("/usr/openwin/lib/someFile");
+ // fn.ReplaceEnvVariable("OPENWINHOME");
+ // // now fn.GetFullPath() == "$OPENWINHOME/lib/someFile"
+ bool ReplaceEnvVariable(const wxString& envname,
+ const wxString& replacementFmtString = "$%s",
+ wxPathFormat format = wxPATH_NATIVE);
+#endif
+
+ // replaces, if present in the path, the home directory for the given user
+ // (see wxGetHomeDir) with a tilde
+ bool ReplaceHomeDir(wxPathFormat format = wxPATH_NATIVE);
+
+