Fixed strange situation when we had wxPathExists and wxDirExists with the same finctionality. Using wxPathExists instead wxFileExists (fixes bug #865628). Minor source cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-03-17 17:46:32 +00:00
parent fbb7dfffb0
commit 27b2dd53f6
16 changed files with 92 additions and 111 deletions

View File

@@ -40,7 +40,7 @@ void NodeInfo::Read(const wxString& filename, wxPathList& list)
NodeClass.Empty(); NodeClass.Empty();
wxString path = list.FindValidPath(filename); wxString path = list.FindValidPath(filename);
if (path.IsEmpty()) return; if (path.empty()) return;
wxTextFile tf; wxTextFile tf;
tf.Open(path); tf.Open(path);
@@ -98,9 +98,9 @@ void NodeInfo::Read(const wxString& filename, wxPathList& list)
} }
} }
if (!nd.IsEmpty()) NodeClass = nd; if (!nd.empty()) NodeClass = nd;
if (!cht.IsEmpty()) ChildType = cht; if (!cht.empty()) ChildType = cht;
if (!!tp) Type = tp; if (!tp.empty()) Type = tp;
if (icn != -1) Icon = icn; if (icn != -1) Icon = icn;
Abstract = ab; Abstract = ab;
} }
@@ -153,7 +153,7 @@ void NodesDb::Load()
void NodesDb::LoadDir(const wxString& path) void NodesDb::LoadDir(const wxString& path)
{ {
if (!wxDirExists(path)) return; if (!wxPathExists(path)) return;
wxDir dir(path); wxDir dir(path);
wxString filename; wxString filename;

View File

@@ -60,7 +60,6 @@ the corresponding topic.
\helpref{wxDDEInitialize}{wxddeinitialize}\\ \helpref{wxDDEInitialize}{wxddeinitialize}\\
\helpref{wxDROP\_ICON}{wxdropicon}\\ \helpref{wxDROP\_ICON}{wxdropicon}\\
\helpref{wxDebugMsg}{wxdebugmsg}\\ \helpref{wxDebugMsg}{wxdebugmsg}\\
\helpref{wxDirExists}{functionwxdirexists}\\
\helpref{wxDirSelector}{wxdirselector}\\ \helpref{wxDirSelector}{wxdirselector}\\
\helpref{wxDisplayDepth}{wxdisplaydepth}\\ \helpref{wxDisplayDepth}{wxdisplaydepth}\\
\helpref{wxDisplaySize}{wxdisplaysize}\\ \helpref{wxDisplaySize}{wxdisplaysize}\\
@@ -191,6 +190,7 @@ the corresponding topic.
\helpref{wxOnAssert}{wxonassert}\\ \helpref{wxOnAssert}{wxonassert}\\
\helpref{wxOpenClipboard}{wxopenclipboard}\\ \helpref{wxOpenClipboard}{wxopenclipboard}\\
\helpref{wxParseCommonDialogsFilter}{wxparsecommondialogsfilter}\\ \helpref{wxParseCommonDialogsFilter}{wxparsecommondialogsfilter}\\
\helpref{wxPathExists}{functionwxpathexists}\\
\helpref{wxPathOnly}{wxpathonly}\\ \helpref{wxPathOnly}{wxpathonly}\\
\helpref{wxPostDelete}{wxpostdelete}\\ \helpref{wxPostDelete}{wxpostdelete}\\
\helpref{wxPostEvent}{wxpostevent}\\ \helpref{wxPostEvent}{wxpostevent}\\
@@ -914,13 +914,6 @@ threads.
\helpref{wxFileName}{wxfilename} \helpref{wxFileName}{wxfilename}
\membersection{::wxDirExists}\label{functionwxdirexists}
\func{bool}{wxDirExists}{\param{const wxString\& }{dirname}}
Returns true if the directory exists.
\membersection{::wxDos2UnixFilename}\label{wxdos2unixfilename} \membersection{::wxDos2UnixFilename}\label{wxdos2unixfilename}
\func{void}{wxDos2UnixFilename}{\param{wxChar *}{s}} \func{void}{wxDos2UnixFilename}{\param{wxChar *}{s}}
@@ -1055,6 +1048,13 @@ Returns true if the argument is an absolute filename, i.e. with a slash
or drive name at the beginning. or drive name at the beginning.
\membersection{::wxPathExists}\label{functionwxpathexists}
\func{bool}{wxPathExists}{\param{const wxString\& }{dirname}}
Returns true if the path exists.
\membersection{::wxPathOnly}\label{wxpathonly} \membersection{::wxPathOnly}\label{wxpathonly}
\func{wxString}{wxPathOnly}{\param{const wxString\& }{path}} \func{wxString}{wxPathOnly}{\param{const wxString\& }{path}}

View File

@@ -150,7 +150,7 @@ enum wxFileKind
wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin); wxFileOffset wxSeek(int fd, wxFileOffset offset, int origin);
#define wxLSeek wxSeek #define wxLSeek wxSeek
wxFileOffset wxTell(int fd); wxFileOffset wxTell(int fd);
// always Unicode under WinCE // always Unicode under WinCE
#define wxMkDir _wmkdir #define wxMkDir _wmkdir
#define wxRmDir _wrmdir #define wxRmDir _wrmdir
@@ -462,7 +462,9 @@ WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(int fd);
WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp); WXDLLIMPEXP_BASE wxFileKind wxGetFileKind(FILE *fp);
// compatibility defines, don't use in new code // compatibility defines, don't use in new code
#define wxDirExists wxPathExists #if WXWIN_COMPATIBILITY_2_4
#define wxDirExists wxPathExists
#endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// separators in file names // separators in file names

