mbeck@ai.mit.edu (Mark Becker) (12/05/90)
Hello * Consider the following situation: I have a piece of software that, as part of it's normal function, takes a directory reference from a configuration file and uses that reference as the top of a directory tree used to contain a bunch of data files. This directory is created during execution and wiped out afterwards. In order to prevent possible configuration errors and major grief, I want do a little sanity checking on the reference that the installer sets up. Turning this thing loose on someone's root directory could lead to a disaster. SUBST is one source of major pain. Novell netware is another, given that it can 'map' drive designators to all kinds of strange places over a network. Is it possible to determine if a given file or directory is in the root directory of a disk drive even though it may be SUBST'ed or Novelled? Suggestions and/or pointers to relevent information would be appreciated. Regards, Mark mbeck@ai.mit.edu -or- mbmm!mbeck@talcott.harvard.edu
kdq@demott.com (Kevin D. Quitt) (12/05/90)
>From: ralf@b.gp.cs.cmu.edu (Ralf Brown) Newsgroups: comp.os.msdos.programmer Date: 15 Sep 90 02:47:26 GMT Organization: Carnegie-Mellon University, CS/RI In article <2091@nyx.UUCP> cla@nyx.UUCP () writes: }How does one determine that two files are indeed the same physical file? Under DOS 3.0 and up, the easiest way is to apply the following undocumented function to both names and then do a string compare. INT 21 - DOS 3+ internal - RESOLVE PATH STRING TO CANONICAL PATH STRING AH = 60h DS:SI -> ASCIZ relative path string or directory name ES:DI -> 128-byte buffer for ASCIZ canonical fully qualified name Return: CF set on error AX = error code 02h invalid source name 03h invalid drive or malformed path others??? CF clear if successful AH = 00h AL = destroyed (00h or 5Ch or last char of current dir on drive) buffer filled with qualified name of form D:\PATH\FILE.EXT or \\MACHINE\PATH\FILE.EXT Notes: the input path need not actually exist letters are uppercased, forward slashes converted to backslashes, asterisks converted to appropriate number of question marks, and file and directory names are truncated to 8.3 if necessary. '.' and '..' in the path are resolved filespecs on local drives always start with "d:", those on network drives always start with "\\" if path string is on a JOINed drive, the returned name is the one that would be needed if the drive were not JOINed; similarly for a SUBSTed, ASSIGNed, or network drive letter. Because of this, it is possible to get a qualified name that is not legal under the current combination of SUBSTs, ASSIGNs, JOINs, and network redirections functions which take pathnames require canonical paths if invoked via INT 21/AX=5D00h supported by OS/2 v1.1 compatibility box SeeAlso: INT 2F/AX=1123h,1221h -- _ Kevin D. Quitt demott!kdq kdq@demott.com DeMott Electronics Co. 14707 Keswick St. Van Nuys, CA 91405-1266 VOICE (818) 988-4975 FAX (818) 997-1190 MODEM (818) 997-4496 PEP last
fisher@sc2a.unige.ch (12/05/90)
In article <12201@life.ai.mit.edu>, mbeck@ai.mit.edu (Mark Becker) writes: > [ needs a temporary directory, name taken from a configuration file > and wants to determine whether this particular path is JOIN'ed, SUBST'ed > or on a Novell network drive, i.e.: ] > > In order to prevent possible configuration errors and major grief, I > want do a little sanity checking on the reference that the installer > sets up. Turning this thing loose on someone's root directory could > lead to a disaster. My first advice would be to check the content of the directory, of course. If the directory exists and isn't empty, the exit with an error. (BTW: I would recommend checking for a TMP variable (which sometimes points to a RAM-drive, or the like) and use, say, <TMP><progname> as the root of your tmp directory...) Still, it's possible to obtain the "physical" directory through a DOS function call. As it's not too long, consider the following quick hack (from the program "write" in queue for posting in c.b.i.p). Original idea adapted from some posting on the net, two years ago: From: pfales@ttrde.UUCP (Peter Fales) Newsgroups: comp.sys.ibm.pc Subject: Finding free space on a joined drive Date: 9 Jan 89 15:19:32 GMT Organization: AT&T, Skokie, IL TurboC 1.5 source file: #include <stdio.h> #include <string.h> #include <dos.h> #include <dir.h> char path[MAXPATH], true_path[MAXPATH]; void getpath(void) /* * Stores the current path into `path' and the true path into `true_path'. * The true path is obtaind by the dos function call 0x60. * DS:SI is input path; ES:DI is output path. */ { union REGS r; struct SREGS s; getcwd (path, MAXPATH); r.x.ax = 0x6000; /* assuming near pointers: */ r.x.si = (unsigned)path; r.x.di = (unsigned)true_path; segread(&s); s.es = s.ds; intdosx(&r,&r,&s); } void main () { char *diagnosis = NULL; getpath(); printf("path: %s", path); if (*true_path == '\\') diagnosis = "network path"; else if (*path != *true_path) if (strlen(true_path) > strlen(path)) diagnosis = "substitutes for"; else diagnosis = "is joined from"; if (diagnosis) printf("; %s: %s", diagnosis, true_path); printf("\n"); }
fmgst@unix.cis.pitt.edu (Filip Gieszczykiewicz) (12/06/90)
Greetings. How about just creating a file that's made up of high ASCII characters? I use that in my database and have had no problems with anything---- yet.... ;-) By the way, that would be ASCII 128 and above. My favorite is 196, it looks like a dash, but it ain't :-) Take care. -- _______________________________________________________________________________ "The Force will be with you, always." It _is_ with me and has been for 10 years Filip Gieszczykiewicz "... a Jedi does it with a mind trick... " ;-) FMGST@PITTVMS or fmgst@unix.cis.pitt.edu "My ideas. ALL MINE!!"