more fixes for volume names handling
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12783 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -129,8 +129,7 @@ public:
|
|||||||
Assign(_T(""), path, name, ext, format);
|
Assign(_T(""), path, name, ext, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE)
|
void AssignDir(const wxString& dir, wxPathFormat format = wxPATH_NATIVE);
|
||||||
{ Assign(dir, _T(""), format); }
|
|
||||||
|
|
||||||
// assorted assignment operators
|
// assorted assignment operators
|
||||||
|
|
||||||
|
@@ -244,14 +244,20 @@ void wxFileName::Assign(const wxString& fullpath,
|
|||||||
Assign(volume, path, name, ext, format);
|
Assign(volume, path, name, ext, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileName::Assign(const wxString& path,
|
void wxFileName::Assign(const wxString& fullpath,
|
||||||
const wxString& fullname,
|
const wxString& fullname,
|
||||||
wxPathFormat format)
|
wxPathFormat format)
|
||||||
{
|
{
|
||||||
wxString name, ext;
|
wxString volume, path, name, ext;
|
||||||
SplitPath(fullname, NULL /* no path */, &name, &ext, format);
|
SplitPath(fullname, NULL /* no path */, &name, &ext, format);
|
||||||
|
SplitPath(fullpath, &volume, &path, NULL, NULL, format);
|
||||||
|
|
||||||
Assign(path, name, ext, format);
|
Assign(volume, path, name, ext, format);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxFileName::AssignDir(const wxString& dir, wxPathFormat format)
|
||||||
|
{
|
||||||
|
Assign(dir, _T(""), format);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFileName::Clear()
|
void wxFileName::Clear()
|
||||||
@@ -429,6 +435,20 @@ bool wxFileName::Normalize(wxPathNormalize flags,
|
|||||||
curDir.AssignCwd();
|
curDir.AssignCwd();
|
||||||
else
|
else
|
||||||
curDir.AssignDir(cwd);
|
curDir.AssignDir(cwd);
|
||||||
|
|
||||||
|
// the path may be not absolute because it doesn't have the volume name
|
||||||
|
// but in this case we shouldn't modify the directory components of it
|
||||||
|
// but just set the current volume
|
||||||
|
if ( !HasVolume() && curDir.HasVolume() )
|
||||||
|
{
|
||||||
|
SetVolume(curDir.GetVolume());
|
||||||
|
|
||||||
|
if ( IsAbsolute() )
|
||||||
|
{
|
||||||
|
// yes, it was the case - we don't need curDir then
|
||||||
|
curDir.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle ~ stuff under Unix only
|
// handle ~ stuff under Unix only
|
||||||
@@ -446,6 +466,7 @@ bool wxFileName::Normalize(wxPathNormalize flags,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// transform relative path into abs one
|
||||||
if ( curDir.IsOk() )
|
if ( curDir.IsOk() )
|
||||||
{
|
{
|
||||||
wxArrayString dirsNew = curDir.GetDirs();
|
wxArrayString dirsNew = curDir.GetDirs();
|
||||||
@@ -508,12 +529,12 @@ bool wxFileName::Normalize(wxPathNormalize flags,
|
|||||||
m_ext.MakeLower();
|
m_ext.MakeLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__WXMSW__) && defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
if (flags & wxPATH_NORM_LONG)
|
if ( (flags & wxPATH_NORM_LONG) && (format == wxPATH_DOS) )
|
||||||
{
|
{
|
||||||
Assign(GetLongPath());
|
Assign(GetLongPath());
|
||||||
}
|
}
|
||||||
#endif
|
#endif // Win32
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -556,31 +577,45 @@ bool wxFileName::IsAbsolute( wxPathFormat format )
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( GetFormat(format) )
|
format = GetFormat(format);
|
||||||
|
|
||||||
|
if ( format == wxPATH_UNIX )
|
||||||
{
|
{
|
||||||
case wxPATH_DOS:
|
const wxString& str = m_dirs[0u];
|
||||||
case wxPATH_VMS:
|
if ( str.empty() )
|
||||||
case wxPATH_MAC:
|
{
|
||||||
// must have the drive
|
// the path started with '/', it's an absolute one
|
||||||
return !m_volume.empty();
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
// the path is absolute if it starts with a path separator or
|
||||||
wxFAIL_MSG( _T("unknown wxPATH_XXX style") );
|
// with "~" or "~user"
|
||||||
// fall through
|
wxChar ch = str[0u];
|
||||||
|
|
||||||
case wxPATH_UNIX:
|
return IsPathSeparator(ch, format) || ch == _T('~');
|
||||||
const wxString& str = m_dirs[0u];
|
}
|
||||||
if ( str.empty() )
|
else // !Unix
|
||||||
{
|
{
|
||||||
// the path started with '/', it's an absolute one
|
// must have the drive
|
||||||
|
if ( m_volume.empty() )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
switch ( format )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG( _T("unknown wxPATH_XXX style") );
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxPATH_DOS:
|
||||||
|
return m_dirs[0u].empty();
|
||||||
|
|
||||||
|
case wxPATH_VMS:
|
||||||
|
// TODO: what is the relative path format here?
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
// the path is absolute if it starts with a path separator or
|
case wxPATH_MAC:
|
||||||
// with "~" or "~user"
|
return !m_dirs[0u].empty();
|
||||||
wxChar ch = str[0u];
|
}
|
||||||
|
|
||||||
return IsPathSeparator(ch, format) || ch == _T('~');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -808,9 +843,10 @@ wxString wxFileName::GetShortPath() const
|
|||||||
// Return the long form of the path (returns identity on non-Windows platforms)
|
// Return the long form of the path (returns identity on non-Windows platforms)
|
||||||
wxString wxFileName::GetLongPath() const
|
wxString wxFileName::GetLongPath() const
|
||||||
{
|
{
|
||||||
#if defined(__WXMSW__) && defined(__WIN32__) && !defined(__WXMICROWIN__)
|
wxString pathOut,
|
||||||
wxString path(GetFullPath());
|
path = GetFullPath();
|
||||||
wxString pathOut;
|
|
||||||
|
#if defined(__WIN32__) && !defined(__WXMICROWIN__)
|
||||||
bool success = FALSE;
|
bool success = FALSE;
|
||||||
|
|
||||||
// VZ: this code was disabled, why?
|
// VZ: this code was disabled, why?
|
||||||
@@ -876,17 +912,20 @@ wxString wxFileName::GetLongPath() const
|
|||||||
wxArrayString dirs = GetDirs();
|
wxArrayString dirs = GetDirs();
|
||||||
dirs.Add(GetFullName());
|
dirs.Add(GetFullName());
|
||||||
|
|
||||||
size_t count = dirs.GetCount();
|
|
||||||
size_t i;
|
|
||||||
wxString tmpPath;
|
wxString tmpPath;
|
||||||
|
|
||||||
for ( i = 0; i < count; i++ )
|
size_t count = dirs.GetCount();
|
||||||
|
for ( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
// We're using pathOut to collect the long-name path,
|
// We're using pathOut to collect the long-name path, but using a
|
||||||
// but using a temporary for appending the last path component which may be short-name
|
// temporary for appending the last path component which may be
|
||||||
|
// short-name
|
||||||
tmpPath = pathOut + dirs[i];
|
tmpPath = pathOut + dirs[i];
|
||||||
|
|
||||||
if (tmpPath.Last() == wxT(':'))
|
if ( tmpPath.empty() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ( tmpPath.Last() == wxT(':') )
|
||||||
{
|
{
|
||||||
// Can't pass a drive and root dir to FindFirstFile,
|
// Can't pass a drive and root dir to FindFirstFile,
|
||||||
// so continue to next dir
|
// so continue to next dir
|
||||||
@@ -901,21 +940,19 @@ wxString wxFileName::GetLongPath() const
|
|||||||
// Error: return immediately with the original path
|
// Error: return immediately with the original path
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
pathOut += findFileData.cFileName;
|
|
||||||
if ( (i < (count-1)) )
|
|
||||||
pathOut += wxFILE_SEP_PATH;
|
|
||||||
|
|
||||||
::FindClose(hFind);
|
pathOut += findFileData.cFileName;
|
||||||
}
|
if ( (i < (count-1)) )
|
||||||
|
pathOut += wxFILE_SEP_PATH;
|
||||||
|
|
||||||
|
::FindClose(hFind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else // !Win32
|
||||||
|
pathOut = path;
|
||||||
|
#endif // Win32/!Win32
|
||||||
|
|
||||||
return pathOut;
|
return pathOut;
|
||||||
#else
|
|
||||||
return GetFullPath();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPathFormat wxFileName::GetFormat( wxPathFormat format )
|
wxPathFormat wxFileName::GetFormat( wxPathFormat format )
|
||||||
|
Reference in New Issue
Block a user