|
|
| version 1.1, 2003/10/28 16:44:44 | version 1.2, 2003/11/03 10:19:43 |
|---|---|
| Line 2 | Line 2 |
| #include "dosio.h" | #include "dosio.h" |
| #include "fdefine.h" | #include "fdefine.h" |
| #include "strres.h" | |
| void Setfiletype(int ftype, OSType *creator, OSType *fileType) { | void Setfiletype(int ftype, OSType *creator, OSType *fileType) { |
| Line 79 static int Getfiletype(FInfo *fndrinfo) | Line 80 static int Getfiletype(FInfo *fndrinfo) |
| return(FTYPE_NONE); | return(FTYPE_NONE); |
| } | } |
| static int GetFileExt(char* filename) { | |
| char* p; | |
| int ftype; | |
| p = file_getext((char *)filename); | |
| if ((!milstr_cmp(p, str_d88)) || (!milstr_cmp(p, str_d98))) { | |
| ftype = FTYPE_D88; | |
| } | |
| else if ((!milstr_cmp(p, str_ini))) { | |
| ftype = FTYPE_TEXT; | |
| } | |
| else if ((!milstr_cmp(p, str_bmp))) { | |
| ftype = FTYPE_BMP; | |
| } | |
| else if ((!milstr_cmp(p, str_thd))) { | |
| ftype = FTYPE_THD; | |
| } | |
| else if ((!milstr_cmp(p, str_hdi))) { | |
| ftype = FTYPE_HDI; | |
| } | |
| else { | |
| ftype = FTYPE_BETA; | |
| } | |
| return(ftype); | |
| } | |
| int file_getftype(char* filename) { | int file_getftype(char* filename) { |
| FSSpec fss; | FSSpec fss; |
| Str255 fname; | Str255 fname; |
| FInfo fndrInfo; | FInfo fndrInfo; |
| int ftype; | |
| mkstr255(fname, filename); | mkstr255(fname, filename); |
| FSMakeFSSpec(0, 0, fname, &fss); | FSMakeFSSpec(0, 0, fname, &fss); |
| if (FSpGetFInfo(&fss, &fndrInfo) != noErr) { | if (FSpGetFInfo(&fss, &fndrInfo) != noErr) { |
| return(FTYPE_NONE); | return(FTYPE_NONE); |
| } | } |
| return(Getfiletype(&fndrInfo)); | ftype = Getfiletype(&fndrInfo); |
| if (ftype == FTYPE_NONE) { | |
| ftype = GetFileExt(filename); | |
| } | |
| return(ftype); | |
| } | } |