View File

@@ -35,7 +35,6 @@
3. SameFileAs() function to compare inodes under Unix 3. SameFileAs() function to compare inodes under Unix
*/ */
// ridiculously enough, this will replace DirExists with wxDirExists etc
#include "wx/filefn.h" #include "wx/filefn.h"
#include "wx/datetime.h" #include "wx/datetime.h"
@@ -186,7 +185,7 @@ public:
bool IsOk() const bool IsOk() const
{ {
// we're fine if we have the path or the name or if we're a root dir // 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.IsEmpty() || !m_relative || return m_dirs.size() != 0 || !m_name.empty() || !m_relative ||
!m_ext.empty() || m_hasExt; !m_ext.empty() || m_hasExt;
} }

View File

@@ -1226,6 +1226,8 @@ bool wxPathExists(const wxChar *pszPathName)
DWORD ret = ::GetFileAttributes(strPath); DWORD ret = ::GetFileAttributes(strPath);
return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY); return (ret != (DWORD)-1) && (ret & FILE_ATTRIBUTE_DIRECTORY);
#elif defined(__OS2__)
return (::DosSetCurrentDir(WXSTRINGCAST strPath));
#else // !__WIN32__ #else // !__WIN32__
wxStructStat st; wxStructStat st;
@@ -1900,7 +1902,7 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special )
// This is important for the archive streams, which benefit greatly from // This is important for the archive streams, which benefit greatly from
// being able to seek on a stream, but which will produce corrupt archives // being able to seek on a stream, but which will produce corrupt archives
// if they unknowingly seek on a non-seekable stream. // if they unknowingly seek on a non-seekable stream.
// //
// wxFILE_KIND_DISK is a good catch all return value, since other values // wxFILE_KIND_DISK is a good catch all return value, since other values
// disable features of the archive streams. Some other value must be returned // disable features of the archive streams. Some other value must be returned
// for a file type that appears seekable but isn't. // for a file type that appears seekable but isn't.

View File

