This program example how to combine multiple files into a single file and be able to decompose itself. This technique is useful when making setup programs. I learned this technology on this site, and will be able to organize the extension, can merge files and directories, the number of unlimited.
The core program includes a merged file Class Ccombinefiles, a class cextractfiles for decomposing files, and information about a data class FileInfo file or directory information that represents a file or directory is represented by the FileInfo class. This class is defined as follows:class FileInfo
{
public:
const FileInfo &operator = (const FileInfo &fi);
FileInfo(CString szFileName, UINT nFileSize, UINT nPos, char type = 0);
FileInfo();
virtual ~FileInfo();
public:
CString szFileName;
UINT nSize;
UINT nPos;
char type; // d --- directory , f --- file , other --- no define
};
The merged file class Ccombinefiles is defined as follows:
class CCombineFiles
{
public:
bool Combine(CStringArray &fileList, CString szToFileName);
CCombineFiles(CString szExeFileName);
virtual ~CCombineFiles();
public:
bool WriteFileInfo(FileInfo fi, FILE *fp);
bool WriteString(CString szStr, FILE *fp);
bool WriteListInfo(CArray &fiList, FILE *fp, UINT nStartOffset);
bool CombineFile(CString szFileName, FILE *fp);
bool CombineDirectory(CString szDir, FILE *fp);
CString m_szExeFileName;
};