I'm in the middle of writing a simple FAT12 driver. When I open the file i compare the name of the file I'm looking for to the name of the file in the drive as I iterate through the root directory. Easy right? apparently not.
When I make a simple call to strcmp(), nothing comes back. I try to print the return value and it prints nothing as if there is nothing in the variable. It doesn't print garbage data, it literally prints nothing. Here is the relevant piece of code:
Code:
FILE file;
unsigned char *buf;
PDIRECTORY directory;
char dosFileName[11];
to_dos_file_name(directoryName, dosFileName, 11);
dosFileName[11] = 0; // null terminate
for (int sector = 0; sector < 14; sector++) {
// read sector
buf = (unsigned char *)flpy_read_sector(mount_info.rootOffset + sector);
directory = (PDIRECTORY)buf;
// 16 entries per sector
for (int i = 0; i < 16; i++) {
// get current filename
char name[11];
memcpy(name, directory->filename, 11);
name[11] = 0;
// does it match?
if (!strcmp(dosFileName, name)) { // if I print this value, nothing shows up
Also when I have it as above (i think, i've been moving things around a lot) the dosFileName string gets over written or something and also becomes a disappearing value. From debugging I know dosFileName is intact until i memcpy() the directory->filename. Any ideas what is causing this madness? Thanks