@@ -527,7 +527,7 @@ bool wxFileName::DirExists() const
bool wxFileName::DirExists( const wxString &dir ) bool wxFileName::DirExists( const wxString &dir )
{ {
return ::wxDirExists( dir ); return ::wxPathExists( dir );
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -318,7 +318,7 @@ void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) )
if (!wxEndsWithPathSeparator(path)) if (!wxEndsWithPathSeparator(path))
path += wxFILE_SEP_PATH; path += wxFILE_SEP_PATH;
path += new_name; path += new_name;
if (wxFileExists(path)) if (wxPathExists(path))
{ {
// try NewName0, NewName1 etc. // try NewName0, NewName1 etc.
int i = 0; int i = 0;
@@ -333,7 +333,7 @@ void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) )
path += wxFILE_SEP_PATH; path += wxFILE_SEP_PATH;
path += new_name; path += new_name;
i++; i++;
} while (wxFileExists(path)); } while (wxPathExists(path));
} }
wxLogNull log; wxLogNull log;

View File

@@ -695,7 +695,7 @@ void wxFileCtrl::GoToHomeDir()
void wxFileCtrl::GoToDir( const wxString &dir ) void wxFileCtrl::GoToDir( const wxString &dir )
{ {
if (!wxDirExists(dir)) return; if (!wxPathExists(dir)) return;
m_dirName = dir; m_dirName = dir;
UpdateFiles(); UpdateFiles();
@@ -1225,7 +1225,7 @@ void wxGenericFileDialog::OnSelected( wxListEvent &event )
if (!IsTopMostDir(dir)) if (!IsTopMostDir(dir))
dir += wxFILE_SEP_PATH; dir += wxFILE_SEP_PATH;
dir += filename; dir += filename;
if (wxDirExists(dir)) return; if (wxPathExists(dir)) return;
ignoreChanges = true; ignoreChanges = true;
m_text->SetValue( filename ); m_text->SetValue( filename );
@@ -1287,7 +1287,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn )
filename = dir; filename = dir;
} }
if (wxDirExists(filename)) if (wxPathExists(filename))
{ {
m_list->GoToDir( filename ); m_list->GoToDir( filename );
UpdateControls(); UpdateControls();

View File

@@ -259,7 +259,7 @@ bool wxExtHelpController::LoadFile(const wxString& ifile)
{ {
wxString newfile; wxString newfile;
newfile << WXEXTHELP_SEPARATOR << wxGetLocale()->GetName(); newfile << WXEXTHELP_SEPARATOR << wxGetLocale()->GetName();
if(wxDirExists(newfile)) if(wxPathExists(newfile))
file = newfile; file = newfile;
else else
{ {
@@ -267,13 +267,13 @@ bool wxExtHelpController::LoadFile(const wxString& ifile)
const wxChar *cptr = wxGetLocale()->GetName().c_str(); const wxChar *cptr = wxGetLocale()->GetName().c_str();
while(*cptr && *cptr != wxT('_')) while(*cptr && *cptr != wxT('_'))
newfile << *(cptr++); newfile << *(cptr++);
if(wxDirExists(newfile)) if(wxPathExists(newfile))
file = newfile; file = newfile;
} }
} }
#endif #endif
if(! wxDirExists(file)) if(! wxPathExists(file))
return false; return false;
mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE; mapFile << file << WXEXTHELP_SEPARATOR << WXEXTHELP_MAPFILE;

View File

@@ -86,7 +86,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
dialog->SetPath(filename); dialog->SetPath(filename);
dialog->UpdateFromDialog(); dialog->UpdateFromDialog();
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
event.SetEventObject(dialog); event.SetEventObject(dialog);
dialog->GetEventHandler()->ProcessEvent(event); dialog->GetEventHandler()->ProcessEvent(event);
@@ -109,7 +109,7 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
wxFileDialog *dialog) wxFileDialog *dialog)
{ {
wxapp_install_idle_handler(); wxapp_install_idle_handler();
if (response == GTK_RESPONSE_ACCEPT) if (response == GTK_RESPONSE_ACCEPT)
gtk_filedialog_ok_callback(w, dialog); gtk_filedialog_ok_callback(w, dialog);
else if (response == GTK_RESPONSE_CANCEL) else if (response == GTK_RESPONSE_CANCEL)
@@ -117,7 +117,7 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
else // "delete" else // "delete"
{ {
gtk_filedialog_cancel_callback(w, dialog); gtk_filedialog_cancel_callback(w, dialog);
dialog->m_destroyed_by_delete = TRUE; dialog->m_destroyed_by_delete = true;
} }
} }
#endif #endif
@@ -143,8 +143,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
m_needParent = FALSE; m_needParent = false;
m_destroyed_by_delete = FALSE; m_destroyed_by_delete = false;
if (!PreCreation(parent, pos, wxDefaultSize) || if (!PreCreation(parent, pos, wxDefaultSize) ||
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
@@ -159,7 +159,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
GtkWindow* gtk_parent = NULL; GtkWindow* gtk_parent = NULL;
if (parent) if (parent)
gtk_parent = GTK_WINDOW(parent->m_widget); gtk_parent = GTK_WINDOW(parent->m_widget);
gchar* ok_btn_stock; gchar* ok_btn_stock;
if ((style & wxSAVE) == wxSAVE) if ((style & wxSAVE) == wxSAVE)
{ {
@@ -180,18 +180,18 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
NULL); NULL);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple);
gtk_signal_connect(GTK_OBJECT(m_widget), gtk_signal_connect(GTK_OBJECT(m_widget),
"response", "response",
GTK_SIGNAL_FUNC(gtk_filedialog_response_callback), GTK_SIGNAL_FUNC(gtk_filedialog_response_callback),
(gpointer*)this); (gpointer*)this);
m_path = m_dir; m_path = m_dir;
if (!m_path.empty() && m_path.Last() != wxT('/')) if (!m_path.empty() && m_path.Last() != wxT('/'))
m_path += wxT('/'); m_path += wxT('/');
m_path += m_fileName; m_path += m_fileName;
SetPath(m_path); SetPath(m_path);
SetWildcard(wildCard); SetWildcard(wildCard);
SetFilterIndex(0); SetFilterIndex(0);
} }
@@ -241,7 +241,7 @@ bool wxFileDialog::Show( bool show )
return wxGenericFileDialog::Show( show ); return wxGenericFileDialog::Show( show );
} }
void wxFileDialog::GetFilenames(wxArrayString& files) const void wxFileDialog::GetFilenames(wxArrayString& files) const
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -251,7 +251,7 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
{ {
wxString name,ext; wxString name,ext;
wxSplitPath(files[n], NULL, &name, &ext); wxSplitPath(files[n], NULL, &name, &ext);
if (!ext.IsEmpty()) if (!ext.empty())
{ {
name += wxT("."); name += wxT(".");
name += ext; name += ext;
@@ -264,15 +264,15 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
wxGenericFileDialog::GetFilenames( files ); wxGenericFileDialog::GetFilenames( files );
} }
void wxFileDialog::GetPaths(wxArrayString& paths) const void wxFileDialog::GetPaths(wxArrayString& paths) const
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
paths.Empty(); paths.Empty();
if (GetWindowStyle() & wxMULTIPLE) if (GetWindowStyle() & wxMULTIPLE)
{ {
GSList *gpathsi = GSList *gpathsi =
gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget)); gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget));
GSList *gpaths = gpathsi; GSList *gpaths = gpathsi;
while (gpathsi) while (gpathsi)
@@ -282,7 +282,7 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
g_free(gpathsi->data); g_free(gpathsi->data);
gpathsi = gpathsi->next; gpathsi = gpathsi->next;
} }
if (gpaths) if (gpaths)
g_slist_free(gpaths); g_slist_free(gpaths);
} }
else else
@@ -304,7 +304,7 @@ void wxFileDialog::SetMessage(const wxString& message)
SetTitle(message); SetTitle(message);
} }
else else
#endif #endif
wxGenericFileDialog::SetMessage( message ); wxGenericFileDialog::SetMessage( message );
} }
@@ -322,7 +322,7 @@ void wxFileDialog::SetPath(const wxString& path)
UpdateDialog(); UpdateDialog();
} }
else else
#endif #endif
wxGenericFileDialog::SetPath( path ); wxGenericFileDialog::SetPath( path );
} }
@@ -331,7 +331,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
if (wxDirExists(dir)) if (wxPathExists(dir))
{ {
m_dir = dir; m_dir = dir;
m_path = wxFileName(m_dir, m_fileName).GetFullPath(); m_path = wxFileName(m_dir, m_fileName).GetFullPath();
@@ -339,7 +339,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
} }
} }
else else
#endif #endif
wxGenericFileDialog::SetDirectory( dir ); wxGenericFileDialog::SetDirectory( dir );
} }
@@ -364,7 +364,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
{ {
m_wildCard = wildCard; m_wildCard = wildCard;
GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget); GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
// empty current filter list: // empty current filter list:
GSList* ifilters = gtk_file_chooser_list_filters(chooser); GSList* ifilters = gtk_file_chooser_list_filters(chooser);
GSList* filters = ifilters; GSList* filters = ifilters;
@@ -374,7 +374,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
ifilters = ifilters->next; ifilters = ifilters->next;
} }
g_slist_free(filters); g_slist_free(filters);
// parse filters // parse filters
wxArrayString wildDescriptions, wildFilters; wxArrayString wildDescriptions, wildFilters;
if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters)) if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters))
@@ -398,7 +398,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
after = after.AfterLast(wxT(';')); after = after.AfterLast(wxT(';'));
} }
while (!after.empty()); while (!after.empty());
gtk_file_chooser_add_filter(chooser, filter); gtk_file_chooser_add_filter(chooser, filter);
} }
} }
@@ -441,7 +441,7 @@ void wxFileDialog::UpdateDialog()
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
// set currently selected directory to match the path: // set currently selected directory to match the path:
if (!m_dir.empty() && wxDirExists(m_dir)) if (!m_dir.empty() && wxPathExists(m_dir))
{ {
// NB: This is important -- if we set directory only and not the path, // NB: This is important -- if we set directory only and not the path,
// then dialog will still remember old path set using previous // then dialog will still remember old path set using previous
@@ -456,18 +456,18 @@ void wxFileDialog::UpdateDialog()
if (m_fileName.empty()) if (m_fileName.empty())
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_dir)); wxGTK_CONV(m_dir));
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_dir)); wxGTK_CONV(m_dir));
} }
// if the user set only the directory (e.g. by calling SetDirectory) // if the user set only the directory (e.g. by calling SetDirectory)
// and not the default filename, then we don't want to set the filename: // and not the default filename, then we don't want to set the filename:
if (!m_fileName.empty()) if (!m_fileName.empty())
{ {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_path)); wxGTK_CONV(m_path));
// pre-fill the filename when saving, too (there's no text entry // pre-fill the filename when saving, too (there's no text entry
// control when opening a file, so it doesn't make sense to // control when opening a file, so it doesn't make sense to
// do this when opening files): // do this when opening files):
@@ -488,7 +488,7 @@ void wxFileDialog::UpdateFromDialog()
GSList *filters = fnode; GSList *filters = fnode;
GtkFileFilter *current = GtkFileFilter *current =
gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget)); gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget));
int i = 0; int i = 0;
m_filterIndex = 0; m_filterIndex = 0;
while (fnode) while (fnode)

