Introduction
Recently I had to copy a file from my computer to my friends computer. It was of 8 MB and was huge
for one floppy. So, I created my own software for moving that file.
This software creates 1-9 segments of one file.
Creating a segment means making rewriting the same file. The segments are named as xxx.fa1, xxx.fa2 xxx.fa3 ... xxx.fa9.
It creates a file like xxx.faz which is the info file which holds information about the original file
that was segmented. To desegment a file back to original file, xxx.faz has to be opened and it
should be in the same directory where all the other segments are and the original file
will be created in the same directory.
How to use
There are only three functions
OpenSegFile()
CreateSegments()
DeSegment()
The concept is that to read a file's length and divide it into
as many segments as the user wants by opening it in binary mode and then writing the amount of
data to different segments.
The CSegFile
class supports two progress bars and one static control to provide information.
First create your progress bars on a dialog (with ID's IDC_STATIC_INFO
, IDC_PROGRESS_BAR
,
and IDC_PROGRESS_SEG
respectively).
To use them, first add code like this into your program:
CSegFile segFile
segFile.spStatic = (CStatic*) GetDlgItem(IDC_STATIC_INFO);
segFile.pProgress=(CProgressCtrl*)GetDlgItem(IDC_PROGRESS_BAR);
segFile.pSegProgress=(CProgressCtrl*)GetDlgItem(IDC_PROGRESS_SEG);
To open a file you can use code like
CFileDialog fdl(TRUE,NULL,NULL,NULL,NULL,this);
if (fdl.DoModal()==IDOK)
{
CString szFileName;
szFileName = fdl.m_ofn.lpstrFile;
segFile.OpenSegFile(szFileName);
m_currentFile = szFileName;
UpdateData(FALSE);
}
Then you can use this line for segmenting:
segFile.CreateSegments(iSegs);
To desegment a file open the info file xxx.faz and call the the function like this one.
segFile.DeSegment();
I tested it on my computer and my friend's computer. I had no means to check it on NT and
win2000. For comments and suggestions contact me at faizan_naqvi@hotmail.com