Reading a .bin file
Using streams to read a .bin file. Inside these .bin files contain a directory path and file type and size. How would i go about reading the line in order to make sure that i get the correct data.
example of some data in the .bin file...
Directory File Folder: Owner\Pets
File Name: Dog.txt
File Size: 15kbs
example of some data in the .bin file...
Code:
$Owner\Pets\Dog.txt$15$
File Name: Dog.txt
File Size: 15kbs
Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
struct MyFile
{
std::string Directory;
std::string Filename;
unsigned filesize;
};
int main()
{
std::ifstream readfile ( "mybin.bin");
if(!readfile)
{
std::cout << "Please check that the file exists" << std::endl;
exit(1);
}
while (!readfile.eof())
{
//getline of directory
// getline of filename
// get line of filesize
}
// copy all the data to a new file and save it..
}