View File

@@ -86,7 +86,7 @@ static void gtk_filedialog_ok_callback(GtkWidget *widget, wxFileDialog *dialog)
dialog->SetPath(filename); dialog->SetPath(filename);
dialog->UpdateFromDialog(); dialog->UpdateFromDialog();
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
event.SetEventObject(dialog); event.SetEventObject(dialog);
dialog->GetEventHandler()->ProcessEvent(event); dialog->GetEventHandler()->ProcessEvent(event);
@@ -109,7 +109,7 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
wxFileDialog *dialog) wxFileDialog *dialog)
{ {
wxapp_install_idle_handler(); wxapp_install_idle_handler();
if (response == GTK_RESPONSE_ACCEPT) if (response == GTK_RESPONSE_ACCEPT)
gtk_filedialog_ok_callback(w, dialog); gtk_filedialog_ok_callback(w, dialog);
else if (response == GTK_RESPONSE_CANCEL) else if (response == GTK_RESPONSE_CANCEL)
@@ -117,7 +117,7 @@ static void gtk_filedialog_response_callback(GtkWidget *w,
else // "delete" else // "delete"
{ {
gtk_filedialog_cancel_callback(w, dialog); gtk_filedialog_cancel_callback(w, dialog);
dialog->m_destroyed_by_delete = TRUE; dialog->m_destroyed_by_delete = true;
} }
} }
#endif #endif
@@ -143,8 +143,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
m_needParent = FALSE; m_needParent = false;
m_destroyed_by_delete = FALSE; m_destroyed_by_delete = false;
if (!PreCreation(parent, pos, wxDefaultSize) || if (!PreCreation(parent, pos, wxDefaultSize) ||
!CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style, !CreateBase(parent, wxID_ANY, pos, wxDefaultSize, style,
@@ -159,7 +159,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
GtkWindow* gtk_parent = NULL; GtkWindow* gtk_parent = NULL;
if (parent) if (parent)
gtk_parent = GTK_WINDOW(parent->m_widget); gtk_parent = GTK_WINDOW(parent->m_widget);
gchar* ok_btn_stock; gchar* ok_btn_stock;
if ((style & wxSAVE) == wxSAVE) if ((style & wxSAVE) == wxSAVE)
{ {
@@ -180,18 +180,18 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
NULL); NULL);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(m_widget), multiple);
gtk_signal_connect(GTK_OBJECT(m_widget), gtk_signal_connect(GTK_OBJECT(m_widget),
"response", "response",
GTK_SIGNAL_FUNC(gtk_filedialog_response_callback), GTK_SIGNAL_FUNC(gtk_filedialog_response_callback),
(gpointer*)this); (gpointer*)this);
m_path = m_dir; m_path = m_dir;
if (!m_path.empty() && m_path.Last() != wxT('/')) if (!m_path.empty() && m_path.Last() != wxT('/'))
m_path += wxT('/'); m_path += wxT('/');
m_path += m_fileName; m_path += m_fileName;
SetPath(m_path); SetPath(m_path);
SetWildcard(wildCard); SetWildcard(wildCard);
SetFilterIndex(0); SetFilterIndex(0);
} }
@@ -241,7 +241,7 @@ bool wxFileDialog::Show( bool show )
return wxGenericFileDialog::Show( show ); return wxGenericFileDialog::Show( show );
} }
void wxFileDialog::GetFilenames(wxArrayString& files) const void wxFileDialog::GetFilenames(wxArrayString& files) const
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
@@ -251,7 +251,7 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
{ {
wxString name,ext; wxString name,ext;
wxSplitPath(files[n], NULL, &name, &ext); wxSplitPath(files[n], NULL, &name, &ext);
if (!ext.IsEmpty()) if (!ext.empty())
{ {
name += wxT("."); name += wxT(".");
name += ext; name += ext;
@@ -264,15 +264,15 @@ void wxFileDialog::GetFilenames(wxArrayString& files) const
wxGenericFileDialog::GetFilenames( files ); wxGenericFileDialog::GetFilenames( files );
} }
void wxFileDialog::GetPaths(wxArrayString& paths) const void wxFileDialog::GetPaths(wxArrayString& paths) const
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
paths.Empty(); paths.Empty();
if (GetWindowStyle() & wxMULTIPLE) if (GetWindowStyle() & wxMULTIPLE)
{ {
GSList *gpathsi = GSList *gpathsi =
gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget)); gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_widget));
GSList *gpaths = gpathsi; GSList *gpaths = gpathsi;
while (gpathsi) while (gpathsi)
@@ -282,7 +282,7 @@ void wxFileDialog::GetPaths(wxArrayString& paths) const
g_free(gpathsi->data); g_free(gpathsi->data);
gpathsi = gpathsi->next; gpathsi = gpathsi->next;
} }
if (gpaths) if (gpaths)
g_slist_free(gpaths); g_slist_free(gpaths);
} }
else else
@@ -304,7 +304,7 @@ void wxFileDialog::SetMessage(const wxString& message)
SetTitle(message); SetTitle(message);
} }
else else
#endif #endif
wxGenericFileDialog::SetMessage( message ); wxGenericFileDialog::SetMessage( message );
} }
@@ -322,7 +322,7 @@ void wxFileDialog::SetPath(const wxString& path)
UpdateDialog(); UpdateDialog();
} }
else else
#endif #endif
wxGenericFileDialog::SetPath( path ); wxGenericFileDialog::SetPath( path );
} }
@@ -331,7 +331,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
#ifdef __WXGTK24__ #ifdef __WXGTK24__
if (!gtk_check_version(2,4,0)) if (!gtk_check_version(2,4,0))
{ {
if (wxDirExists(dir)) if (wxPathExists(dir))
{ {
m_dir = dir; m_dir = dir;
m_path = wxFileName(m_dir, m_fileName).GetFullPath(); m_path = wxFileName(m_dir, m_fileName).GetFullPath();
@@ -339,7 +339,7 @@ void wxFileDialog::SetDirectory(const wxString& dir)
} }
} }
else else
#endif #endif
wxGenericFileDialog::SetDirectory( dir ); wxGenericFileDialog::SetDirectory( dir );
} }
@@ -364,7 +364,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
{ {
m_wildCard = wildCard; m_wildCard = wildCard;
GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget); GtkFileChooser* chooser = GTK_FILE_CHOOSER(m_widget);
// empty current filter list: // empty current filter list:
GSList* ifilters = gtk_file_chooser_list_filters(chooser); GSList* ifilters = gtk_file_chooser_list_filters(chooser);
GSList* filters = ifilters; GSList* filters = ifilters;
@@ -374,7 +374,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
ifilters = ifilters->next; ifilters = ifilters->next;
} }
g_slist_free(filters); g_slist_free(filters);
// parse filters // parse filters
wxArrayString wildDescriptions, wildFilters; wxArrayString wildDescriptions, wildFilters;
if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters)) if (!wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, wildFilters))
@@ -398,7 +398,7 @@ void wxFileDialog::SetWildcard(const wxString& wildCard)
after = after.AfterLast(wxT(';')); after = after.AfterLast(wxT(';'));
} }
while (!after.empty()); while (!after.empty());
gtk_file_chooser_add_filter(chooser, filter); gtk_file_chooser_add_filter(chooser, filter);
} }
} }
@@ -441,7 +441,7 @@ void wxFileDialog::UpdateDialog()
{ {
#ifdef __WXGTK24__ #ifdef __WXGTK24__
// set currently selected directory to match the path: // set currently selected directory to match the path:
if (!m_dir.empty() && wxDirExists(m_dir)) if (!m_dir.empty() && wxPathExists(m_dir))
{ {
// NB: This is important -- if we set directory only and not the path, // NB: This is important -- if we set directory only and not the path,
// then dialog will still remember old path set using previous // then dialog will still remember old path set using previous
@@ -456,18 +456,18 @@ void wxFileDialog::UpdateDialog()
if (m_fileName.empty()) if (m_fileName.empty())
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_dir)); wxGTK_CONV(m_dir));
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_dir)); wxGTK_CONV(m_dir));
} }
// if the user set only the directory (e.g. by calling SetDirectory) // if the user set only the directory (e.g. by calling SetDirectory)
// and not the default filename, then we don't want to set the filename: // and not the default filename, then we don't want to set the filename:
if (!m_fileName.empty()) if (!m_fileName.empty())
{ {
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(m_widget),
wxGTK_CONV(m_path)); wxGTK_CONV(m_path));
// pre-fill the filename when saving, too (there's no text entry // pre-fill the filename when saving, too (there's no text entry
// control when opening a file, so it doesn't make sense to // control when opening a file, so it doesn't make sense to
// do this when opening files): // do this when opening files):
@@ -488,7 +488,7 @@ void wxFileDialog::UpdateFromDialog()
GSList *filters = fnode; GSList *filters = fnode;
GtkFileFilter *current = GtkFileFilter *current =
gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget)); gtk_file_chooser_get_filter(GTK_FILE_CHOOSER(m_widget));
int i = 0; int i = 0;
m_filterIndex = 0; m_filterIndex = 0;
while (fnode) while (fnode)

