tools/installer/CFileList.cpp
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/tools/installer/CFileList.cpp	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,151 +0,0 @@
     1.4 -#include "CFileList.h"
     1.5 -#include "InstallerUtil.h"
     1.6 -
     1.7 -using namespace std;
     1.8 -
     1.9 -CFileList::CFileList(const TCHAR *name) : m_TotalSize(0), m_RecursiveSize(0), 
    1.10 -	m_bGotRecursiveSize(false)
    1.11 -{
    1.12 -	UTIL_Format(m_FolderName, sizeof(m_FolderName) / sizeof(TCHAR), _T("%s"), name);
    1.13 -}
    1.14 -
    1.15 -CFileList::~CFileList()
    1.16 -{
    1.17 -	list<CFileList *>::iterator iter;
    1.18 -
    1.19 -	for (iter = m_folder_list.begin();
    1.20 -		 iter != m_folder_list.end();
    1.21 -		 iter++)
    1.22 -	{
    1.23 -		delete (*iter);
    1.24 -	}
    1.25 -}
    1.26 -
    1.27 -const TCHAR *CFileList::GetFolderName()
    1.28 -{
    1.29 -	return m_FolderName;
    1.30 -}
    1.31 -
    1.32 -void CFileList::AddFolder(CFileList *pFileList)
    1.33 -{
    1.34 -	m_folder_list.push_back(pFileList);
    1.35 -}
    1.36 -
    1.37 -void CFileList::AddFile(const TCHAR *name, unsigned __int64 size)
    1.38 -{
    1.39 -	CFileListEntry entry;
    1.40 -	
    1.41 -	UTIL_Format(entry.file, sizeof(entry.file) / sizeof(TCHAR), _T("%s"), name);
    1.42 -	entry.size = size;
    1.43 -
    1.44 -	m_file_list.push_back(entry);
    1.45 -	m_TotalSize += size;
    1.46 -}
    1.47 -
    1.48 -unsigned __int64 CFileList::GetRecursiveSize()
    1.49 -{
    1.50 -	if (m_bGotRecursiveSize)
    1.51 -	{
    1.52 -		return m_RecursiveSize;
    1.53 -	}
    1.54 -
    1.55 -	m_RecursiveSize = m_TotalSize;
    1.56 -
    1.57 -	list<CFileList *>::iterator iter;
    1.58 -	for (iter = m_folder_list.begin(); iter != m_folder_list.end(); iter++)
    1.59 -	{
    1.60 -		m_RecursiveSize += (*iter)->GetRecursiveSize();
    1.61 -	}
    1.62 -
    1.63 -	m_bGotRecursiveSize = true;
    1.64 -
    1.65 -	return m_RecursiveSize;
    1.66 -}
    1.67 -
    1.68 -const TCHAR *CFileList::PeekCurrentFile()
    1.69 -{
    1.70 -	if (m_file_list.empty())
    1.71 -	{
    1.72 -		return NULL;
    1.73 -	}
    1.74 -
    1.75 -	return m_file_list.begin()->file;
    1.76 -}
    1.77 -
    1.78 -void CFileList::PopCurrentFile()
    1.79 -{
    1.80 -	m_file_list.erase(m_file_list.begin());
    1.81 -}
    1.82 -
    1.83 -CFileList *CFileList::PeekCurrentFolder()
    1.84 -{
    1.85 -	if (m_folder_list.empty())
    1.86 -	{
    1.87 -		return NULL;
    1.88 -	}
    1.89 -
    1.90 -	return *(m_folder_list.begin());
    1.91 -}
    1.92 -
    1.93 -void CFileList::PopCurrentFolder()
    1.94 -{
    1.95 -	m_folder_list.erase(m_folder_list.begin());
    1.96 -}
    1.97 -
    1.98 -void RecursiveBuildFileList(CFileList *file_list, const TCHAR *current_folder)
    1.99 -{
   1.100 -	HANDLE hFind;
   1.101 -	WIN32_FIND_DATA fd;
   1.102 -	TCHAR path[MAX_PATH];
   1.103 -
   1.104 -	UTIL_PathFormat(path, sizeof(path) / sizeof(TCHAR), _T("%s\\*.*"), current_folder);
   1.105 -
   1.106 -	if ((hFind = FindFirstFile(path, &fd)) == INVALID_HANDLE_VALUE)
   1.107 -	{
   1.108 -		return;
   1.109 -	}
   1.110 -
   1.111 -	do
   1.112 -	{
   1.113 -		if (tstrcasecmp(fd.cFileName, _T(".")) == 0
   1.114 -			|| tstrcasecmp(fd.cFileName, _T("..")) == 0)
   1.115 -		{
   1.116 -			continue;
   1.117 -		}
   1.118 -
   1.119 -		if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
   1.120 -		{
   1.121 -			CFileList *pSubList = new CFileList(fd.cFileName);
   1.122 -
   1.123 -			UTIL_PathFormat(path,
   1.124 -				sizeof(path) / sizeof(TCHAR),
   1.125 -				_T("%s\\%s"), 
   1.126 -				current_folder,
   1.127 -				fd.cFileName);			
   1.128 -
   1.129 -			RecursiveBuildFileList(pSubList, path);
   1.130 -
   1.131 -			file_list->AddFolder(pSubList);
   1.132 -		}
   1.133 -		else
   1.134 -		{
   1.135 -			LARGE_INTEGER li;
   1.136 -
   1.137 -			li.LowPart = fd.nFileSizeLow;
   1.138 -			li.HighPart = fd.nFileSizeHigh;
   1.139 -
   1.140 -			file_list->AddFile(fd.cFileName, li.QuadPart);
   1.141 -		}
   1.142 -	} while (FindNextFile(hFind, &fd));
   1.143 -
   1.144 -	FindClose(hFind);
   1.145 -}
   1.146 -
   1.147 -CFileList *CFileList::BuildFileList(const TCHAR *name, const TCHAR *root_folder)
   1.148 -{
   1.149 -	CFileList *pFileList = new CFileList(name);
   1.150 -
   1.151 -	RecursiveBuildFileList(pFileList, root_folder);
   1.152 -
   1.153 -	return pFileList;
   1.154 -}