#include "wx/intl.h"
#include "wx/log.h"
#include "wx/utils.h"
+ #include "wx/crt.h"
#endif
#include "wx/filename.h"
#endif
-wxULongLong wxInvalidSize = (unsigned)-1;
+#if wxUSE_LONGLONG
+extern const wxULongLong wxInvalidSize = (unsigned)-1;
+#endif // wxUSE_LONGLONG
// ----------------------------------------------------------------------------
{
m_hFile = ::CreateFile
(
- filename, // name
+ filename.fn_str(), // name
mode == Read ? GENERIC_READ // access mask
: GENERIC_WRITE,
FILE_SHARE_READ | // sharing mode
DWORD attributes = FILE_ATTRIBUTE_TEMPORARY |
FILE_FLAG_DELETE_ON_CLOSE;
- HANDLE h = ::CreateFile(filename, access, 0, NULL,
+ HANDLE h = ::CreateFile(filename.fn_str(), access, 0, NULL,
disposition, attributes, NULL);
return wxOpenOSFHandle(h, wxO_BINARY);
}
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
- if ( !::GetTempFileName(dir, name, 0, wxStringBuffer(path, MAX_PATH + 1)) )
+ if ( !::GetTempFileName(dir.fn_str(), name.fn_str(), 0,
+ wxStringBuffer(path, MAX_PATH + 1)) )
{
wxLogLastError(_T("GetTempFileName"));
path += _T("XXXXXX");
// we need to copy the path to the buffer in which mkstemp() can modify it
- wxCharBuffer buf( wxConvFile.cWX2MB( path ) );
+ wxCharBuffer buf(path.fn_str());
// cast is safe because the string length doesn't change
int fdTemp = mkstemp( (char*)(const char*) buf );
size_t count = dirs.GetCount();
for ( size_t i = 0; i < count; i++ )
{
- if ( i > 0 ||
-#if defined(__WXMAC__) && !defined(__DARWIN__)
- // relative pathnames are exactely the other way round under mac...
- !filename.IsAbsolute()
-#else
- filename.IsAbsolute()
-#endif
- )
+ if ( i > 0 || filename.IsAbsolute() )
currPath += wxFILE_SEP_PATH;
currPath += dirs[i];
wxString path(GetFullPath());
#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
- DWORD sz = ::GetShortPathName(path, NULL, 0);
+ DWORD sz = ::GetShortPathName(path.fn_str(), NULL, 0);
if ( sz != 0 )
{
wxString pathOut;
if ( ::GetShortPathName
(
- path,
+ path.fn_str(),
wxStringBuffer(pathOut, sz),
sz
) != 0 )
if ( s_pfnGetLongPathName )
{
- DWORD dwSize = (*s_pfnGetLongPathName)(path, NULL, 0);
+ DWORD dwSize = (*s_pfnGetLongPathName)(path.fn_str(), NULL, 0);
if ( dwSize > 0 )
{
if ( (*s_pfnGetLongPathName)
(
- path,
+ path.fn_str(),
wxStringBuffer(pathOut, dwSize),
dwSize
) != 0 )
continue;
}
- hFind = ::FindFirstFile(tmpPath, &findFileData);
+ hFind = ::FindFirstFile(tmpPath.fn_str(), &findFileData);
if (hFind == INVALID_HANDLE_VALUE)
{
// Error: most likely reason is that path doesn't exist, so
{
#if defined(__WXMSW__) || defined(__OS2__) || defined(__DOS__)
format = wxPATH_DOS;
-#elif defined(__WXMAC__) && !defined(__DARWIN__)
- format = wxPATH_MAC;
#elif defined(__VMS)
format = wxPATH_VMS;
#else
// file size functions
// ----------------------------------------------------------------------------
+#if wxUSE_LONGLONG
+
/* static */
wxULongLong wxFileName::GetSize(const wxString &filename)
{
DWORD lpFileSizeHigh;
DWORD ret = GetFileSize(f, &lpFileSizeHigh);
- if (ret == INVALID_FILE_SIZE)
+ if ( ret == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR )
return wxInvalidSize;
- // compose the low-order and high-order byte sizes
- return wxULongLong(ret | (lpFileSizeHigh << sizeof(WORD)*2));
-
-#else // ! __WIN32__
-
+ return wxULongLong(lpFileSizeHigh, ret);
+#else // ! __WIN32__
wxStructStat st;
#ifndef wxNEED_WX_UNISTD_H
if (wxStat( filename.fn_str() , &st) != 0)
return GetHumanReadableSize(GetSize(), failmsg, precision);
}
+#endif // wxUSE_LONGLONG
// ----------------------------------------------------------------------------
// Mac-specific functions