There are also UNC names of the form \\share\fullpath
- wxPATH_MAC: Mac OS 8/9 and Mac OS X under CodeWarrior 7 format, absolute file
+ wxPATH_MAC: Mac OS 8/9 and Mac OS X under CodeWarrior 7 format, absolute file
names have the form
volume:dir1:...:dirN:filename
and the relative file names are either
or just
filename
(although :filename works as well).
- :::file is not yet supported. TODO.
+ :::filename.ext is not yet supported. TODO.
+ Since the volume is just part of the file path, it is not
+ treated like a separate entity as it is done under DOS.
wxPATH_VMS: VMS native format, absolute file names have the form
<device>:[dir1.dir2.dir3]file.txt
#include <unix.h>
#endif
+#ifdef __WATCOMC__
+ #include <io.h>
+ #include <sys/utime.h>
+ #include <sys/stat.h>
+#endif
+
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
{
SetCwd(cwdOld);
}
-
+
return cwd;
}
#ifndef __WATCOMC__
::DosCreateDir(wxStringBuffer(MAX_PATH), NULL);
#endif
-
-#else // !Windows, !OS/2
+
+#else // !Windows, !OS/2, !DOS
if ( dir.empty() )
{
dir = wxGetenv(_T("TMP"));
if ( dir.empty() )
{
// default
+ #ifdef __DOS__
+ dir = _T(".");
+ #else
dir = _T("/tmp");
+ #endif
}
}
if ( !wxEndsWithPathSeparator(dir) &&
(name.empty() || !wxIsPathSeparator(name[0u])) )
{
- path += _T('/');
+ path += wxFILE_SEP_PATH;
}
path += name;
-#ifdef HAVE_MKSTEMP
+#if defined(__DOS__) && defined(__WATCOMC__)
+ // scratch space for mkstemp()
+ path += _T("XXXXXX");
+
+ // can use the cast here because the length doesn't change and the string
+ // is not shared
+ if ( !_mktemp((char *)path.mb_str()) )
+ {
+ // this might be not necessary as mkstemp() on most systems should have
+ // already done it but it doesn't hurt neither...
+ path.clear();
+ }
+#elif defined(HAVE_MKSTEMP)
// scratch space for mkstemp()
path += _T("XXXXXX");
wxFileName curDir;
format = GetFormat(format);
-
+
// make the path absolute
if ( (flags & wxPATH_NORM_ABSOLUTE) && !IsAbsolute() )
{
}
}
}
-
+
// handle ~ stuff under Unix only
if ( (format == wxPATH_UNIX) && (flags & wxPATH_NORM_TILDE) )
{
return FALSE;
}
- m_dirs.Remove(m_dirs.GetCount() - 1);
+ m_dirs.RemoveAt(m_dirs.GetCount() - 1);
continue;
}
}
while ( !m_dirs.IsEmpty() && !fnBase.m_dirs.IsEmpty() &&
m_dirs[0u].IsSameAs(fnBase.m_dirs[0u], withCase) )
{
- m_dirs.Remove(0u);
- fnBase.m_dirs.Remove(0u);
+ m_dirs.RemoveAt(0);
+ fnBase.m_dirs.RemoveAt(0);
}
// add as many ".." as needed
{
wxString sepVol;
- if ( GetFormat(format) != wxPATH_UNIX )
+ if ( (GetFormat(format) == wxPATH_DOS) ||
+ (GetFormat(format) == wxPATH_VMS) )
{
- // so far it is the same for all systems which have it
sepVol = wxFILE_SEP_DSK;
}
- //else: leave empty, no volume separators under Unix
+ //else: leave empty
return sepVol;
}
// first put the volume
if ( !m_volume.empty() )
{
- // special Windows UNC paths hack, part 2: undo what we did in
- // SplitPath() and make an UNC path if we have a drive which is not a
- // single letter (hopefully the network shares can't be one letter only
- // although I didn't find any authoritative docs on this)
- if ( format == wxPATH_DOS && m_volume.length() > 1 )
- {
- fullpath << wxFILE_SEP_PATH_DOS << wxFILE_SEP_PATH_DOS << m_volume;
- }
- else // !UNC
- {
- fullpath << m_volume << GetVolumeSeparator(format);
+ {
+ // Special Windows UNC paths hack, part 2: undo what we did in
+ // SplitPath() and make an UNC path if we have a drive which is not a
+ // single letter (hopefully the network shares can't be one letter only
+ // although I didn't find any authoritative docs on this)
+ if ( format == wxPATH_DOS && m_volume.length() > 1 )
+ {
+ fullpath << wxFILE_SEP_PATH_DOS << wxFILE_SEP_PATH_DOS << m_volume;
+ }
+ else // !UNC
+ {
+ fullpath << m_volume << GetVolumeSeparator(format);
+ }
}
}
{
// under Mac, we must have a path separator in the beginning of the
// relative path - otherwise it would be parsed as an absolute one
- if ( format == wxPATH_MAC && m_volume.empty() && !m_dirs[0].empty() )
+ if ( format == wxPATH_MAC && m_dirs[0].empty() )
{
fullpath += wxFILE_SEP_PATH_MAC;
}
{
if (format == wxPATH_NATIVE)
{
-#if defined(__WXMSW__) || defined(__WXPM__)
+#if defined(__WXMSW__) || defined(__WXPM__) || defined(__DOS__)
format = wxPATH_DOS;
#elif defined(__WXMAC__) && !defined(__DARWIN__)
format = wxPATH_MAC;
}
}
- // do we have the volume name in the beginning?
- wxString sepVol = GetVolumeSeparator(format);
- if ( !sepVol.empty() )
+ // We separate the volume here
+ if ( format == wxPATH_DOS || format == wxPATH_VMS )
{
+ wxString sepVol = GetVolumeSeparator(format);
+
size_t posFirstColon = fullpath.find_first_of(sepVol);
if ( posFirstColon != wxString::npos )
{
const wxDateTime *dtAccess,
const wxDateTime *dtMod)
{
-#if defined(__UNIX_LIKE__)
+#if defined(__UNIX_LIKE__) || (defined(__DOS__) && defined(__WATCOMC__))
if ( !dtAccess && !dtMod )
{
// can't modify the creation time anyhow, don't try
wxDateTime *dtMod,
wxDateTime *dtChange) const
{
-#if defined(__UNIX_LIKE__)
- wxStructStat stBuf;
- if ( wxStat(GetFullPath(), &stBuf) == 0 )
- {
- if ( dtAccess )
- dtAccess->Set(stBuf.st_atime);
- if ( dtMod )
- dtMod->Set(stBuf.st_mtime);
- if ( dtChange )
- dtChange->Set(stBuf.st_ctime);
-
- return TRUE;
- }
-#elif defined(__WXMAC__)
+#if defined(__UNIX_LIKE__) || defined(__WXMAC__) || (defined(__DOS__) && defined(__WATCOMC__))
wxStructStat stBuf;
if ( wxStat(GetFullPath(), &stBuf) == 0 )
{