if ( m_hFile == INVALID_HANDLE_VALUE )
{
if ( mode == Read )
+ {
wxLogSysError(_("Failed to open '%s' for reading"),
filename.c_str());
+ }
else
+ {
wxLogSysError(_("Failed to open '%s' for writing"),
filename.c_str());
+ }
}
}
FILETIME ftLocal;
if ( !::FileTimeToLocalFileTime(&ftcopy, &ftLocal) )
{
- wxLogLastError(_T("FileTimeToLocalFileTime"));
+ wxLogLastError(wxT("FileTimeToLocalFileTime"));
}
SYSTEMTIME st;
if ( !::FileTimeToSystemTime(&ftLocal, &st) )
{
- wxLogLastError(_T("FileTimeToSystemTime"));
+ wxLogLastError(wxT("FileTimeToSystemTime"));
}
dt->Set(st.wDay, wxDateTime::Month(st.wMonth - 1), st.wYear,
FILETIME ftLocal;
if ( !::SystemTimeToFileTime(&st, &ftLocal) )
{
- wxLogLastError(_T("SystemTimeToFileTime"));
+ wxLogLastError(wxT("SystemTimeToFileTime"));
}
if ( !::LocalFileTimeToFileTime(&ftLocal, ft) )
{
- wxLogLastError(_T("LocalFileTimeToFileTime"));
+ wxLogLastError(wxT("LocalFileTimeToFileTime"));
}
}
break;
default:
- wxFAIL_MSG( _T("Unknown path format") );
+ wxFAIL_MSG( wxT("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 = leadingChar != wxT('/');
break;
case wxPATH_DOS:
SplitPath(fullname, &volDummy, &pathDummy, &name, &ext, &hasExt, format);
wxASSERT_MSG( volDummy.empty() && pathDummy.empty(),
- _T("the file name shouldn't contain the path") );
+ wxT("the file name shouldn't contain the path") );
SplitPath(fullpath, &volume, &path, &nameDummy, &extDummy, format);
wxASSERT_MSG( nameDummy.empty() && extDummy.empty(),
- _T("the path shouldn't contain file name nor extension") );
+ wxT("the path shouldn't contain file name nor extension") );
Assign(volume, path, name, ext, hasExt, format);
}
{
#ifndef wx_fdopen
*deleteOnClose = false;
- return file->Open(path, _T("w+b"));
+ return file->Open(path, wxT("w+b"));
#else // wx_fdopen
int fd = wxTempOpen(path, deleteOnClose);
if (fd == -1)
if ( !::GetTempFileName(dir.fn_str(), name.fn_str(), 0,
wxStringBuffer(path, MAX_PATH + 1)) )
{
- wxLogLastError(_T("GetTempFileName"));
+ wxLogLastError(wxT("GetTempFileName"));
path.clear();
}
#if defined(HAVE_MKSTEMP)
// scratch space for mkstemp()
- path += _T("XXXXXX");
+ path += wxT("XXXXXX");
// we need to copy the path to the buffer in which mkstemp() can modify it
wxCharBuffer buf(path.fn_str());
#ifdef wx_fdopen
ffileTemp->Attach(wx_fdopen(fdTemp, "r+b"));
#else
- ffileTemp->Open(path, _T("r+b"));
+ ffileTemp->Open(path, wxT("r+b"));
close(fdTemp);
#endif
}
#ifdef HAVE_MKTEMP
// same as above
- path += _T("XXXXXX");
+ path += wxT("XXXXXX");
wxCharBuffer buf = wxConvFile.cWX2MB( path );
if ( !mktemp( (char*)(const char*) buf ) )
for ( size_t n = 0; n < numTries; n++ )
{
// 3 hex digits is enough for numTries == 1000 < 4096
- pathTry = path + wxString::Format(_T("%.03x"), (unsigned int) n);
+ pathTry = path + wxString::Format(wxT("%.03x"), (unsigned int) n);
if ( !wxFileName::FileExists(pathTry) )
{
break;
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
if ( !::GetTempPath(MAX_PATH, wxStringBuffer(dir, MAX_PATH + 1)) )
{
- wxLogLastError(_T("GetTempPath"));
+ wxLogLastError(wxT("GetTempPath"));
}
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
dir = wxMacFindFolder(short(kOnSystemDisk), kTemporaryFolderType, kCreateFolder);
wxString path(dir);
if ( path.Last() == wxFILE_SEP_PATH )
path.RemoveLast();
- path += _T('\0');
+ path += wxT('\0');
SHFILEOPSTRUCT fileop;
wxZeroMemory(fileop);
{
// SHFileOperation may return non-Win32 error codes, so the error
// message can be incorrect
- wxLogApiError(_T("SHFileOperation"), ret);
+ wxLogApiError(wxT("SHFileOperation"), ret);
return false;
}
}
// handle ~ stuff under Unix only
- if ( (format == wxPATH_UNIX) && (flags & wxPATH_NORM_TILDE) )
+ if ( (format == wxPATH_UNIX) && (flags & wxPATH_NORM_TILDE) && m_relative )
{
if ( !dirs.IsEmpty() )
{
wxString dir = dirs[0u];
- if ( !dir.empty() && dir[0u] == _T('~') )
+ if ( !dir.empty() && dir[0u] == wxT('~') )
{
// to make the path absolute use the home directory
curDir.AssignDir(wxGetUserHome(dir.c_str() + 1));
-
- // if we are expanding the tilde, then this path
- // *should* be already relative (since we checked for
- // the tilde only in the first char of the first dir);
- // if m_relative==false, it's because it was initialized
- // from a string which started with /~; in that case
- // we reach this point but then need m_relative=true
- // for relative->absolute expansion later
- m_relative = true;
-
dirs.RemoveAt(0u);
}
}
// if we used e.g. tilde expansion previously and wxGetUserHome didn't
// return for some reason an absolute path, then curDir maybe not be absolute!
- if ( curDir.IsAbsolute(format) )
+ if ( !curDir.m_relative )
{
// we have prepended an absolute path and thus we are now an absolute
// file name too
bool wxFileName::IsAbsolute(wxPathFormat format) const
{
+ // unix paths beginning with ~ are reported as being absolute
+ if ( format == wxPATH_UNIX )
+ {
+ if ( !m_dirs.IsEmpty() )
+ {
+ wxString dir = m_dirs[0u];
+
+ if (!dir.empty() && dir[0u] == wxT('~'))
+ return true;
+ }
+ }
+
// if our path doesn't start with a path separator, it's not an absolute
// path
if ( m_relative )
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
+ // enough to have the full path to be an absolute file under Windows
if ( GetVolume().empty() )
return false;
}
// files)
if ( m_dirs.IsEmpty() && IsDir() )
{
- m_dirs.Add(_T('.'));
+ m_dirs.Add(wxT('.'));
}
}
break;
default:
- wxFAIL_MSG( _T("Unknown wxPATH_XXX style") );
+ wxFAIL_MSG( wxT("Unknown wxPATH_XXX style") );
// fall through
case wxPATH_UNIX:
// under VMS the end of the path is ']', not the path separator used to
// separate the components
- return format == wxPATH_VMS ? wxString(_T(']')) : GetPathSeparators(format);
+ return format == wxPATH_VMS ? wxString(wxT(']')) : GetPathSeparators(format);
}
/* static */
{
// wxString::Find() doesn't work as expected with NUL - it will always find
// it, so test for it separately
- return ch != _T('\0') && GetPathSeparators(format).Find(ch) != wxNOT_FOUND;
+ return ch != wxT('\0') && GetPathSeparators(format).Find(ch) != wxNOT_FOUND;
}
// ----------------------------------------------------------------------------
{
if ( dir.empty() )
{
- wxFAIL_MSG( _T("empty directory passed to wxFileName::InsertDir()") );
+ wxFAIL_MSG( wxT("empty directory passed to wxFileName::InsertDir()") );
return false;
}
{
if ( dir[n] == GetVolumeSeparator() || IsPathSeparator(dir[n]) )
{
- wxFAIL_MSG( _T("invalid directory component in wxFileName") );
+ wxFAIL_MSG( wxT("invalid directory component in wxFileName") );
return false;
}
case wxPATH_UNIX:
if ( !m_relative )
{
- // normally the absolute file names start with a slash
- // with one exception: the ones like "~/foo.bar" don't
- // have it
- if ( m_dirs.IsEmpty() || m_dirs[0u] != _T('~') )
- {
- fullpath += wxFILE_SEP_PATH_UNIX;
- }
+ fullpath += wxFILE_SEP_PATH_UNIX;
}
break;
{
s_triedToLoad = true;
- wxDynamicLibrary dllKernel(_T("kernel32"));
+ wxDynamicLibrary dllKernel(wxT("kernel32"));
- const wxChar* GetLongPathName = _T("GetLongPathName")
+ const wxChar* GetLongPathName = wxT("GetLongPathName")
#if wxUSE_UNICODE
- _T("W");
+ wxT("W");
#else // ANSI
- _T("A");
+ wxT("A");
#endif // Unicode/ANSI
if ( dllKernel.HasSymbol(GetLongPathName) )
if ( (posLastDot != wxString::npos) &&
(posLastDot == 0 ||
IsPathSeparator(fullpath[posLastDot - 1]) ||
- (format == wxPATH_VMS && fullpath[posLastDot - 1] == _T(']'))) )
+ (format == wxPATH_VMS && fullpath[posLastDot - 1] == wxT(']'))) )
{
// dot may be (and commonly -- at least under Unix -- is) the first
// character of the filename, don't treat the entire filename as
// special VMS hack: remove the initial bracket
if ( format == wxPATH_VMS )
{
- if ( (*pstrPath)[0u] == _T('[') )
+ if ( (*pstrPath)[0u] == wxT('[') )
pstrPath->erase(0, 1);
}
}