Visit the Ultimate Toolbox main page for an overview and configuration guide to the Ultimate Toolbox library.
The Ultimate Toolbox contains some useful utilities for file encryption and compression, comparison, search and replace and more.
COXDiffProgress classes combine to encapsulate binary differences and are able to compute the differences between two versions of a file.
Imagine that you have an original file and an updated file. Using the
COXBinDiffCalculator, you can see what has changed between the original and the updated version. This difference can then be written to a third file. Later on you can reproduce the updated version using the original and the difference file.
Difference = Update - Original and Update = Original + Difference. This can be useful if you want to send an updated file version to other people. You don't have to send them the entire new file, just the differences. These can then be applied to the original file which results in a fully updated version. Normally the difference file is much smaller then the entire updated file. You can supply path specifications directly to create the difference or updated file.
void SubtractFiles(LPCTSTR orgFilNam, LPCTSTR derivedFilNam,
LPCTSTR diffFilNam, COXDiffFileHeader* pHeader = NULL);
void AddFiles(LPCTSTR orgFilNam, LPCTSTR derivedFilNam, LPCTSTR diffFilNam,
COXDiffFileHeader* pHeader = NULL);
Another possibility would be to create three
CFile derived objects, open them and let the
COXBinDiffCalculator object use them. This creates the possibility of using other
CFile based classes -
COXCryptFile or your own.
virtual void SubtractFiles(CFile* pOrgFil, CFile* pDerivedFil,
CFile* pDiffFil, COXDiffFileHeader* pHeader = NULL);
virtual void AddFiles(CFile* pOrgFil, CFile* pDerivedFil, CFile* pDiffFil,
COXDiffFileHeader* pHeader = NULL);
While the differences are being computed or applied, a progress bar can help visualize how much has already been completed. This information is supplied to a
COXDiffProgress object. By default this is just written to standard output (e.g. a console program). You can derive your own class from it and make another visual indicator:
void ReplaceProgressBar(COXDiffProgress* pProgressBar);
If you want to use the class only to AddFiles you can #define BDEXTR as 1, which will make the class more compact.
See the compiled HTML help for complete class references for these.
COXConvertedFile provide various forms of file compression and encryption.
COXCompressedFile class encapsulates compression over a
CFile object. Simply put,
COXCompressedFile enhances the
CFile class to allow the data to be compressed. You treat a
COXCompressedFile in the same way as a
CFile object except that some operations are not available on the compressed file. These operations are:
Setting the file size via
Locking and unlocking a byte range via
- Flushing a file via Flush.
In each of these cases, the
COXCompressedFile class will throw a
CNotSupportedException MFC exception object.
COXCompressor class encapsulates an enhanced version of the Lempel Ziv 77 compression algorithm. It is based on the code supplied by Mark Nelson in his book The Data Compression Book, (M&T Publishing 1992). This algorithm is based on a sliding window dictionary-based compression scheme.
To compress and uncompress (or expand) data use the following functions:
int Compress(const LPBYTE pInBuffer, int nInLength, LPBYTE pOutBuffer, int
int Expand (const LPBYTE pInBuffer, int nInLength, LPBYTE pOutBuffer,
Each of these functions takes a pointer to input data identified by
pInBuffer and writes the compressed (if calling
Compress) or uncompressed (if calling
Expand) data to the output buffer
COXConvertedFile, COXCryptFile and COXMDCCryptor
COXCryptFile is derived from the
COXConvertedFile which in turn extends the MFCs
CFile class to facilitate block encryption and decryption operations on a file.
COXCryptFile layers a
COXMDCCryptor to provide MD5 block encryption for files.
CProtectedFile class in the samples\Advenced\DIBManager sample uses these calsses to apply protection to files:
BOOL CProtectedFile::SetProtection(CFile* pFile)
pApp->ErrorNotify(_T("Cannot protect image!"));
See the File Management | Compression and Encryption section of compiled HTML help for more on these classes and their usage.
Note: In versions previous to 9.0 of the Ultimate Toolbox library
COXCryptFile did not ship with the main installation files of Ultimate Toolbox. They were available to users within North America only, in compliance with certain U.S. export restrictions concerning encryption algorithms.
The File Watcher sample in action.
COXFileWatchNotifier organize file change notifications in a number of directories supplied by the user.
See the File Watcher article for more on this class and its usage.
COXFileChanger class facilitates search and replace of a files contents.
The samples\utility\FileChanger example project in action.
COXFileChanger can be set to send notifications (WM_OX_FILE_MATCH_FOUND, WM_OX_FILE_PRE_REPLACE, WM_OX_FILE_POST_REPLACE) to a window to allow for confirmation of replacement actions resulting from calls to the Search and Replace methods. This bit of code asks the user whether to add this instance to the count of items found - the search can also be cancelled by setting the data
m_bContinue flag to false:
LRESULT CFileChangerDemoDlg::OnFileMatchFound(WPARAM wParam,
COXFileChanger::COXFileChangerData* pFileChangerData = (
switch(AfxMessageBox(sMsg, MB_YESNOCANCEL | MB_ICONQUESTION))
case IDCANCEL: pFileChangerData->m_bContinue = FALSE;
case IDNO: return FALSE;
Visit the URL article for more on this class and its usage.
COXUUDecoder class performs decoding of Unix to Unix encoded files.
Unix to Unix encoding arose from the need to transfer binary data through 7 bit ASCII text protocols, and survives as one encoding scheme available for MIME encoded email and news messages.
hr = UUDecoder.UUDecodeFile(
"c:\temp\msg.uue", "c:\uudecoded", DecodedArray);
The code above examines whether the file c:\temp\msg.uue is a uuencoded file or not. If it is a uuencoded file, it tries to decode it and save the file(s) with the filename(s) it finds in the uuencoded file and place the saved file(s) in the directory c:\uudecoded as specified by the user. If the uuencoded file is a multiple part file, it will decode and save all parts with their stored names in the directory c:\uudecoded. After the
UUDecode function is complete, you can examine the
CStringArray to find out which files were saved and where they were saved.
To give the part(s) of a (multiple part) uuencoded file, other filenames than the ones stored in the uuencoded file, you must set the strings(paths) in the
CStringArray before you pass it to the uudecode function.
See the compiled HTML help documentation for more on the
Initial CodeProject release August 2007.