daemon@rutgers.UUCP (03/01/87)
From: Steve Walton <ametek!walton@csvax.caltech.edu> VT100 Version 2.6 does not handle CurrentDir correctly. The code in vt100.c and expand.c has fixes which were posted to the net some time back, but they made the program work under Workbench but fail under CLI. After looking at the new code, I had an inspiration. In general, Workbench and CLI are sufficiently different that for any substantial program, you must have at least some code which depends on which one you're running under. In the case of programs which do a CurrentDir call, I have a quite general fix: if you were started from Workbench, do: CurrentDir(DupLock(((struct Process *) FindTask(0L))->pr_CurrentDir)); as part of your initialization. From then on, you are free to change your current directory just as you would from a CLI-started program by doing UnLock(CurrentDir(new_dir_lock)). The specific changes to VT100 version 2.6 follow. Lines marked *DEL* in the margin are to be deleted and lines marked *INS* are to be inserted. (Incidentally, this is a partial output of a Modula-2 diff program which can also generate a script for the AmigaDOS line-oriented editor "edit" to change an old file into a new one.) vt100.c ------- char MyDir[60]; *DEL* struct FileLock *MyDirLock = NULL; *DEL* struct FileLock *StartLock = NULL; main()... MyDir[0] = '\000'; *DEL* StartLock = (struct FileLock *)((ULONG)((struct Process *) *DEL* (FindTask(NULL)))->pr_CurrentDir); *DEL* MyDirLock = (struct FileLock *)DupLock(StartLock); *INS* /* If we started from the Workbench, we need to set our CurrentDir *INS* * to a DupLock on our startup current directory. This is so that *INS* * future changes of directory by a simple UnLock(CurrentDir(Lock)) *INS* * will work. Otherwise, we'd UnLock our startup directory, and so *INS* * would Workbench, and we'd hear about it from the Guru. */ *INS* if (argc == 0) { *INS* BPTR StartLock; *INS* StartLock = ((struct Process *) FindTask(NULL))->pr_CurrentDir; *INS* CurrentDir(DupLock(StartLock)); *INS* } /* Now we can do UnLock(CurrentDir(newdir)) */ cleanup().... CloseDevice(&Audio_Request); *DEL* if (MyDirLock != NULL) UnLock(MyDirLock); expand.c -------- if (fib->fib_DirEntryType > 0) { *DEL* CurrentDir(lock); *DEL* if (MyDirLock != NULL) UnLock(MyDirLock); *DEL* MyDirLock = lock; *INS* UnLock(CurrentDir(lock)); if (MyDir[strlen(MyDir)-1] == '/') And there you are. Steve Walton ametek!walton@csvax.caltech.edu walton@caltech.bitnet ...!seismo!cit-vax!ametek!walton