use wxString instead of const wxChar* in wxFile's public API

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45807 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-04 19:04:19 +00:00
parent 62602fbd53
commit fcea31d51b
3 changed files with 20 additions and 20 deletions

View File

@@ -93,7 +93,7 @@ mode constants used with \helpref{Seek()}{wxfileseek}:
Default constructor.
\func{}{wxFile}{\param{const char*}{ filename}, \param{wxFile::OpenMode}{ mode = wxFile::read}}
\func{}{wxFile}{\param{const wxString\&}{ filename}, \param{wxFile::OpenMode}{ mode = wxFile::read}}
Opens a file with the given mode. As there is no way to return whether the
operation was successful or not from the constructor you should test the
@@ -124,7 +124,7 @@ Destructor will close the file.
\membersection{wxFile::Access}\label{wxfileaccess}
\func{static bool}{Access}{\param{const char *}{ name}, \param{OpenMode}{ mode}}
\func{static bool}{Access}{\param{const wxString\&}{ name}, \param{OpenMode}{ mode}}
This function verifies if we may access the given file in specified mode. Only
values of wxFile::read or wxFile::write really make sense here.
@@ -151,7 +151,7 @@ Closes the file.
\membersection{wxFile::Create}\label{wxfilecreate}
\func{bool}{Create}{\param{const char*}{ filename}, \param{bool}{ overwrite = false}, \param{int }{access = wxS\_DEFAULT}}
\func{bool}{Create}{\param{const wxString\&}{ filename}, \param{bool}{ overwrite = false}, \param{int }{access = wxS\_DEFAULT}}
Creates a file for writing. If the file already exists, setting {\bf overwrite} to true
will ensure it is overwritten.
@@ -195,7 +195,7 @@ of using Eof() as this will not work for special files under Unix.
\membersection{wxFile::Exists}\label{wxfileexists}
\func{static bool}{Exists}{\param{const char*}{ filename}}
\func{static bool}{Exists}{\param{const wxString\&}{ filename}}
Returns true if the given name specifies an existing regular file (not a
directory or a link)
@@ -246,7 +246,7 @@ Returns the length of the file.
\membersection{wxFile::Open}\label{wxfileopen}
\func{bool}{Open}{\param{const char*}{ filename}, \param{wxFile::OpenMode}{ mode = wxFile::read}}
\func{bool}{Open}{\param{const wxString\&}{ filename}, \param{wxFile::OpenMode}{ mode = wxFile::read}}
Opens the file, returning true if successful.

View File

@@ -63,10 +63,10 @@ public:
// static functions
// ----------------
// check whether a regular file by this name exists
static bool Exists(const wxChar *name);
static bool Exists(const wxString& name);
// check whether we can access the given file in given mode
// (only read and write make sense here)
static bool Access(const wxChar *name, OpenMode mode);
static bool Access(const wxString& name, OpenMode mode);
// ctors
// -----
@@ -80,9 +80,9 @@ public:
// open/close
// create a new file (with the default value of bOverwrite, it will fail if
// the file already exists, otherwise it will overwrite it and succeed)
bool Create(const wxChar *szFileName, bool bOverwrite = false,
bool Create(const wxString& fileName, bool bOverwrite = false,
int access = wxS_DEFAULT);
bool Open(const wxChar *szFileName, OpenMode mode = read,
bool Open(const wxString& fileName, OpenMode mode = read,
int access = wxS_DEFAULT);
bool Close(); // Close is a NOP if not opened

View File

@@ -148,12 +148,12 @@
// static functions
// ----------------------------------------------------------------------------
bool wxFile::Exists(const wxChar *name)
bool wxFile::Exists(const wxString& name)
{
return wxFileExists(name);
}
bool wxFile::Access(const wxChar *name, OpenMode mode)
bool wxFile::Access(const wxString& name, OpenMode mode)
{
int how;
@@ -193,23 +193,23 @@ wxFile::wxFile(const wxString& fileName, OpenMode mode)
}
// create the file, fail if it already exists and bOverwrite
bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
bool wxFile::Create(const wxString& fileName, bool bOverwrite, int accessMode)
{
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
#if defined(__WXMAC__) && !defined(__UNIX__) && !wxUSE_UNICODE
// Dominic Mazzoni [dmazzoni+@cs.cmu.edu] reports that open is still broken on the mac, so we replace
// int fd = open( szFileName , O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat( szFileName , accessMode);
// int fd = open( fileName , O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
int fd = creat( fileName , accessMode);
#else
int fd = wxOpen( szFileName,
int fd = wxOpen( fileName,
O_BINARY | O_WRONLY | O_CREAT |
(bOverwrite ? O_TRUNC : O_EXCL)
ACCESS(accessMode) );
#endif
if ( fd == -1 )
{
wxLogSysError(_("can't create file '%s'"), szFileName);
wxLogSysError(_("can't create file '%s'"), fileName);
return false;
}
@@ -218,7 +218,7 @@ bool wxFile::Create(const wxChar *szFileName, bool bOverwrite, int accessMode)
}
// open the file
bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
bool wxFile::Open(const wxString& fileName, OpenMode mode, int accessMode)
{
int flags = O_BINARY;
@@ -229,7 +229,7 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
break;
case write_append:
if ( wxFile::Exists(szFileName) )
if ( wxFile::Exists(fileName) )
{
flags |= O_WRONLY | O_APPEND;
break;
@@ -257,11 +257,11 @@ bool wxFile::Open(const wxChar *szFileName, OpenMode mode, int accessMode)
accessMode &= wxS_IRUSR | wxS_IWUSR;
#endif // __WINDOWS__
int fd = wxOpen( szFileName, flags ACCESS(accessMode));
int fd = wxOpen( fileName, flags ACCESS(accessMode));
if ( fd == -1 )
{
wxLogSysError(_("can't open file '%s'"), szFileName);
wxLogSysError(_("can't open file '%s'"), fileName);
return false;
}