Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!feeder.news-service.com!nf14.news-service.com!not-for-mail From: "A.D. Fundum" Message-ID: Newsgroups: comp.os.os2.programmer.tools,comp.os.os2.programmer.misc,comp.os.os2.apps Subject: Re: DosQueryPathInfo with correct case (was: Force gnu assembler to invoke the preprocessor) References: <4dfdcf49$0$7624$9b4e6d93@newsspool1.arcor-online.net> <97c9mpF42tU1@mid.uni-berlin.de> User-Agent: ProNews/2 V1.60.cp125 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@news-service.com Organization: News-Service.com Date: Thu, 21 Jul 2011 22:54:00 +0200 Lines: 139 NNTP-Posting-Host: 84.53.88.202 (84.53.88.202) NNTP-Posting-Date: Thu, 21 Jul 2011 22:54:00 +0200 Xref: x330-a1.tempe.blueboxinc.net comp.os.os2.programmer.tools:19 comp.os.os2.programmer.misc:341 comp.os.os2.apps:399 >>> As an aside: is there an API or function which consistenly returns >>> the case of a directory as-is, with or without the drive letter? >> A combination of DosQueryPathInfo with DosFind* works for me. >> (DosFindNext returns the correct case, so SysFileTree may work >> as well for REXX.) > [D:\Database\Caf‚]dir > Directory of D:\Database > 4-07-11 10:50 0 ---- Caf‚ FTR: this seems to work. It prints the current directory of a drive, recursivly using DosFind* in the final stage to preserve, or rather respect, the original case. Together with e.g. Sergey Yevtushenko's CLIP.CPP this already has some use, possibly while installing software and creating WPS program objects. It's basicly the CMD.EXE-equivalent of a RMB on a WPS folder object to copy the full path of a directory to the eCS clipboard: "PRINTDIR | CLIP". I haven't embedded the clipboard funcionality, so PRINTDIR isn't DIR2CLIP. For one because the .subject-EA of a file downloaded with FF/SM also is a possible candidate to be copied to the clipboard, and I don't really want an *.EXE for each silly idea, with RFC #1 being a version which optionally adds quotes to the full path. Hey, write your own Rexx 2Clip-frontend! ;-) -- /* ICC PRINTDIR.C, Q&D Worked At Least Once For Me Amateur Alert */ #define INCL_DOSFILEMGR #include #include #include #include #include int main(int argc, char* argv[]) { APIRET rc; char *buffer,buffer2[CCHMAXPATH],path[CCHMAXPATH],path2[CCHMAXPATH]; FILEFINDBUF3 filebuf={0}; HDIR hdir=HDIR_SYSTEM; int drive=0,length,position; ULONG filebuflen=sizeof(FILEFINDBUF3),searchlimit=1; if (argc>2) { printf("Usage: PRINTDIR.EXE [drive]\n"); return 1; } if (argc==2) { if (strlen(argv[1])!=2) { printf("Usage: PRINTDIR.EXE [drive]\n"); return 1; } if (argv[1][1]!=':') { printf("Usage: PRINTDIR.EXE [drive]\n"); return 1; } if (argv[1][0]>90) argv[1][0]-=32; if (argv[1][0]<'A') { printf("Usage: PRINTDIR.EXE [drive]\n"); return 1; } if (argv[1][0]>'Z') { printf("Usage: PRINTDIR.EXE [drive]\n"); return 1; } drive=argv[1][0]-64; } if (drive) buffer=_getdcwd(drive,buffer2,CCHMAXPATH); else buffer=_getcwd(buffer2,CCHMAXPATH); if (NULL==buffer) { fprintf(stderr,"SYS0021: The drive is not ready.\n"); return 1; } /* No root directory? DosFindFirst() each involved (sub-)directory */ if (strlen(buffer)>3) { while (strlen(buffer)>3) { rc=DosFindFirst(buffer,&hdir,FILE_DIRECTORY,&filebuf,filebuflen &searchlimit,FIL_STANDARD); if (rc) { fprintf(stderr,"DosFindFirst() error: rc=%u\n",rc); return 1; } length=strlen(buffer); position=length; while (buffer[position]!='\\'&&position>3) --position; buffer[position]='\0'; if (strlen(path)) sprintf(path2,"%s\\%s",filebuf.achName,path); else sprintf(path2,"%s",filebuf.achName); sprintf(path,"%s",path2); rc=DosFindClose(hdir); if (rc) { fprintf(stderr,"DosFindClose() error: rc=%u\n",rc); return 1; } } strcat(buffer,path); } if (strlen(buffer)<3) { fprintf(stderr, "Error: unexpected number of characters (%u) in %s\n", strlen(buffer),buffer); return 1; } printf("%s\n",buffer); return 0; }