extern const wxULongLong wxInvalidSize = (unsigned)-1;
#endif // wxUSE_LONGLONG
-#ifdef __WIN32__
- // this define is missing from VC6 headers
- #ifndef INVALID_FILE_ATTRIBUTES
- #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
- #endif
-#endif // __WIN32__
-
namespace
{
// access time (see #10567)
m_hFile = ::CreateFile
(
- filename.fn_str(), // name
+ filename.t_str(), // name
mode == ReadAttr ? FILE_READ_ATTRIBUTES // access mask
: FILE_WRITE_ATTRIBUTES,
FILE_SHARE_READ | // sharing mode
/* static */
bool wxFileName::FileExists( const wxString &filePath )
{
-#if defined(__WXPALMOS__)
- return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// we must use GetFileAttributes() instead of the ANSI C functions because
// it can cope with network (UNC) paths unlike them
- DWORD ret = ::GetFileAttributes(filePath.fn_str());
+ DWORD ret = ::GetFileAttributes(filePath.t_str());
return (ret != INVALID_FILE_ATTRIBUTES) && !(ret & FILE_ATTRIBUTE_DIRECTORY);
#else // !__WIN32__
strPath << wxT('.');
#endif
-#if defined(__WXPALMOS__)
- return false;
-#elif defined(__WIN32__) && !defined(__WXMICROWIN__)
+#if defined(__WIN32__) && !defined(__WXMICROWIN__)
// stat() can't cope with network paths
- DWORD ret = ::GetFileAttributes(strPath.fn_str());
+ DWORD ret = ::GetFileAttributes(strPath.t_str());
return (ret != INVALID_FILE_ATTRIBUTES) && (ret & FILE_ATTRIBUTE_DIRECTORY);
#elif defined(__OS2__)
int fd = wxTempOpen(path, deleteOnClose);
if (fd == -1)
return false;
- file->Attach(wx_fdopen(fd, "w+b"));
+ file->Attach(wx_fdopen(fd, "w+b"), path);
return file->IsOpened();
#endif // wx_fdopen
}
}
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
- if ( !::GetTempFileName(dir.fn_str(), name.fn_str(), 0,
- wxStringBuffer(path, MAX_PATH + 1)) )
+ if (!::GetTempFileName(dir.t_str(), name.t_str(), 0,
+ wxStringBuffer(path, MAX_PATH + 1)))
{
wxLogLastError(wxT("GetTempFileName"));
if ( ffileTemp )
{
#ifdef wx_fdopen
- ffileTemp->Attach(wx_fdopen(fdTemp, "r+b"));
+ ffileTemp->Attach(wx_fdopen(fdTemp, "r+b"), path);
#else
ffileTemp->Open(path, wxT("r+b"));
close(fdTemp);
}
#else // !HAVE_MKTEMP (includes __DOS__)
// generate the unique file name ourselves
- #if !defined(__DOS__) && !defined(__PALMOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) )
+ #if !defined(__DOS__) && (!defined(__MWERKS__) || defined(__DARWIN__) )
path << (unsigned int)getpid();
#endif
wxLogLastError(wxT("GetTempPath"));
}
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
- dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
+ dir = wxMacFindFolderNoSeparator(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
#endif // systems with native way
}
else // we got directory from an environment variable
SHFILEOPSTRUCT fileop;
wxZeroMemory(fileop);
fileop.wFunc = FO_DELETE;
+ #if defined(__CYGWIN__) && defined(wxUSE_UNICODE)
+ fileop.pFrom = path.wc_str();
+ #else
fileop.pFrom = path.fn_str();
+ #endif
fileop.fFlags = FOF_SILENT | FOF_NOCONFIRMATION;
#ifndef __WXWINCE__
// FOF_NOERRORUI is not defined in WinCE
if ( dir == wxT("..") )
{
- if ( m_dirs.IsEmpty() )
+ if ( m_dirs.empty() )
{
- wxLogError(_("The path '%s' contains too many \"..\"!"),
- GetFullPath().c_str());
- return false;
- }
+ // We have more ".." than directory components so far.
+ // Don't treat this as an error as the path could have been
+ // entered by user so try to handle it reasonably: if the
+ // path is absolute, just ignore the extra ".." because
+ // "/.." is the same as "/". Otherwise, i.e. for relative
+ // paths, keep ".." unchanged because removing it would
+ // modify the file a relative path refers to.
+ if ( !m_relative )
+ continue;
- m_dirs.RemoveAt(m_dirs.GetCount() - 1);
- continue;
+ }
+ else // Normal case, go one step up.
+ {
+ m_dirs.pop_back();
+ continue;
+ }
}
}
wxString path(GetFullPath());
#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
- DWORD sz = ::GetShortPathName(path.fn_str(), NULL, 0);
+ DWORD sz = ::GetShortPathName(path.t_str(), NULL, 0);
if ( sz != 0 )
{
wxString pathOut;
if ( ::GetShortPathName
(
- path.fn_str(),
+ path.t_str(),
wxStringBuffer(pathOut, sz),
sz
) != 0 )
if ( s_pfnGetLongPathName )
{
- DWORD dwSize = (*s_pfnGetLongPathName)(path.fn_str(), NULL, 0);
+ DWORD dwSize = (*s_pfnGetLongPathName)(path.t_str(), NULL, 0);
if ( dwSize > 0 )
{
if ( (*s_pfnGetLongPathName)
(
- path.fn_str(),
+ path.t_str(),
wxStringBuffer(pathOut, dwSize),
dwSize
) != 0 )
continue;
}
- hFind = ::FindFirstFile(tmpPath.fn_str(), &findFileData);
+ hFind = ::FindFirstFile(tmpPath.t_str(), &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
// Error: most likely reason is that path doesn't exist, so
if (!wxFileExists(filename))
return wxInvalidSize;
-#if defined(__WXPALMOS__)
- // TODO
- return wxInvalidSize;
-#elif defined(__WIN32__)
+#if defined(__WIN32__)
wxFileHandle f(filename, wxFileHandle::ReadAttr);
if (!f.IsOk())
return wxInvalidSize;