I am trying to back up windows file attributes using a nested structure to save the path and file name along with the windows attributes structure. I have simplifed the code to the snippet below. Compile (gcc) gives
error: field `attr_struct' has incomplete type.
Assistnace will be very much appreciated.
Leon
Code:
#include <stdio.h>
#include <windows.h>
FILE *out;
int get_attrs(char *dir)
{
int result;
char char_buffer[500];
char char_dir[500];
char shortpath[500];
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
struct file_attrs {
char filename[500];
struct WIN32_FIND_DATA attr_struct;
} file_data;
strcpy(char_buffer,dir);
strcat(char_buffer,"\\*.*");
hFind = FindFirstFile(char_buffer, &FindFileData);
do
{
if (!strcmp(FindFileData.cFileName, "."))
continue;
if (!strcmp(FindFileData.cFileName, ".."))
continue;
strcpy(file_data.filename, char_buffer);
file_data.attr_struct = FindFileData;
fwrite(&file_data, sizeof(file_data),1, out);
} while (FindNextFile(hFind, &FindFileData));
FindClose(hFind);
}
int main(void)
{
out = fopen("attrs.dat", "w");
if ( out == NULL)
{
printf("could not open attrs.dat");
exit(1);
}
get_attrs("d:\\c_projects");
fclose(out);
exit(0);
}