-
Notifications
You must be signed in to change notification settings - Fork 4
/
DirObject.cpp
63 lines (50 loc) · 1.55 KB
/
DirObject.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// DirObject.cpp : implementation file
//
#include "stdafx.h"
#include "DirObject.h"
#include "FileObject.h"
// CDirObject
IMPLEMENT_DYNAMIC(CDirObject, CBaseObject)
CDirObject::CDirObject(const CString& dirPath)
: CBaseObject(dirPath)
{
CFileFind fileFind;
BOOL bWorking = fileFind.FindFile(dirPath+_T("\\*.*"));
while (bWorking)
{
bWorking = fileFind.FindNextFile();
if (fileFind.IsDots())
continue;
if (fileFind.IsDirectory())
{
CDirObject* pDirObject = new CDirObject(fileFind.GetFilePath());
m_dirArray.Add(pDirObject);
}
else
{
CFileObject* pFileObject = new CFileObject(fileFind.GetFilePath());
m_fileArray.Add(pFileObject);
}
}
}
CDirObject::~CDirObject()
{
INT_PTR dirCount = m_dirArray.GetSize();//m_dirArray.GetCount();
for (INT_PTR dirIndex = 0; dirIndex < dirCount; dirIndex++)
delete m_dirArray.GetAt(dirIndex);
INT_PTR fileCount = m_fileArray.GetSize();//m_fileArray.GetCount();
for (INT_PTR fileIndex = 0; fileIndex < fileCount; fileIndex++)
delete m_fileArray.GetAt(fileIndex);
}
// CDirObject member functions
ULONGLONG CDirObject::GetSizeOnDisc()
{
ULONGLONG sectorSize = 0;
INT_PTR dirCount = m_dirArray.GetSize();//m_dirArray.GetCount();
for (INT_PTR dirIndex = 0; dirIndex < dirCount; dirIndex++)
sectorSize += m_dirArray.GetAt(dirIndex)->GetSizeOnDisc();
INT_PTR fileCount = m_fileArray.GetSize();//m_fileArray.GetCount();
for (INT_PTR fileIndex = 0; fileIndex < fileCount; fileIndex++)
sectorSize += m_fileArray.GetAt(fileIndex)->GetSizeOnDisc();
return sectorSize;
}