CompuServe Thread

#ParentDIR from CLI

6 messages in this thread
#46584From: Kelly JordanJan 1, 1987 12:17 PM
Mike, have you looked at the program called LD or LD4? This is a program for for getting a directory. This program works without being given a directory to start with. In this case, for the Lock() command, it uses a name that is a null string. Here is a fragment of that program. Hope this is what you are looking for. main(argc,argv) int argc; char *argv[]; { char *dirname; /* Selected AmigaDOS directory */ struct FileLock *dir; /* Locked AmigaDOS directory */ struct FileInfoBlock *fb; /* File Info from locked directory */ BOOL fail; /* Directory Access Failure */ UBYTE count; /* Line length count */ if (argc == 1) dirname = ""; else if (argc == 2) dirname = argv[1]; else { printf("Usage: Ld [dirname]\n"); Exit(); } fb = (struct FileInfoBlock *) AllocMem(sizeof(struct FileInfoBlock),0); dir = Lock(dirname,ACCESS_READ); fail = (dir == NULL) | !Examine(dir,fb); if (fail) { printf("Invalid directory '%s' requested\n",dirname); FreeMem(fb,sizeof(struct FileInfoBlock)); Exit(); } Happy new year, Kelly
#46640From: Mike BerroJan 1, 1987 4:36 PM
Thanx, Kelly. I'm not certain what send a null string to Lock() gives you back. I did "bro /key dir*" in DL10 on DL'ed a few listings, including LD.C. Thanx again, and HNY. —Mike
#46669From: Kelly JordanJan 1, 1987 8:15 PM
Hi Mike, What calling Lock with a null string gives is the FileInfoBlock pointer (or a pointer to the block is what I mean), and this block will give the info for the current directory. The name will be that of the current VOLUME if the CD is to a drive and not a subdirectory. If CD is too a SubDirectory, then the Name will be the proper name for the SubDirectory, but of course the parent diectory to that subdirectory is not in the name field. I couldn't remember what it was exactly you were looking for and that program came to mind. If that is what you needed, thank Hazy, it is his program! I didn't notice that until after I sent that to you, or I would have given him the credit in my message. So maybe you could tell me how one goes backwards to find the parent directory, though this would be just for curiousity, since I AINT no programmer.. All the best, Kelly
#46690From: Mike BerroJan 1, 1987 10:52 PM
Kelly: there is a DOS function called ParentDir() that gets the FileInfoBlock for (what else?) the parent directory. What I haven;t determined is if the file is in a drawer which is in a drawer (etc.), how does one get the intermediate pathnames. Thanx! —Mike
#46720From: Larry Phillips/ICUGJan 2, 1987 12:50 AM
Mike, Glad to hear you got the info you needed on obtaining a CurrentDir lock. As for ParentDir, a "drawer in a drawer" situation should be that the parent of Volume:dir/subdir is Volume:dir, and the parent of Volume:dir is of course Volume: If it doesn't work like this, I would call it a bug. Regards, Larry.
#46759From: Mike BerroJan 2, 1987 2:04 AM
You are right (rereading the function description). ParentDir does give the immediate parent, not the grandparent. You keep calling it until it returns a zero, which means it found the root directory. —Mike