⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filename.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
📖 第 1 页 / 共 3 页
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name:        filename.tex%% Purpose:     wxFileName documentation%% Author:      Vadim Zeitlin%% Modified by:%% Created:     30.11.01%% RCS-ID:      $Id: filename.tex,v 1.49 2006/11/19 21:08:57 RR Exp $%% Copyright:   (c) 2001 Vadim Zeitlin%% License:     wxWindows license%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{\class{wxFileName}}\label{wxfilename}wxFileName encapsulates a file name. This class serves two purposes: first, itprovides the functions to split the file names into components and to recombinethese components in the full file name which can then be passed to the OS filefunctions (and \helpref{wxWidgets functions}{filefunctions} wrapping them).Second, it includes the functions for working with the files itself. Note thatto change the file data you should use \helpref{wxFile}{wxfile} class instead.wxFileName provides functions for working with the file attributes.When working with directory names (i.e. without filename and extension)make sure not to misuse the file name part of this class with the lastdirectory. Instead initialize the wxFileName instance like this:\begin{verbatim}wxFileName dirname( wxT("C:\mydir"), wxEmptyString );MyMethod( dirname.GetPath() );\end{verbatim}The same can be done using the static method \helpref{wxFileName::DirName}{wxfilenamedirname}:\begin{verbatim}wxFileName dirname = wxFileName::DirName( wxT("C:\mydir") );MyMethod( dirname.GetPath() );\end{verbatim}Accordingly, methods dealing with directories or directory nameslike \helpref{IsDirReadable}{wxfilenameisdirreadable} use\helpref{GetPath}{wxfilenamegetpath} whereas methods dealing with file names like \helpref{IsFileReadable}{wxfilenameisfilereadable}use \helpref{GetFullPath}{wxfilenamegetfullpath}.If it is not known wether a string contains a directory name ora complete file name (such as when interpreting user input) you need to usethe static function \helpref{wxFileName::DirExists}{wxfilenamedirexists}(or its identical variants \helpref{wxDir::Exists}{wxdirexists} and\helpref{wxDirExists}{functionwxdirexists}) and construct the wxFileNameinstance accordingly. This will only work if the directory actually exists,of course:\begin{verbatim}wxString user_input;// get input from userwxFileName fname;if (wxDirExists(user_input))    fname.AssignDir( user_input );else    fname.Assign( user_input );\end{verbatim}\wxheading{Derived from}No base class\wxheading{Include files}<wx/filename.h>\wxheading{Data structures}Many wxFileName methods accept the path format argument which is by\rtfsp{\tt wxPATH\_NATIVE} by default meaning to use the path format native for thecurrent platform.The path format affects the operation of wxFileName functions in several ways:first and foremost, it defines the path separator character to use, but it alsoaffects other things such as whether the path has the drive part or not.\begin{verbatim}enum wxPathFormat{    wxPATH_NATIVE = 0,      // the path format for the current platform    wxPATH_UNIX,    wxPATH_BEOS = wxPATH_UNIX,    wxPATH_MAC,    wxPATH_DOS,    wxPATH_WIN = wxPATH_DOS,    wxPATH_OS2 = wxPATH_DOS,    wxPATH_VMS,    wxPATH_MAX // Not a valid value for specifying path format}\end{verbatim}\latexignore{\rtfignore{\wxheading{Function groups}}}\membersection{File name format}\label{filenameformat}wxFileName currently supports the file names in the Unix, DOS/Windows, Mac OSand VMS formats. Although these formats are quite different, wxFileName triesto treat them all in the same generic way. It supposes that all file namesconsist of the following parts: the volume (also known as drive under Windowsor device under VMS), the path which is a sequence of directory names separatedby the \helpref{path separators}{wxfilenamegetpathseparators} and the fullfilename itself which, in turn, is composed from the base file name and theextension. All of the individual components of the file name may be empty and,for example, the volume name is always empty under Unix, but if they are allempty simultaneously, the filename object is considered to be in an invalidstate and \helpref{IsOk}{wxfilenameisok} returns {\tt false} for it.File names can be case-sensitive or not, the function\rtfsp\helpref{IsCaseSensitive}{wxfilenameiscasesensitive} allows to determine this.The rules for determining whether the file name is absolute or relative alsodepend on the file name format and the only portable way to answer thisquestion is to use \helpref{IsAbsolute}{wxfilenameisabsolute} or\rtfsp\helpref{IsRelative}{wxfilenameisrelative} method. Note that on Windows, "X:"refers to the current working directory on drive X. Therefore, a wxFileNameinstance constructed from for example "X:dir/file.ext" treats the portion beyond drive separator as being relative to that directory.To ensure that the filename is absolute, you may use\rtfsp\helpref{MakeAbsolute}{wxfilenamemakeabsolute}. There is also an inversefunction \helpref{MakeRelativeTo}{wxfilenamemakerelativeto} which undoeswhat \helpref{Normalize(wxPATH\_NORM\_DOTS)}{wxfilenamenormalize} does.Other functions returning information about the file format provided by thisclass are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp\helpref{IsPathSeparator}{wxfilenameispathseparator}.\membersection{File name construction}\label{filenameconstruction}You can initialize a wxFileName instance using one of the following functions:\helpref{wxFileName constructors}{wxfilenamewxfilename}\\\helpref{Assign}{wxfilenameassign}\\\helpref{AssignCwd}{wxfilenameassigncwd}\\\helpref{AssignDir}{wxfilenameassigndir}\\\helpref{AssignHomeDir}{wxfilenameassignhomedir}\\\helpref{AssignHomeTempFileName}{wxfilenameassigntempfilename}\\\helpref{operator $=$}{wxfilenameoperatorassign}\membersection{File tests}\label{filetests}Before doing other tests, you should use \helpref{IsOk}{wxfilenameisok} toverify that the filename is well defined. If it is,\rtfsp\helpref{FileExists}{wxfilenamefileexists} can be used to test whether a filewith such name exists and \helpref{DirExists}{wxfilenamedirexists} can be usedto test for directory existence.File names should be compared using \helpref{SameAs}{wxfilenamesameas} methodor \helpref{operator $==$}{wxfilenameoperatorequal}.For testing basic access modes, you can use:\helpref{IsDirWritable}{wxfilenameisdirwritable}\\\helpref{IsDirReadable}{wxfilenameisdirreadable}\\\helpref{IsFileWritable}{wxfilenameisfilewritable}\\\helpref{IsFileReadable}{wxfilenameisfilereadable}\\\helpref{IsFileExecutable}{wxfilenameisfileexecutable}\membersection{File name components}\label{filenamecomponents}These functions allow to examine and modify the individual directories of thepath:\helpref{AppendDir}{wxfilenameappenddir}\\\helpref{InsertDir}{wxfilenameinsertdir}\\\helpref{GetDirCount}{wxfilenamegetdircount}\helpref{PrependDir}{wxfilenameprependdir}\\\helpref{RemoveDir}{wxfilenameremovedir}\\\helpref{RemoveLastDir}{wxfilenameremovelastdir}To change the components of the file name individually you can use thefollowing functions:\helpref{GetExt}{wxfilenamegetext}\\\helpref{GetName}{wxfilenamegetname}\\\helpref{GetVolume}{wxfilenamegetvolume}\\\helpref{HasExt}{wxfilenamehasext}\\\helpref{HasName}{wxfilenamehasname}\\\helpref{HasVolume}{wxfilenamehasvolume}\\\helpref{SetExt}{wxfilenamesetext}\\\helpref{ClearExt}{wxfilenameclearext}\\\helpref{SetEmptyExt}{wxfilenamesetemptyext}\\\helpref{SetName}{wxfilenamesetname}\\\helpref{SetVolume}{wxfilenamesetvolume}\\\membersection{Operations}\label{filenameoperations}These methods allow to work with the file creation, access and modificationtimes. Note that not all filesystems under all platforms implement these timesin the same way. For example, the access time under Windows has a resolution ofone day (so it is really the access date and not time). The access time may beupdated when the file is executed or not depending on the platform.\helpref{GetModificationTime}{wxfilenamegetmodificationtime}\\\helpref{GetTimes}{wxfilenamegettimes}\\\helpref{SetTimes}{wxfilenamesettimes}\\\helpref{Touch}{wxfilenametouch}Other file system operations functions are:\helpref{Mkdir}{wxfilenamemkdir}\\\helpref{Rmdir}{wxfilenamermdir}\latexignore{\rtfignore{\wxheading{Members}}}\membersection{wxFileName::wxFileName}\label{wxfilenamewxfilename}\func{}{wxFileName}{\void}Default constructor.\func{}{wxFileName}{\param{const wxFileName\& }{filename}}Copy constructor.\func{}{wxFileName}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Constructor taking a full filename. If it terminates with a '/', a directory pathis constructed (the name will be empty), otherwise a file name andextension are extracted from it.\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Constructor from a directory name and a file name.\func{}{wxFileName}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Constructor from a directory name, base file name and extension.\func{}{wxFileName}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Constructor from a volume name, a directory name, base file name and extension.\membersection{wxFileName::AppendDir}\label{wxfilenameappenddir}\func{void}{AppendDir}{\param{const wxString\& }{dir}}Appends a directory component to the path. This component should contain asingle directory name level, i.e. not contain any path or volume separators norshould it be empty, otherwise the function does nothing (and generates anassert failure in debug build).\membersection{wxFileName::Assign}\label{wxfilenameassign}\func{void}{Assign}{\param{const wxFileName\& }{filepath}}\func{void}{Assign}{\param{const wxString\& }{fullpath}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}\func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{bool }{hasExt}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}\func{void}{Assign}{\param{const wxString\& }{volume}, \param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}\func{void}{Assign}{\param{const wxString\& }{path}, \param{const wxString\& }{name}, \param{const wxString\& }{ext}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Creates the file name from various combinations of data.\membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd}\func{static void}{AssignCwd}{\param{const wxString\& }{volume = wxEmptyString}}Makes this object refer to the current working directory on the specifiedvolume (or current volume if {\it volume} is empty).\wxheading{See also}\helpref{GetCwd}{wxfilenamegetcwd}\membersection{wxFileName::AssignDir}\label{wxfilenameassigndir}\func{void}{AssignDir}{\param{const wxString\& }{dir}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}Sets this file name object to the given directory name. The name and extensionwill be empty.\membersection{wxFileName::AssignHomeDir}\label{wxfilenameassignhomedir}\func{void}{AssignHomeDir}{\void}Sets this file name object to the home directory.\membersection{wxFileName::AssignTempFileName}\label{wxfilenameassigntempfilename}\func{void}{AssignTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}}The function calls \helpref{CreateTempFileName}{wxfilenamecreatetempfilename} tocreate a temporary file and sets this object to the name of the file. If atemporary file couldn't be created, the object is put into the\rtfsp\helpref{invalid}{wxfilenameisok} state.\membersection{wxFileName::Clear}\label{wxfilenameclear}\func{void}{Clear}{\void}Reset all components to default, uninitialized state.\membersection{wxFileName::ClearExt}\label{wxfilenameclearext}\func{void}{SetClearExt}{\void}Removes the extension from the file name resulting in a file name with no trailing dot.\wxheading{See also}\helpref{SetExt}{wxfilenamesetext}\helpref{SetEmptyExt}{wxfilenamesetemptyext}\membersection{wxFileName::CreateTempFileName}\label{wxfilenamecreatetempfilename}\func{static wxString}{CreateTempFileName}{\param{const wxString\& }{prefix}, \param{wxFile *}{fileTemp = {\tt NULL}}}Returns a temporary file name starting with the given {\it prefix}. Ifthe {\it prefix} is an absolute path, the temporary file is created in thisdirectory, otherwise it is created in the default system directory for thetemporary files or in the current directory.If the function succeeds, the temporary file is actually created. If\rtfsp{\it fileTemp} is not {\tt NULL}, this file will be opened using the name ofthe temporary file. When possible, this is done in an atomic way ensuring thatno race condition occurs between the temporary file name generation and openingit which could often lead to security compromise on the multiuser systems.If {\it fileTemp} is {\tt NULL}, the file is only created, but not opened.Under Unix, the temporary file will have read and write permissions for theowner only to minimize the security problems.\wxheading{Parameters}\docparam{prefix}{Prefix to use for the temporary file name construction}\docparam{fileTemp}{The file to open or {\tt NULL} to just get the name}\wxheading{Return value}The full temporary file name or an empty string on error.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -