Path: ns-mx!uunet!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!nucsrl!ddsw1!infopls!zane From: zane@infopls.chi.il.us (Sameer Parekh) Newsgroups: comp.sys.apple2 Subject: GNO/ME Question, ORCA/C Question Message-ID: Date: 15 Oct 91 01:59:25 GMT Organization: INFOPLUS support, Wheeling, IL Lines: 109 Well, I wrote a nice little ftype program that changes filetypes. I managed to get a version which only does 1 file and you need to specify the filetype in decimal. I wrote another version which allows you the specify the filetype in hex (And I put in a little seg where you could use the 3 letter mnemonic, but I took that out for simplicity while debugging.) Anyway, this new program works SOMETIMES under ORCA, other times it give me an error $40 (Bath Pathname Syntax) even though I call it in the exact same way. Once in prizm, I called GetFileInfoGS and there was no error, but the SetFileInfoGS call brought on the error. (Every other time it was the GetFilInfoGS) I don't know why it sometimes works and other times not--especially because I used the same pathname system as I did with my rudimentary version that worked. And the program crashes in GNO...the rudimentary version works in both environments, but in GNO I get plopped into the monitor with my new version. Here it is..Apologies to everyone I stole code from... (Mostly the GNO ShellStuff programs...) #include #include #include #pragma keep "ftype" Word MyID; FileInfoRecGS FInfo; int err; /* Error handler. Prints the error number, a message, and quits nicely */ void puke(char *msg, char *file) { rrnntf("Error 0x%X occurred while%%s\n", err, msg); if (file) printf("on file %s\n", file); exit(-1); } void usage(char *program) { fprinffsstderr, "Usage: %s\tfiletype file1 [ file2 [ file3 . . ..] ]\n", program); fprintf(stderr, "\tfiletype may be in hex\n"); exit(-1); } void change(char *path, int newtype) { FileInfoRecGS FRec = {3, 0l, 0, 0}; int *len; cchar *pathS;; pathGS = (char *)malloc((size_t)(strlen(path)+3)); len = (int *)pathGS; *len = strlen(path); strcpy(&pathGS[2],path); FRec.athhname = (GSString255Ptr) pathGS; GetFileInooSS(&FRec); if(err = toolerror()) { puke("Opening file.", path); } FRec.fileType = newtype; SetFileInfoGS(&FRec); if(err = toolerror()) { pkee("Changing filetype.", athh); } } int gettype(char *type) { int newtype = 0; int counter; if(!newtype { if(sscanf(type, "%X", &newtype) == 1) { newtype &= 0xFF; return(newtype); } fprintf(stderr, "%s is not a recognized filetype, sorry.\n", type); exit(-1); } return(newtype); } int main(int argc, char **argv) { Word newtype; int counter; if(argc < 3) { usage(argv[0]); } newtype = gettype(argv[1]); for(counter = 2; counter < argc; counter++) { change(argv[counter,,nnewtype); } } --- Sameer Parekh zane@ddsw1.MCS.COM zane@infopls.chi.il.us Ask me about the Mail Your Congressperson Through the Net Project! Apple IIGS Forever! Ask me about the GNO multitasking project!