All:
- added wxDateSpan::operator==() and !=() (Lukasz Michalski)
+- added wxFileName::GetForbiddenChars() (Dimitri Schoolwerth)
- use true/false throughout the library instead of TRUE/FALSE
- wxStopWatch::Start() resumes the stop watch if paused, as per the docs
- added wxDirTraverser::OnOpenError() to customize the error handling
- fixes to the command line parsing error and usage messages
- modified wxFileName::CreateTempFileName() to open the file atomically
(if possible) and, especially, not to leak the file descriptors under Unix
-- memory leak in wxHTTP fixed (Dimitri)
+- memory leak in wxHTTP fixed (Dimitri Schoolwerth)
- fixes to AM_PATH_WXCONFIG autoconf macro
- added wxHashMap class that replaces type-unsafe wxHashTable and is modelled
after (non standard) STL hash_map
{
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_BEOS = wxPATH_UNIX,
- wxPATH_WIN = wxPATH_DOS,
- wxPATH_OS2 = wxPATH_DOS
+ wxPATH_MAX // Not a valid value for specifying path format
}
\end{verbatim}
\membersection{wxFileName::AssignCwd}\label{wxfilenameassigncwd}
-\func{void}{AssignCwd}{\param{const wxString\& }{volume = ""}}
+\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).
\func{static bool}{DirExists}{\param{const wxString\& }{dir}}
-Returns true if the directory with this name exists.
+Returns {\tt true} if the directory with this name exists.
\membersection{wxFileName::DirName}\label{wxfilenamedirname}
\func{static bool}{FileExists}{\param{const wxString\& }{file}}
-Returns true if the file with this name exists.
+Returns {\tt true} if the file with this name exists.
\wxheading{See also}
\membersection{wxFileName::GetCwd}\label{wxfilenamegetcwd}
-\func{wxString}{GetCwd}{\param{const wxString\& }{volume = ""}}
+\func{static wxString}{GetCwd}{\param{const wxString\& }{volume = ""}}
Retrieves the value of the current working directory on the specified volume. If
the volume is empty, the programs current working directory is returned for the
Returns the file name extension.
+\membersection{wxFileName::GetForbiddenChars}\label{wxfilenamegetforbiddenchars}
+
+\func{static wxString}{GetForbiddenChars}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+
+Returns the characters that can't be used in filenames and directory names for the specified format.
+
\membersection{wxFileName::GetFormat}\label{wxfilenamegetformat}
-\func{wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static wxPathFormat}{GetFormat}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
Returns the canonical path format for this platform.
\membersection{wxFileName::GetHomeDir}\label{wxfilenamegethomedir}
-\func{wxString}{GetHomeDir}{\void}
+\func{static wxString}{GetHomeDir}{\void}
Returns the home directory.
\membersection{wxFileName::GetPathSeparator}\label{wxfilenamegetpathseparator}
-\func{wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static wxChar}{GetPathSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
Returns the usually used path separator for this format. For all formats but
{\tt wxPATH\_DOS} there is only one path separator anyhow, but for DOS there
\membersection{wxFileName::GetPathSeparators}\label{wxfilenamegetpathseparators}
-\func{wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static wxString}{GetPathSeparators}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
Returns the string containing all the path separators for this format. For all
formats but {\tt wxPATH\_DOS} this string contains only one character but for
\membersection{wxFileName::GetVolumeSeparator}\label{wxfilenamegetvolumeseparator}
-\func{wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static wxString}{GetVolumeSeparator}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
Returns the string separating the volume from the path for this format.
\constfunc{bool}{HasExt}{\void}
-Returns true if an extension is present.
+Returns {\tt true} if an extension is present.
\membersection{wxFileName::HasName}\label{wxfilenamehasname}
\constfunc{bool}{HasName}{\void}
-Returns true if a name is present.
+Returns {\tt true} if a name is present.
\membersection{wxFileName::HasVolume}\label{wxfilenamehasvolume}
\constfunc{bool}{HasVolume}{\void}
-Returns true if a volume specifier is present.
+Returns {\tt true} if a volume specifier is present.
\membersection{wxFileName::InsertDir}\label{wxfilenameinsertdir}
\func{bool}{IsAbsolute}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
-Returns true if this filename is absolute.
+Returns {\tt true} if this filename is absolute.
\membersection{wxFileName::IsCaseSensitive}\label{wxfilenameiscasesensitive}
-\func{bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static bool}{IsCaseSensitive}{\param{wxPathFormat }{format = wxPATH\_NATIVE}}
-Returns true if the file names of this type are case-sensitive.
+Returns {\tt true} if the file names of this type are case-sensitive.
\membersection{wxFileName::IsOk}\label{wxfilenameisok}
\membersection{wxFileName::IsPathSeparator}\label{wxfilenameispathseparator}
-\func{bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{static bool}{IsPathSeparator}{\param{wxChar }{ch}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
Returns {\tt true} if the char is a path separator for this format.
\membersection{wxFileName::MakeRelativeTo}\label{wxfilenamemakerelativeto}
-\func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = ""}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
+\func{bool}{MakeRelativeTo}{\param{const wxString\& }{pathBase = wxEmptyString}, \param{wxPathFormat }{format = wxPATH\_NATIVE}}
This function tries to put this file name in a form relative to {\it pathBase}.
In other words, it returns the file name which should be used to access this
{
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_BEOS = wxPATH_UNIX,
- wxPATH_WIN = wxPATH_DOS,
- wxPATH_OS2 = wxPATH_DOS
+ wxPATH_MAX // Not a valid value for specifying path format
};
// the kind of normalization to do with the file name: these values can be
wxFile *fileTemp = NULL);
// directory creation and removal.
- // if full is TRUE, will try to make each directory in the path.
bool Mkdir( int perm = 0777, int flags = 0);
static bool Mkdir( const wxString &dir, int perm = 0777, int flags = 0 );
//
// pass an empty string to get a path relative to the working directory
//
- // returns TRUE if the file name was modified, FALSE if we failed to do
+ // returns true if the file name was modified, false if we failed to do
// anything with it (happens when the file is on a different volume,
// for example)
bool MakeRelativeTo(const wxString& pathBase = wxEmptyString,
bool IsRelative(wxPathFormat format = wxPATH_NATIVE) const
{ return !IsAbsolute(format); }
+ // Returns the characters that aren't allowed in filenames
+ // on the specified platform.
+ static wxString GetForbiddenChars(wxPathFormat format = wxPATH_NATIVE);
+
// Information about path format
// get the string separating the volume from the path for this format,
// that our path is '/', i.e. the root directory
//
// we use m_relative to distinguish between these two cases, it will be
- // TRUE in the former and FALSE in the latter
+ // true in the former and false in the latter
//
- // NB: the path is not absolute just because m_relative is FALSE, it still
+ // NB: the path is not absolute just because m_relative is false, it still
// needs the drive (i.e. volume) in some formats (Windows)
bool m_relative;
};
}
}
- // return TRUE only if the file could be opened successfully
+ // return true only if the file could be opened successfully
bool IsOk() const { return m_hFile != INVALID_HANDLE_VALUE; }
// get the handle
case wxPATH_VMS:
// TODO: what is the relative path format here?
- m_relative = FALSE;
+ m_relative = false;
break;
+ default:
+ wxFAIL_MSG( _T("Unknown path format") );
+ // !! Fall through !!
+
case wxPATH_UNIX:
// the paths of the form "~" or "~username" are absolute
m_relative = leadingChar != wxT('/') && leadingChar != _T('~');
m_relative = !IsPathSeparator(leadingChar, my_format);
break;
- default:
- wxFAIL_MSG( wxT("error") );
- break;
}
// 2) Break up the path into its members. If the original path
}
else // no path at all
{
- m_relative = TRUE;
+ m_relative = true;
}
}
m_ext = wxEmptyString;
// we don't have any absolute path for now
- m_relative = TRUE;
+ m_relative = true;
}
/* static */
if (!wxMkdir(currPath, perm))
{
// no need to try creating further directories
- return FALSE;
+ return false;
}
}
}
- return TRUE;
+ return true;
}
{
wxLogError(_("The path '%s' contains too many \"..\"!"),
GetFullPath().c_str());
- return FALSE;
+ return false;
}
m_dirs.RemoveAt(m_dirs.GetCount() - 1);
// we do have the path now
//
// NB: need to do this before (maybe) calling Assign() below
- m_relative = FALSE;
+ m_relative = false;
#if defined(__WIN32__)
if ( (flags & wxPATH_NORM_LONG) && (format == wxPATH_DOS) )
}
#endif // Win32
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
// if our path doesn't start with a path separator, it's not an absolute
// path
if ( m_relative )
- return FALSE;
+ return false;
if ( !GetVolumeSeparator(format).empty() )
{
// this format has volumes and an absolute path must have one, it's not
// enough to have the full path to bean absolute file under Windows
if ( GetVolume().empty() )
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
if ( !GetVolume().IsSameAs(fnBase.GetVolume(), withCase) )
{
// nothing done
- return FALSE;
+ return false;
}
// same drive, so we don't need our volume
}
}
- m_relative = TRUE;
+ m_relative = true;
// we were modified
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
fn2.Normalize(wxPATH_NORM_ALL & ~wxPATH_NORM_CASE, cwd, format);
if ( fn1.GetFullPath() == fn2.GetFullPath() )
- return TRUE;
+ return true;
// TODO: compare inodes for Unix, this works even when filenames are
// different but files are the same (symlinks) (VZ)
- return FALSE;
+ return false;
}
/* static */
return GetFormat(format) == wxPATH_UNIX;
}
+/* static */
+wxString wxFileName::GetForbiddenChars(wxPathFormat format)
+{
+ // Inits to forbidden characters that are common to (almost) all platforms.
+ wxString strForbiddenChars = wxT("*?");
+
+ // If asserts, wxPathFormat has been changed. In case of a new path format
+ // addition, the following code might have to be updated.
+ wxCOMPILE_TIME_ASSERT(wxPATH_MAX == 5, wxPathFormatChanged);
+ switch ( GetFormat(format) )
+ {
+ default :
+ wxFAIL_MSG( wxT("Unknown path format") );
+ // !! Fall through !!
+
+ case wxPATH_UNIX:
+ break;
+
+ case wxPATH_MAC:
+ // On a Mac even names with * and ? are allowed (Tested with OS
+ // 9.2.1 and OS X 10.2.5)
+ strForbiddenChars = wxEmptyString;
+ break;
+
+ case wxPATH_DOS:
+ strForbiddenChars += wxT("\\/:\"<>|");
+ break;
+
+ case wxPATH_VMS:
+ break;
+ }
+
+ return strForbiddenChars;
+}
+
/* static */
wxString wxFileName::GetVolumeSeparator(wxPathFormat format)
{
break;
default:
- wxFAIL_MSG( _T("unknown wxPATH_XXX style") );
+ wxFAIL_MSG( _T("Unknown wxPATH_XXX style") );
// fall through
case wxPATH_UNIX:
break;
default:
- wxFAIL_MSG( _T("unknown path format") );
+ wxFAIL_MSG( wxT("Unknown path format") );
// fall through
case wxPATH_UNIX:
break;
default:
- wxFAIL_MSG( wxT("unexpected path format") );
+ wxFAIL_MSG( wxT("Unexpected path format") );
// still fall through
case wxPATH_DOS:
path = GetFullPath();
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
- bool success = FALSE;
+ bool success = false;
#if wxUSE_DYNAMIC_LOADER
typedef DWORD (WINAPI *GET_LONG_PATH_NAME)(const wxChar *, wxChar *, DWORD);
- static bool s_triedToLoad = FALSE;
+ static bool s_triedToLoad = false;
if ( !s_triedToLoad )
{
// suppress the errors about missing GetLongPathName[AW]
wxLogNull noLog;
- s_triedToLoad = TRUE;
+ s_triedToLoad = true;
wxDynamicLibrary dllKernel(_T("kernel32"));
if ( dllKernel.IsLoaded() )
{
) != 0;
pathOut.UngetWriteBuf();
- success = TRUE;
+ success = true;
}
}
}
dtAccess ? &ftAccess : NULL,
dtMod ? &ftWrite : NULL) )
{
- return TRUE;
+ return true;
}
}
}
if ( !dtAccess && !dtMod )
{
// can't modify the creation time anyhow, don't try
- return TRUE;
+ return true;
}
// if dtAccess or dtMod is not specified, use the other one (which must be
utm.modtime = dtMod ? dtMod->GetTicks() : dtAccess->GetTicks();
if ( utime(GetFullPath().fn_str(), &utm) == 0 )
{
- return TRUE;
+ return true;
}
#else // other platform
#endif // platforms
wxLogSysError(_("Failed to modify file times for '%s'"),
GetFullPath().c_str());
- return FALSE;
+ return false;
}
bool wxFileName::Touch()
// under Unix touching file is simple: just pass NULL to utime()
if ( utime(GetFullPath().fn_str(), NULL) == 0 )
{
- return TRUE;
+ return true;
}
wxLogSysError(_("Failed to touch the file '%s'"), GetFullPath().c_str());
- return FALSE;
+ return false;
#else // other platform
wxDateTime dtNow = wxDateTime::Now();
}
else
{
- ok = FALSE;
+ ok = false;
}
}
if ( dtMod )
ConvertFileTimeToWx(dtMod, ftWrite);
- return TRUE;
+ return true;
}
#elif defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
wxStructStat stBuf;
if ( dtCreate )
dtCreate->Set(stBuf.st_ctime);
- return TRUE;
+ return true;
}
#else // other platform
#endif // platforms
wxLogSysError(_("Failed to retrieve file times for '%s'"),
GetFullPath().c_str());
- return FALSE;
+ return false;
}
#endif // wxUSE_DATETIME