CompuServe Messages

Path string from lock?

    29-Jul-91 00:23:22
Fm: Bob Rakosky 75156,336
To: Syndesis 76004,1763
John, I believe there's an AmigaDOS function to do it in 2.0, but I assume you're trying to maintain pre-2.0 compatibility. The following function works reliably for me: —————————– CHAR pbuf[MAX_PATH]; CHAR * lock_to_pathstr(BPTR lok) { char buf0[MAX_PATH]; BPTR plok; int i; struct FileInfoBlock *fib; pbuf[0] = '\0'; fib = (struct FileInfoBlock *) AllocMem(sizeof(struct FileInfoBlock),MEMF_CLEAR); if (!fib) { return(pbuf); } buf0[0] = '\0'; plok = lok; while (plok) /* Parent lock==0 ==> last lock was volume node */ { if (!Examine(plok,fib)) { goto outtahere; } plok = ParentDir(plok); if (!plok) { strcpy(buf0,fib->fib_FileName); strcat(buf0,":"); strcat(buf0,pbuf); strcpy(pbuf,buf0); break; /* exit loop here and only here */ } strcpy(buf0,fib->fib_FileName); strcat(buf0,"/"); strcat(buf0,pbuf); strcpy(pbuf,buf0); } i = strlen(pbuf) – 1; if (pbuf[i] == '/') { pbuf[i] = '\0'; } outtahere: if (fib) { FreeMem((char *)fib,(long)sizeof(struct FileInfoBlock)); } return(pbuf); } —————————- Hope this helps…. ….BobR