Hello,
I'm writing a short program that'll open a large file and cut it to smaller files of a defined size, and another program that'll do the inverse - stick the small files together to make one big file back.
For a reason I can't quite figure out, I'm getting an ifstream error when I try to run the code. Here's the important part :
Code:
fin.open("fileA.part", ios::binary);
fout.open(FILENAME, ios::binary);
char a;
int count(0);
while(count != PARTS+1)
{
if(fin.eof())
{
fin.close();
temp = filename;
files += 1;
temp += files;
temp += ending;
fin.open(temp.c_str(), ios::binary);
if(!fin) { cout << temp; Sleep(2000); }
}
count++;
while(fin.get(a)) fout << a;
}
I know the code is a mess :P Basically :
Open the first file, and open the receiving output file. Until you reach the end of that file, keep transferring data. When you reach EOF, close the input file, open a new one (temp, filename and ending are strings (string.h)). If you can't open it, give me the name of the file you can't open. If you CAN open it, just increase the counter telling you what part you're on and keep transferring data. Global WHILE - while your counter doesn't exceed the total number of parts, keep opening part files.
The trouble comes in that ifstream error statement - if you can't open the file, write out the name of that file. It gives me the name of the file, showing that fin.open() failed, but the filename is correct and the file exists in the right directory.
Any ideas ?
Thanks very much,
Quent