1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
getDir();
ifstream fin;
_finddata_t a_file;
intptr_t dir_handle;
dir_handle = _findfirst("*.*", &a_file);
//if (dir_handle == -1)
//{
//return;
//}
while (_findnext(dir_handle, &a_file) == 0);
{
fin.open(a_file.name, ios::in | ios::binary);
if (!fin)
{
cout << endl << "Could not open the file."
<< " Attempting to open the next file." << endl;
return false;
}
else
{
cout << "Files opened successfully."
<< " Processing through the directory." << endl;
ifstream fl(a_file.name);
fl.seekg(0, ios::end);
size_t len = fl.tellg();
char *ret = new char[len];
fl.seekg(0, ios::beg);
fl.read(ret, len);
fl.close();
char arr1[6] = { 'G', 'I', 'F', 8, 7, 'a' };
char arr2[6] = { 'G', 'I', 'F', 8, 9, 'a' };
if (ret == arr1 || arr2 )
{
cout << a_file.name << " has a .gif extension" << endl;
return true;
}
}
}
|