View File

@@ -119,7 +119,7 @@ static void wxFixOPENFILENAME(LPOPENFILENAME ofn)
if ( (ofn->Flags & OFN_ALLOWMULTISELECT) && if ( (ofn->Flags & OFN_ALLOWMULTISELECT) &&
ofn->lpstrFile[ofn->nFileOffset-1] != wxT('\0') ) ofn->lpstrFile[ofn->nFileOffset-1] != wxT('\0') )
{ {
if ( wxDirExists(ofn->lpstrFile) ) if ( wxPathExists(ofn->lpstrFile) )
{ {
// 1st component is dir => multiple files selected // 1st component is dir => multiple files selected
ofn->nFileOffset = wxStrlen(ofn->lpstrFile)+1; ofn->nFileOffset = wxStrlen(ofn->lpstrFile)+1;

View File

@@ -460,16 +460,6 @@ wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
return (wxChar *)wxGetHomeDir(&s_home); return (wxChar *)wxGetHomeDir(&s_home);
} }
bool wxDirExists(const wxString& dir)
{
#ifdef __WXMICROWIN__
return wxPathExist(dir);
#elif defined(__WIN32__)
DWORD attribs = GetFileAttributes(dir);
return ((attribs != (DWORD)-1) && (attribs & FILE_ATTRIBUTE_DIRECTORY));
#endif // Win32/__WXMICROWIN__
}
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
{ {
#ifdef __WXWINCE__ #ifdef __WXWINCE__
@@ -1231,9 +1221,9 @@ wxToolkitInfo& wxAppTraits::GetToolkitInfo()
#ifdef __WXWINCE__ #ifdef __WXWINCE__
case VER_PLATFORM_WIN32_CE: case VER_PLATFORM_WIN32_CE:
s_ver = wxWINDOWS_CE; s_ver = wxWINDOWS_CE;
#endif #endif
} }
#endif #endif
} }
} }

