filename.tex
来自「Wxpython Implemented on Windows CE, Sou」· TEX 代码 · 共 917 行 · 第 1/3 页
TEX
917 行
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Name: filename.tex
%% Purpose: wxFileName documentation
%% Author: Vadim Zeitlin
%% Modified by:
%% Created: 30.11.01
%% RCS-ID: $Id: filename.tex,v 1.43 2006/05/03 13:12:41 VZ 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, it
provides the functions to split the file names into components and to recombine
these components in the full file name which can then be passed to the OS file
functions (and \helpref{wxWidgets functions}{filefunctions} wrapping them).
Second, it includes the functions for working with the files itself. Note that
to change the file data you should use \helpref{wxFile}{wxfile} class instead.
wxFileName provides functions for working with the file attributes.
\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 the
current 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 also
affects 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 OS
and VMS formats. Although these formats are quite different, wxFileName tries
to treat them all in the same generic way. It supposes that all file names
consist of the following parts: the volume (also known as drive under Windows
or device under VMS), the path which is a sequence of directory names separated
by the \helpref{path separators}{wxfilenamegetpathseparators} and the full
filename itself which, in turn, is composed from the base file name and the
extension. 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 all
empty simultaneously, the filename object is considered to be in an invalid
state 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 also
depend on the file name format and the only portable way to answer this
question 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 wxFileName
instance 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 inverse
function \helpref{MakeRelativeTo}{wxfilenamemakerelativeto} which undoes
what \helpref{Normalize(wxPATH\_NORM\_DOTS)}{wxfilenamenormalize} does.
Other functions returning information about the file format provided by this
class are \helpref{GetVolumeSeparator}{wxfilenamegetvolumeseparator},\rtfsp
\helpref{IsPathSeparator}{wxfilenameispathseparator}.
\membersection{File name construction}\label{filenameconstruction}
TODO.
\membersection{File tests}\label{filetests}
Before doing other tests, you should use \helpref{IsOk}{wxfilenameisok} to
verify that the filename is well defined. If it is,\rtfsp
\helpref{FileExists}{wxfilenamefileexists} can be used to test whether a file
with such name exists and \helpref{DirExists}{wxfilenamedirexists} can be used
to test for directory existence.
File names should be compared using \helpref{SameAs}{wxfilenamesameas} method
or \helpref{$==$}{wxfilenameoperatorequal}.
\membersection{File name components}\label{filenamecomponents}
These functions allow to examine and modify the individual directories of the
path:
\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 the
following 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 modification
times. Note that not all filesystems under all platforms implement these times
in the same way. For example, the access time under Windows has a resolution of
one day (so it is really the access date and not time). The access time may be
updated 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 path
is constructed (the name will be empty), otherwise a file name and
extension 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 a
single directory name level, i.e. not contain any path or volume separators nor
should it be empty, otherwise the function does nothing (and generates an
assert 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 specified
volume (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 extension
will 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} to
create a temporary file and sets this object to the name of the file. If a
temporary 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}. If
the {\it prefix} is an absolute path, the temporary file is created in this
directory, otherwise it is created in the default system directory for the
temporary 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 of
the temporary file. When possible, this is done in an atomic way ensuring that
no race condition occurs between the temporary file name generation and opening
it 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 the
owner 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.
\membersection{wxFileName::DirExists}\label{wxfilenamedirexists}
\constfunc{bool}{DirExists}{\void}
\func{static bool}{DirExists}{\param{const wxString\& }{dir}}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?