Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/windirstat.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorassarbad <none@none>2008-12-27 05:53:17 +0300
committerassarbad <none@none>2008-12-27 05:53:17 +0300
commit4f22dfcac7a074079e3b02afdaf2976c2085753c (patch)
tree8a38dcac36c7dd5dc55a5aa01671d793541408d8 /windirstat/mountpoints.cpp
parent22b89178914ec4fe02031b988d051bbcaeed37bb (diff)
- Literally hundreds of cosmetic changes
- First fixes to the multi-select code, especially to allow WDS to run after build ;)
Diffstat (limited to 'windirstat/mountpoints.cpp')
-rw-r--r--windirstat/mountpoints.cpp384
1 files changed, 191 insertions, 193 deletions
diff --git a/windirstat/mountpoints.cpp b/windirstat/mountpoints.cpp
index bc7cc8a..4468557 100644
--- a/windirstat/mountpoints.cpp
+++ b/windirstat/mountpoints.cpp
@@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// Author(s): - bseifert -> http://windirstat.info/contact/bernhard/
-// - assarbad -> oliver@windirstat.info
+// - assarbad -> http://windirstat.info/contact/oliver/
//
// $Id$
@@ -34,238 +34,236 @@
CMountPoints::~CMountPoints()
{
- Clear();
+ Clear();
}
void CMountPoints::Clear()
{
- m_drive.RemoveAll();
-
- POSITION pos = m_volume.GetStartPosition();
- while(pos != NULL)
- {
- CString volume;
- PointVolumeArray *pva = NULL;
- m_volume.GetNextAssoc(pos, volume, pva);
- ASSERT_VALID(pva);
- delete pva;
- }
- m_volume.RemoveAll();
+ m_drive.RemoveAll();
+
+ POSITION pos = m_volume.GetStartPosition();
+ while(pos != NULL)
+ {
+ CString volume;
+ PointVolumeArray *pva = NULL;
+ m_volume.GetNextAssoc(pos, volume, pva);
+ ASSERT_VALID(pva);
+ delete pva;
+ }
+ m_volume.RemoveAll();
}
void CMountPoints::Initialize()
{
- Clear();
+ Clear();
- if(!m_va.IsSupported())
- {
- return;
- }
+ if(!m_va.IsSupported())
+ {
+ return;
+ }
- GetDriveVolumes();
- GetAllMountPoints();
+ GetDriveVolumes();
+ GetAllMountPoints();
}
void CMountPoints::GetDriveVolumes()
{
- m_drive.SetSize(32);
-
- DWORD drives = GetLogicalDrives();
- int i;
- DWORD mask = 0x00000001;
- for(i = 0; i < 32; i++, mask <<= 1)
- {
- CString volume;
-
- if((drives & mask) != 0)
- {
- CString s;
- s.Format(TEXT("%c:\\"), i + chrCapA);
-
- BOOL b = m_va.GetVolumeNameForVolumeMountPoint(s, volume.GetBuffer(_MAX_PATH), _MAX_PATH);
- volume.ReleaseBuffer();
-
- if(!b)
- {
- TRACE(TEXT("GetVolumeNameForVolumeMountPoint(%s) failed.\n"), s);
- volume.Empty();
- }
- }
-
- m_drive[i]= volume;
- }
+ m_drive.SetSize(32);
+
+ DWORD drives = GetLogicalDrives();
+ int i;
+ DWORD mask = 0x00000001;
+ for(i = 0; i < 32; i++, mask <<= 1)
+ {
+ CString volume;
+
+ if((drives & mask) != 0)
+ {
+ CString s;
+ s.Format(_T("%c:\\"), i + chrCapA);
+
+ BOOL b = m_va.GetVolumeNameForVolumeMountPoint(s, volume.GetBuffer(_MAX_PATH), _MAX_PATH);
+ volume.ReleaseBuffer();
+
+ if(!b)
+ {
+ TRACE(_T("GetVolumeNameForVolumeMountPoint(%s) failed.\n"), s);
+ volume.Empty();
+ }
+ }
+
+ m_drive[i]= volume;
+ }
}
void CMountPoints::GetAllMountPoints()
{
- TCHAR volume[_MAX_PATH];
- HANDLE hvol = m_va.FindFirstVolume(volume, countof(volume));
- if(hvol == INVALID_HANDLE_VALUE)
- {
- TRACE(TEXT("No volumes found.\r\n"));
- return;
- }
-
- for(BOOL bContinue = true; bContinue; bContinue = m_va.FindNextVolume(hvol, volume, countof(volume)))
- {
- PointVolumeArray *pva = new PointVolumeArray;
- ASSERT_VALID(pva);
-
- DWORD sysflags;
- CString fsname;
- BOOL b = GetVolumeInformation(volume, NULL, 0, NULL, NULL, &sysflags, fsname.GetBuffer(_MAX_PATH), _MAX_PATH);
- fsname.ReleaseBuffer();
-
- if(!b)
- {
- TRACE(TEXT("This file system (%s) is not ready.\r\n"), volume);
- m_volume.SetAt(volume, pva);
- continue;
- }
-
- if((sysflags & FILE_SUPPORTS_REPARSE_POINTS) == 0)
- {
- // No support for reparse points, and therefore for volume
- // mount points, which are implemented using reparse points.
- TRACE(TEXT("This file system (%s) does not support volume mount points.\r\n"), volume);
- m_volume.SetAt(volume, pva);
- continue;
- }
-
- TCHAR point[_MAX_PATH];
- HANDLE h = m_va.FindFirstVolumeMountPoint(volume, point, countof(point));
- if(h == INVALID_HANDLE_VALUE)
- {
- TRACE(TEXT("No volume mount points found on %s.\r\n"), volume);
- m_volume.SetAt(volume, pva);
- continue;
- }
-
- for(BOOL bCont = true; bCont; bCont = m_va.FindNextVolumeMountPoint(h, point, countof(point)))
- {
- CString uniquePath = volume;
- uniquePath += point;
- CString mountedVolume;
-
- BOOL b = m_va.GetVolumeNameForVolumeMountPoint(uniquePath, mountedVolume.GetBuffer(_MAX_PATH), _MAX_PATH);
- mountedVolume.ReleaseBuffer();
-
- if(!b)
- {
- TRACE(TEXT("GetVolumeNameForVolumeMountPoint(%s) failed.\r\n"), uniquePath);
- continue;
- }
-
- SPointVolume pv;
- pv.point = point;
- pv.volume = mountedVolume;
-
- pv.point.MakeLower();
-
- pva->Add(pv);
- }
- m_va.FindVolumeMountPointClose(h);
-
- m_volume.SetAt(volume, pva);
- }
-
- (void)m_va.FindVolumeClose(hvol);
+ TCHAR volume[_MAX_PATH];
+ HANDLE hvol = m_va.FindFirstVolume(volume, countof(volume));
+ if(hvol == INVALID_HANDLE_VALUE)
+ {
+ TRACE(_T("No volumes found.\r\n"));
+ return;
+ }
+
+ for(BOOL bContinue = true; bContinue; bContinue = m_va.FindNextVolume(hvol, volume, countof(volume)))
+ {
+ PointVolumeArray *pva = new PointVolumeArray;
+ ASSERT_VALID(pva);
+
+ DWORD sysflags;
+ CString fsname;
+ BOOL b = GetVolumeInformation(volume, NULL, 0, NULL, NULL, &sysflags, fsname.GetBuffer(_MAX_PATH), _MAX_PATH);
+ fsname.ReleaseBuffer();
+
+ if(!b)
+ {
+ TRACE(_T("This file system (%s) is not ready.\r\n"), volume);
+ m_volume.SetAt(volume, pva);
+ continue;
+ }
+
+ if((sysflags & FILE_SUPPORTS_REPARSE_POINTS) == 0)
+ {
+ // No support for reparse points, and therefore for volume
+ // mount points, which are implemented using reparse points.
+ TRACE(_T("This file system (%s) does not support volume mount points.\r\n"), volume);
+ m_volume.SetAt(volume, pva);
+ continue;
+ }
+
+ TCHAR point[_MAX_PATH];
+ HANDLE h = m_va.FindFirstVolumeMountPoint(volume, point, countof(point));
+ if(h == INVALID_HANDLE_VALUE)
+ {
+ TRACE(_T("No volume mount points found on %s.\r\n"), volume);
+ m_volume.SetAt(volume, pva);
+ continue;
+ }
+
+ for(BOOL bCont = true; bCont; bCont = m_va.FindNextVolumeMountPoint(h, point, countof(point)))
+ {
+ CString uniquePath = volume;
+ uniquePath += point;
+ CString mountedVolume;
+
+ BOOL b = m_va.GetVolumeNameForVolumeMountPoint(uniquePath, mountedVolume.GetBuffer(_MAX_PATH), _MAX_PATH);
+ mountedVolume.ReleaseBuffer();
+
+ if(!b)
+ {
+ TRACE(_T("GetVolumeNameForVolumeMountPoint(%s) failed.\r\n"), uniquePath);
+ continue;
+ }
+
+ SPointVolume pv;
+ pv.point = point;
+ pv.volume = mountedVolume;
+
+ pv.point.MakeLower();
+
+ pva->Add(pv);
+ }
+ m_va.FindVolumeMountPointClose(h);
+
+ m_volume.SetAt(volume, pva);
+ }
+
+ (void)m_va.FindVolumeClose(hvol);
#ifdef _DEBUG
- POSITION pos = m_volume.GetStartPosition();
- while(pos != NULL)
- {
- CString volume;
- PointVolumeArray *pva = NULL;
- m_volume.GetNextAssoc(pos, volume, pva);
- pva->AssertValid();
- }
+ POSITION pos = m_volume.GetStartPosition();
+ while(pos != NULL)
+ {
+ CString volume;
+ PointVolumeArray *pva = NULL;
+ m_volume.GetNextAssoc(pos, volume, pva);
+ pva->AssertValid();
+ }
#endif
-
}
bool CMountPoints::IsMountPoint(CString path)
{
- if(path.GetLength() < 3 || path[1] != chrColon || path[2] != chrBackslash)
- {
- // Don't know how to make out mount points on UNC paths ###
- return false;
- }
+ if(path.GetLength() < 3 || path[1] != chrColon || path[2] != chrBackslash)
+ {
+ // Don't know how to make out mount points on UNC paths ###
+ return false;
+ }
- ASSERT(path.GetLength() >= 3);
- ASSERT(path[1] == chrColon);
- ASSERT(path[2] == chrBackslash);
+ ASSERT(path.GetLength() >= 3);
+ ASSERT(path[1] == chrColon);
+ ASSERT(path[2] == chrBackslash);
- if(!m_va.IsSupported())
- {
- return false;
- }
+ if(!m_va.IsSupported())
+ {
+ return false;
+ }
- if(path.Right(1) != chrBackslash)
- {
- path += TEXT("\\");
- }
+ if(path.Right(1) != chrBackslash)
+ {
+ path += _T("\\");
+ }
- path.MakeLower();
+ path.MakeLower();
- CString volume = m_drive[path[0] - chrSmallA];
- path = path.Mid(3);
+ CString volume = m_drive[path[0] - chrSmallA];
+ path = path.Mid(3);
- return IsVolumeMountPoint(volume, path);
+ return IsVolumeMountPoint(volume, path);
}
// Check whether the current item is a junction point but no volume mount point
// as the latter ones are treated differently (see above).
bool CMountPoints::IsJunctionPoint(CString path)
{
- if(IsMountPoint(path))
- {
- return false;
- }
-
- DWORD attr = GetFileAttributes(path);
- if(attr == INVALID_FILE_ATTRIBUTES)
- {
- return false;
- }
-
- return ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
+ if(IsMountPoint(path))
+ {
+ return false;
+ }
+
+ DWORD attr = GetFileAttributes(path);
+ if(attr == INVALID_FILE_ATTRIBUTES)
+ {
+ return false;
+ }
+
+ return ((attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
}
bool CMountPoints::IsVolumeMountPoint(CString volume, CString path)
{
- while(true)
- {
- int i = 0;
- PointVolumeArray *pva;
- if(!m_volume.Lookup(volume, pva))
- {
- TRACE(TEXT("CMountPoints: Volume(%s) unknown!\r\n"), volume);
- return false;
- }
-
- CString point;
- for(i = 0; i < pva->GetSize(); i++)
- {
- point = (*pva)[i].point;
- if(path.Left(point.GetLength()) == point)
- {
- break;
- }
- }
- if(i >= pva->GetSize())
- {
- return false;
- }
-
- if(path.GetLength() == point.GetLength())
- {
- return true;
- }
-
- volume = (*pva)[i].volume;
- path = path.Mid(point.GetLength());
- }
+ while(true)
+ {
+ int i = 0;
+ PointVolumeArray *pva;
+ if(!m_volume.Lookup(volume, pva))
+ {
+ TRACE(_T("CMountPoints: Volume(%s) unknown!\r\n"), volume);
+ return false;
+ }
+
+ CString point;
+ for(i = 0; i < pva->GetSize(); i++)
+ {
+ point = (*pva)[i].point;
+ if(path.Left(point.GetLength()) == point)
+ {
+ break;
+ }
+ }
+ if(i >= pva->GetSize())
+ {
+ return false;
+ }
+
+ if(path.GetLength() == point.GetLength())
+ {
+ return true;
+ }
+
+ volume = (*pva)[i].volume;
+ path = path.Mid(point.GetLength());
+ }
}
-