1: /* 2: * Test to see if a filename is a directory. Subdir() has to be called 3: * on the directory above this one first... Returns 1 if true. 4: */ 5: 6: #include <stdio.h> 7: #include "msdos.h" 8: 9: extern int dir_entries; 10: 11: int 12: is_dir(path) 13: char *path; 14: { 15: register int entry; 16: char *newname, *unix_name(); 17: struct directory *dir, *dir_read(); 18: /* no path */ 19: if (*path == '\0') 20: return(0); 21: 22: for (entry = 0; entry < dir_entries; entry++) { 23: dir = dir_read(entry); 24: /* if empty */ 25: if (dir->name[0] == 0x0) 26: break; 27: /* if erased */ 28: if (dir->name[0] == 0xe5) 29: continue; 30: /* skip if not a directory */ 31: if (!(dir->attr & 0x10)) 32: continue; 33: 34: newname = unix_name(dir->name, dir->ext); 35: if (match(newname, path)) 36: return(1); 37: } 38: 39: /* 40: * If the file is "." or ".." but it fails to match, then you 41: * must be at root 42: */ 43: if (!strcmp(path, ".") || !strcmp(path, "..")) 44: return(1); 45: 46: return(0); 47: }