fix for temp file creation under Windows
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
(although :filename works as well).
|
(although :filename works as well).
|
||||||
Since the volume is just part of the file path, it is not
|
Since the volume is just part of the file path, it is not
|
||||||
treated like a separate entity as it is done under DOS and
|
treated like a separate entity as it is done under DOS and
|
||||||
VMS, it is just treated as another dir.
|
VMS, it is just treated as another dir.
|
||||||
|
|
||||||
wxPATH_VMS: VMS native format, absolute file names have the form
|
wxPATH_VMS: VMS native format, absolute file names have the form
|
||||||
<device>:[dir1.dir2.dir3]file.txt
|
<device>:[dir1.dir2.dir3]file.txt
|
||||||
@@ -237,13 +237,13 @@ void wxFileName::Assign(const wxString& volume,
|
|||||||
{
|
{
|
||||||
wxPathFormat my_format = GetFormat( format );
|
wxPathFormat my_format = GetFormat( format );
|
||||||
wxString my_path = path;
|
wxString my_path = path;
|
||||||
|
|
||||||
m_dirs.Clear();
|
m_dirs.Clear();
|
||||||
|
|
||||||
if (!my_path.empty())
|
if (!my_path.empty())
|
||||||
{
|
{
|
||||||
// 1) Determine if the path is relative or absolute.
|
// 1) Determine if the path is relative or absolute.
|
||||||
|
|
||||||
switch (my_format)
|
switch (my_format)
|
||||||
{
|
{
|
||||||
case wxPATH_MAC:
|
case wxPATH_MAC:
|
||||||
@@ -251,7 +251,7 @@ void wxFileName::Assign(const wxString& volume,
|
|||||||
// We then remove a leading ":". The reason is in our
|
// We then remove a leading ":". The reason is in our
|
||||||
// storage form for relative paths:
|
// storage form for relative paths:
|
||||||
// ":dir:file.txt" actually means "./dir/file.txt" in
|
// ":dir:file.txt" actually means "./dir/file.txt" in
|
||||||
// DOS notation and should get stored as
|
// DOS notation and should get stored as
|
||||||
// (relative) (dir) (file.txt)
|
// (relative) (dir) (file.txt)
|
||||||
// "::dir:file.txt" actually means "../dir/file.txt"
|
// "::dir:file.txt" actually means "../dir/file.txt"
|
||||||
// stored as (relative) (..) (dir) (file.txt)
|
// stored as (relative) (..) (dir) (file.txt)
|
||||||
@@ -275,11 +275,11 @@ void wxFileName::Assign(const wxString& volume,
|
|||||||
wxFAIL_MSG( wxT("error") );
|
wxFAIL_MSG( wxT("error") );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) Break up the path into its members. If the original path
|
// 2) Break up the path into its members. If the original path
|
||||||
// was just "/" or "\\", m_dirs will be empty. We know from
|
// was just "/" or "\\", m_dirs will be empty. We know from
|
||||||
// the m_relative field, if this means "nothing" or "root dir".
|
// the m_relative field, if this means "nothing" or "root dir".
|
||||||
|
|
||||||
wxStringTokenizer tn( my_path, GetPathSeparators(my_format) );
|
wxStringTokenizer tn( my_path, GetPathSeparators(my_format) );
|
||||||
|
|
||||||
while ( tn.HasMoreTokens() )
|
while ( tn.HasMoreTokens() )
|
||||||
@@ -523,7 +523,7 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
|
|||||||
#ifndef __WATCOMC__
|
#ifndef __WATCOMC__
|
||||||
::DosCreateDir(wxStringBuffer(path, MAX_PATH), NULL);
|
::DosCreateDir(wxStringBuffer(path, MAX_PATH), NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else // !Windows, !OS/2
|
#else // !Windows, !OS/2
|
||||||
if ( dir.empty() )
|
if ( dir.empty() )
|
||||||
{
|
{
|
||||||
@@ -628,7 +628,16 @@ wxFileName::CreateTempFileName(const wxString& prefix, wxFile *fileTemp)
|
|||||||
{
|
{
|
||||||
// open the file - of course, there is a race condition here, this is
|
// open the file - of course, there is a race condition here, this is
|
||||||
// why we always prefer using mkstemp()...
|
// why we always prefer using mkstemp()...
|
||||||
if ( !fileTemp->Open(path, wxFile::write_excl, wxS_IRUSR | wxS_IWUSR) )
|
//
|
||||||
|
// NB: GetTempFileName() under Windows creates the file, so using
|
||||||
|
// write_excl there would fail
|
||||||
|
if ( !fileTemp->Open(path,
|
||||||
|
#if defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
||||||
|
wxFile::write,
|
||||||
|
#else
|
||||||
|
wxFile::write_excl,
|
||||||
|
#endif
|
||||||
|
wxS_IRUSR | wxS_IWUSR) )
|
||||||
{
|
{
|
||||||
// FIXME: If !ok here should we loop and try again with another
|
// FIXME: If !ok here should we loop and try again with another
|
||||||
// file name? That is the standard recourse if open(O_EXCL)
|
// file name? That is the standard recourse if open(O_EXCL)
|
||||||
@@ -870,7 +879,7 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
|
|||||||
{
|
{
|
||||||
m_dirs.Insert(wxT(".."), 0u);
|
m_dirs.Insert(wxT(".."), 0u);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_relative = TRUE;
|
m_relative = TRUE;
|
||||||
|
|
||||||
// we were modified
|
// we were modified
|
||||||
@@ -1037,7 +1046,7 @@ wxString wxFileName::GetPath( bool add_separator, wxPathFormat format ) const
|
|||||||
if (!m_relative)
|
if (!m_relative)
|
||||||
fullpath += wxFILE_SEP_PATH_UNIX;
|
fullpath += wxFILE_SEP_PATH_UNIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// then concatenate all the path components using the path separator
|
// then concatenate all the path components using the path separator
|
||||||
size_t dirCount = m_dirs.GetCount();
|
size_t dirCount = m_dirs.GetCount();
|
||||||
if ( dirCount )
|
if ( dirCount )
|
||||||
@@ -1123,7 +1132,7 @@ wxString wxFileName::GetFullPath( wxPathFormat format ) const
|
|||||||
// else ignore
|
// else ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the leading character
|
// the leading character
|
||||||
if ( format == wxPATH_MAC && m_relative )
|
if ( format == wxPATH_MAC && m_relative )
|
||||||
{
|
{
|
||||||
@@ -1139,7 +1148,7 @@ wxString wxFileName::GetFullPath( wxPathFormat format ) const
|
|||||||
if (!m_relative)
|
if (!m_relative)
|
||||||
fullpath += wxFILE_SEP_PATH_UNIX;
|
fullpath += wxFILE_SEP_PATH_UNIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
// then concatenate all the path components using the path separator
|
// then concatenate all the path components using the path separator
|
||||||
size_t dirCount = m_dirs.GetCount();
|
size_t dirCount = m_dirs.GetCount();
|
||||||
if ( dirCount )
|
if ( dirCount )
|
||||||
|
Reference in New Issue
Block a user