Hi There ,
I used the following code which I found on the net to copy files. I tried on a dbf file and it copies the file but it puts the first byte of the next record into the last field of the previous record. A dbf record begins with a delete byte that is either Ox20 for not deleted and 0x2A for deleted.
I tested the code with a deleted record and the * appeared in the last field of the previous record and the first field of the deleted record. All the field in each record begin with a space which I take to be the delete byte.
The file size after copying is exactly the same size as the orginal.
I don't understand how to fix this.
Here is the code I used:
#include <fstream>
#include <iostream>
int main(int argc, char **argv) {
if (argc < 3) {
std::cerr << "usage: " << argv[0] << " [source] [destination]" << std::endl;
return 1;
}
std::ifstream fin(argv[1]);
std:
fstream fout(argv[2], std::ios_base:
ut | std::ios_base::trunc);
if (fin.is_open() && fout.is_open())
fout << fin.rdbuf();// here's the line
fin.close();
fout.close();
return 0;
}
I tried various other copying file code and they all did the same thing.
Surely there is a way .
Any ideas appreciated.
Thanks
Hugh
I used the following code which I found on the net to copy files. I tried on a dbf file and it copies the file but it puts the first byte of the next record into the last field of the previous record. A dbf record begins with a delete byte that is either Ox20 for not deleted and 0x2A for deleted.
I tested the code with a deleted record and the * appeared in the last field of the previous record and the first field of the deleted record. All the field in each record begin with a space which I take to be the delete byte.
The file size after copying is exactly the same size as the orginal.
I don't understand how to fix this.
Here is the code I used:
#include <fstream>
#include <iostream>
int main(int argc, char **argv) {
if (argc < 3) {
std::cerr << "usage: " << argv[0] << " [source] [destination]" << std::endl;
return 1;
}
std::ifstream fin(argv[1]);
std:
if (fin.is_open() && fout.is_open())
fout << fin.rdbuf();// here's the line
fin.close();
fout.close();
return 0;
}
I tried various other copying file code and they all did the same thing.
Surely there is a way .
Any ideas appreciated.
Thanks
Hugh