From 95653072d3ba685088a33a49ba892ad576b85a5f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 5 Jul 2009 21:09:34 +0000 Subject: [PATCH] The original DosGetCuDir is now inlined in truename(). DosGetCuDir now does truename("D:", CDS_MODE_SKIP_PHYSICAL), and this mode was changed to no longer call QRemote_Fn (int2f/ax=1123). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@1472 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 39 ++++++++++----------------------------- kernel/newstuff.c | 29 +++++++++++++++++++++++++---- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 6a6509f..d281af4 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -887,38 +887,19 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { - BYTE *cp; - struct cds FAR *cdsp; + char path[3]; - /* next - "log" in the drive */ - /* first check for valid drive */ - cdsp = get_cds1(drive); - if (cdsp == NULL) + if (drive-- == 0) /* get default drive or convert to 0 = A:, 1 = B:, ... */ + drive = default_drive; + path[0] = 'A' + (drive & 0x1f); + path[1] = ':'; + path[2] = '\0'; + + if (truename(path, PriPathName, CDS_MODE_SKIP_PHYSICAL) < SUCCESS) return DE_INVLDDRV; - fmemcpy(&TempCDS, cdsp, sizeof(TempCDS)); - cp = TempCDS.cdsCurrentPath; - /* ensure termination of fstrcpy */ - cp[MAX_CDSPATH - 1] = '\0'; - - if ((TempCDS.cdsFlags & CDSNETWDRV) == 0) - { - /* dos_cd ensures that the path exists; if not, we - need to change to the root directory */ - int result = dos_cd(cp); - if (result == DE_PATHNOTFND) - cp[TempCDS.cdsBackslashOffset + 1] = - cdsp->cdsCurrentPath[TempCDS.cdsBackslashOffset + 1] = '\0'; - else if (result < SUCCESS) - return result; - } - - cp += TempCDS.cdsBackslashOffset; - if (*cp == '\0') - s[0] = '\0'; - else - fstrcpy(s, cp + 1); - + /* skip d:\ */ + fstrcpy(s, PriPathName + 3); return SUCCESS; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f68cbcc..731b96d 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -368,7 +368,8 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) dest[0] = '\0'; /* better probable for sanity check below -- included by original truename() */ /* MUX succeeded and really something */ - if (QRemote_Fn(dest, src) == SUCCESS && dest[0] != '\0') + if (!(mode & CDS_MODE_SKIP_PHYSICAL) && + QRemote_Fn(dest, src) == SUCCESS && dest[0] != '\0') { tn_printf(("QRemoteFn() returned: \"%S\"\n", dest)); #ifdef DEBUG_TRUENAME @@ -431,7 +432,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) rootPos = p = dest + 2; if (*p != '/') /* i.e., it's a backslash! */ { - COUNT prevresult = result; + BYTE *cp; if (!(mode & CDS_MODE_SKIP_PHYSICAL)) { tn_printf(("SUBSTing from: %S\n", cdsEntry->cdsCurrentPath)); @@ -459,8 +460,28 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) p++; /* truename must use the CuDir of the "virtual" drive letter! */ /* tn_printf(("DosGetCuDir drive #%u\n", prevresult & 0x1f)); */ - if (DosGetCuDir((UBYTE)((prevresult & 0x1f) + 1), p) < 0) - return DE_PATHNOTFND; + fmemcpy(&TempCDS, cdsEntry, sizeof(TempCDS)); + cp = TempCDS.cdsCurrentPath; + /* ensure termination of strcpy */ + cp[MAX_CDSPATH - 1] = '\0'; + if ((TempCDS.cdsFlags & CDSNETWDRV) == 0) + { + /* dos_cd ensures that the path exists; if not, we + need to change to the root directory */ + int result = dos_cd(cp); + if (result == DE_PATHNOTFND) + cp[TempCDS.cdsBackslashOffset + 1] = + cdsEntry->cdsCurrentPath[TempCDS.cdsBackslashOffset + 1] = '\0'; + else if (result < SUCCESS) + return DE_PATHNOTFND; + } + + cp += TempCDS.cdsBackslashOffset; + if (*cp == '\0') + p[0] = '\0'; + else + strcpy(p, cp + 1); + if (*src != '\\' && *src != '/') p += strlen(p); else /* skip the absolute path marker */