wxString and wxChar* access for file functions. Source cleaning.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31105 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -748,7 +748,7 @@ int LoadIndex(wxChar *file_name)
|
|||||||
|
|
||||||
wxSprintf(buf, _T("%s.idx"), file_name);
|
wxSprintf(buf, _T("%s.idx"), file_name);
|
||||||
|
|
||||||
index_file = wxFopen(buf, _T("r"));
|
index_file = wxFopen(wxFNCONV(buf), _T("r"));
|
||||||
if (index_file == NULL)
|
if (index_file == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -823,7 +823,7 @@ bool LoadPoem(wxChar *file_name, long position)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wxSprintf(buf, _T("%s.dat"), file_name);
|
wxSprintf(buf, _T("%s.dat"), file_name);
|
||||||
data_file = wxFopen(buf, _T("r"));
|
data_file = wxFopen(wxFNCONV(buf), _T("r"));
|
||||||
|
|
||||||
if (data_file == NULL)
|
if (data_file == NULL)
|
||||||
{
|
{
|
||||||
@@ -897,7 +897,7 @@ long MainWindow::DoSearch(void)
|
|||||||
if (data_filename)
|
if (data_filename)
|
||||||
wxSprintf(buf, _T("%s.dat"), data_filename);
|
wxSprintf(buf, _T("%s.dat"), data_filename);
|
||||||
|
|
||||||
file = wxFopen(buf, _T("r"));
|
file = wxFopen(wxFNCONV(buf), _T("r"));
|
||||||
if (! (data_filename && file))
|
if (! (data_filename && file))
|
||||||
{
|
{
|
||||||
wxSprintf(error_buf, _T("Poetry data file %s not found\n"), buf);
|
wxSprintf(error_buf, _T("Poetry data file %s not found\n"), buf);
|
||||||
@@ -979,7 +979,7 @@ bool Compile(void)
|
|||||||
if (data_filename)
|
if (data_filename)
|
||||||
wxSprintf(buf, _T("%s.dat"), data_filename);
|
wxSprintf(buf, _T("%s.dat"), data_filename);
|
||||||
|
|
||||||
file = wxFopen(buf, _T("r"));
|
file = wxFopen(wxFNCONV(buf), _T("r"));
|
||||||
if (! (data_filename && file))
|
if (! (data_filename && file))
|
||||||
{
|
{
|
||||||
wxSprintf(error_buf, _T("Poetry data file %s not found\n"), buf);
|
wxSprintf(error_buf, _T("Poetry data file %s not found\n"), buf);
|
||||||
@@ -1011,7 +1011,7 @@ bool Compile(void)
|
|||||||
if (index_filename)
|
if (index_filename)
|
||||||
wxSprintf(buf, _T("%s.idx"), index_filename);
|
wxSprintf(buf, _T("%s.idx"), index_filename);
|
||||||
|
|
||||||
file = wxFopen(buf, _T("w"));
|
file = wxFopen(wxFNCONV(buf), _T("w"));
|
||||||
if (! (data_filename && file))
|
if (! (data_filename && file))
|
||||||
{
|
{
|
||||||
wxSprintf(error_buf, _T("Poetry index file %s cannot be created\n"), buf);
|
wxSprintf(error_buf, _T("Poetry index file %s cannot be created\n"), buf);
|
||||||
|
@@ -2163,7 +2163,7 @@ bool wxDb::ExecSql(const wxString &pSqlStmt)
|
|||||||
} // wxDb::ExecSql()
|
} // wxDb::ExecSql()
|
||||||
|
|
||||||
|
|
||||||
/********** wxDb::ExecSql() with column info **********/
|
/********** wxDb::ExecSql() with column info **********/
|
||||||
bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcols)
|
bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcols)
|
||||||
{
|
{
|
||||||
//execute the statement first
|
//execute the statement first
|
||||||
@@ -2176,21 +2176,21 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
DispAllErrors(henv, hdbc, hstmt);
|
DispAllErrors(henv, hdbc, hstmt);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (noCols == 0)
|
if (noCols == 0)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
numcols = noCols;
|
numcols = noCols;
|
||||||
|
|
||||||
// Get column information
|
// Get column information
|
||||||
short colNum;
|
short colNum;
|
||||||
wxChar name[DB_MAX_COLUMN_NAME_LEN+1];
|
wxChar name[DB_MAX_COLUMN_NAME_LEN+1];
|
||||||
SWORD Sword;
|
SWORD Sword;
|
||||||
SDWORD Sdword;
|
SDWORD Sdword;
|
||||||
wxDbColInf* pColInf = new wxDbColInf[noCols];
|
wxDbColInf* pColInf = new wxDbColInf[noCols];
|
||||||
|
|
||||||
//fill in column information (name, datatype)
|
//fill in column information (name, datatype)
|
||||||
for (colNum = 0; colNum < noCols; colNum++)
|
for (colNum = 0; colNum < noCols; colNum++)
|
||||||
{
|
{
|
||||||
if (SQLColAttributes(hstmt, (UWORD)(colNum+1), SQL_COLUMN_NAME,
|
if (SQLColAttributes(hstmt, (UWORD)(colNum+1), SQL_COLUMN_NAME,
|
||||||
name, sizeof(name),
|
name, sizeof(name),
|
||||||
@@ -2200,9 +2200,9 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
delete[] pColInf;
|
delete[] pColInf;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxStrncpy(pColInf[colNum].colName, name, DB_MAX_COLUMN_NAME_LEN);
|
wxStrncpy(pColInf[colNum].colName, name, DB_MAX_COLUMN_NAME_LEN);
|
||||||
|
|
||||||
if (SQLColAttributes(hstmt, (UWORD)(colNum+1), SQL_COLUMN_TYPE,
|
if (SQLColAttributes(hstmt, (UWORD)(colNum+1), SQL_COLUMN_TYPE,
|
||||||
NULL, 0, &Sword, &Sdword) != SQL_SUCCESS)
|
NULL, 0, &Sword, &Sdword) != SQL_SUCCESS)
|
||||||
{
|
{
|
||||||
@@ -2210,7 +2210,7 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
delete[] pColInf;
|
delete[] pColInf;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (Sdword)
|
switch (Sdword)
|
||||||
{
|
{
|
||||||
case SQL_VARCHAR:
|
case SQL_VARCHAR:
|
||||||
@@ -2245,7 +2245,7 @@ bool wxDb::ExecSql(const wxString &pSqlStmt, wxDbColInf** columns, short& numcol
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*columns = pColInf;
|
*columns = pColInf;
|
||||||
return true;
|
return true;
|
||||||
} // wxDb::ExecSql()
|
} // wxDb::ExecSql()
|
||||||
@@ -3338,7 +3338,7 @@ bool wxDb::Catalog(const wxChar *userID, const wxString &fileName)
|
|||||||
wxChar typeName[30+1];
|
wxChar typeName[30+1];
|
||||||
SDWORD precision, length;
|
SDWORD precision, length;
|
||||||
|
|
||||||
FILE *fp = wxFopen(fileName.c_str(),wxT("wt"));
|
FILE *fp = wxFopen(fileName.fn_str(),wxT("wt"));
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -3675,7 +3675,7 @@ bool wxDb::SetSqlLogging(wxDbSqlLogState state, const wxString &filename, bool a
|
|||||||
{
|
{
|
||||||
if (fpSqlLog == 0)
|
if (fpSqlLog == 0)
|
||||||
{
|
{
|
||||||
fpSqlLog = wxFopen(filename, (append ? wxT("at") : wxT("wt")));
|
fpSqlLog = wxFopen(filename.fn_str(), (append ? wxT("at") : wxT("wt")));
|
||||||
if (fpSqlLog == NULL)
|
if (fpSqlLog == NULL)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -213,7 +213,7 @@ void wxPathList::AddEnvList (const wxString& envVariable)
|
|||||||
void wxPathList::EnsureFileAccessible (const wxString& path)
|
void wxPathList::EnsureFileAccessible (const wxString& path)
|
||||||
{
|
{
|
||||||
wxString path_only(wxPathOnly(path));
|
wxString path_only(wxPathOnly(path));
|
||||||
if ( !path_only.IsEmpty() )
|
if ( !path_only.empty() )
|
||||||
{
|
{
|
||||||
if ( !Member(path_only) )
|
if ( !Member(path_only) )
|
||||||
Add(path_only);
|
Add(path_only);
|
||||||
@@ -361,7 +361,7 @@ void wxStripExtension(wxChar *buffer)
|
|||||||
|
|
||||||
void wxStripExtension(wxString& buffer)
|
void wxStripExtension(wxString& buffer)
|
||||||
{
|
{
|
||||||
//RN: Be careful about the handling the case where
|
//RN: Be careful about the handling the case where
|
||||||
//buffer.Length() == 0
|
//buffer.Length() == 0
|
||||||
for(size_t i = buffer.Length() - 1; i != wxString::npos; --i)
|
for(size_t i = buffer.Length() - 1; i != wxString::npos; --i)
|
||||||
{
|
{
|
||||||
@@ -951,9 +951,9 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil
|
|||||||
FILE *fp2 = NULL;
|
FILE *fp2 = NULL;
|
||||||
FILE *fp3 = NULL;
|
FILE *fp3 = NULL;
|
||||||
// Open the inputs and outputs
|
// Open the inputs and outputs
|
||||||
if ((fp1 = wxFopen ( file1, wxT("rb"))) == NULL ||
|
if ((fp1 = wxFopen ( file1.fn_str(), wxT("rb"))) == NULL ||
|
||||||
(fp2 = wxFopen ( file2, wxT("rb"))) == NULL ||
|
(fp2 = wxFopen ( file2.fn_str(), wxT("rb"))) == NULL ||
|
||||||
(fp3 = wxFopen ( outfile, wxT("wb"))) == NULL)
|
(fp3 = wxFopen ( outfile.fn_str(), wxT("wb"))) == NULL)
|
||||||
{
|
{
|
||||||
if (fp1)
|
if (fp1)
|
||||||
fclose (fp1);
|
fclose (fp1);
|
||||||
@@ -1137,11 +1137,11 @@ bool wxMkdir(const wxString& dir, int perm)
|
|||||||
#error "Unsupported DOS compiler!"
|
#error "Unsupported DOS compiler!"
|
||||||
#endif
|
#endif
|
||||||
#else // !MSW, !DOS and !OS/2 VAC++
|
#else // !MSW, !DOS and !OS/2 VAC++
|
||||||
(void)perm;
|
wxUnusedVar(perm);
|
||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
if ( !CreateDirectory(dirname, NULL) )
|
if ( !CreateDirectory(dirname, NULL) )
|
||||||
#else
|
#else
|
||||||
if ( wxMkDir(wxFNSTRINGCAST wxFNCONV(dirname)) != 0 )
|
if ( wxMkDir(dir.fn_str()) != 0 )
|
||||||
#endif
|
#endif
|
||||||
#endif // !MSW/MSW
|
#endif // !MSW/MSW
|
||||||
{
|
{
|
||||||
@@ -1244,7 +1244,7 @@ static wxString gs_dirPath;
|
|||||||
wxString wxFindFirstFile(const wxChar *spec, int flags)
|
wxString wxFindFirstFile(const wxChar *spec, int flags)
|
||||||
{
|
{
|
||||||
wxSplitPath(spec, &gs_dirPath, NULL, NULL);
|
wxSplitPath(spec, &gs_dirPath, NULL, NULL);
|
||||||
if ( gs_dirPath.IsEmpty() )
|
if ( gs_dirPath.empty() )
|
||||||
gs_dirPath = wxT(".");
|
gs_dirPath = wxT(".");
|
||||||
if ( !wxEndsWithPathSeparator(gs_dirPath ) )
|
if ( !wxEndsWithPathSeparator(gs_dirPath ) )
|
||||||
gs_dirPath << wxFILE_SEP_PATH;
|
gs_dirPath << wxFILE_SEP_PATH;
|
||||||
@@ -1269,7 +1269,7 @@ wxString wxFindFirstFile(const wxChar *spec, int flags)
|
|||||||
|
|
||||||
wxString result;
|
wxString result;
|
||||||
gs_dir->GetFirst(&result, wxFileNameFromPath(wxString(spec)), dirFlags);
|
gs_dir->GetFirst(&result, wxFileNameFromPath(wxString(spec)), dirFlags);
|
||||||
if ( result.IsEmpty() )
|
if ( result.empty() )
|
||||||
{
|
{
|
||||||
wxDELETE(gs_dir);
|
wxDELETE(gs_dir);
|
||||||
return result;
|
return result;
|
||||||
@@ -1285,7 +1285,7 @@ wxString wxFindNextFile()
|
|||||||
wxString result;
|
wxString result;
|
||||||
gs_dir->GetNext(&result);
|
gs_dir->GetNext(&result);
|
||||||
|
|
||||||
if ( result.IsEmpty() )
|
if ( result.empty() )
|
||||||
{
|
{
|
||||||
wxDELETE(gs_dir);
|
wxDELETE(gs_dir);
|
||||||
return result;
|
return result;
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
wxFileInputStream::wxFileInputStream(const wxString& fileName)
|
wxFileInputStream::wxFileInputStream(const wxString& fileName)
|
||||||
: wxInputStream()
|
: wxInputStream()
|
||||||
{
|
{
|
||||||
m_file = new wxFile(fileName, wxFile::read);
|
m_file = new wxFile(fileName.fn_str(), wxFile::read);
|
||||||
m_file_destroy = true;
|
m_file_destroy = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ wxFileOffset wxFileInputStream::OnSysTell() const
|
|||||||
|
|
||||||
wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
|
wxFileOutputStream::wxFileOutputStream(const wxString& fileName)
|
||||||
{
|
{
|
||||||
m_file = new wxFile(fileName, wxFile::write);
|
m_file = new wxFile(fileName.fn_str(), wxFile::write);
|
||||||
m_file_destroy = true;
|
m_file_destroy = true;
|
||||||
|
|
||||||
if (!m_file->IsOpened())
|
if (!m_file->IsOpened())
|
||||||
|
Reference in New Issue
Block a user