View File

@@ -431,7 +431,7 @@ wxChar* wxGetUserHome (
char *wxBuffer = new wxChar[256]; char *wxBuffer = new wxChar[256];
#ifndef __EMX__ #ifndef __EMX__
if (sUser1 != _T("")) if (!sUser1.empty())
{ {
wxChar zTmp[64]; wxChar zTmp[64];
@@ -453,7 +453,7 @@ wxChar* wxGetUserHome (
} }
} }
#endif #endif
if (sUser1 == _T("")) if (sUser1.empty())
{ {
if ((zHome = wxGetenv(_T("HOME"))) != NULL) if ((zHome = wxGetenv(_T("HOME"))) != NULL)
{ {
@@ -468,13 +468,6 @@ wxChar* wxGetUserHome (
return NULL; // No home known! return NULL; // No home known!
} }
bool wxDirExists(
const wxString& rDir
)
{
return (::DosSetCurrentDir(WXSTRINGCAST rDir));
}
wxString WXDLLEXPORT wxPMErrorToStr( wxString WXDLLEXPORT wxPMErrorToStr(
ERRORID vError ERRORID vError
) )

View File

@@ -106,11 +106,6 @@ wxChar *wxGetUserHome(const wxString& WXUNUSED(user))
return NULL; return NULL;
} }
bool wxDirExists(const wxString& dir)
{
return false;
}
bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree) bool wxGetDiskSpace(const wxString& path, wxLongLong *pTotal, wxLongLong *pFree)
{ {
return false; return false;

View File

@@ -912,7 +912,7 @@ void ArchiveTestCase<ClassFactoryT>::VerifyDir(wxString& path,
name = m_factory->GetInternalName( name = m_factory->GetInternalName(
path.substr(rootlen, wxString::npos)); path.substr(rootlen, wxString::npos));
bool isDir = wxDirExists(path); bool isDir = wxPathExists(path);
if (isDir) if (isDir)
name += _T("/"); name += _T("/");