--- np2/generic/hostdrvs.c 2004/01/09 04:36:02 1.1 +++ np2/generic/hostdrvs.c 2004/01/10 17:36:07 1.4 @@ -1,11 +1,14 @@ #include "compiler.h" +#if defined(OSLANG_EUC) +#include "codecnv.h" +#endif #include "dosio.h" #include "pccore.h" #include "hostdrv.h" #include "hostdrvs.h" -static const HDRVDIR hddroot = {" ", 0, 0x10}; +static const HDRVDIR hddroot = {" ", 0, 0, 0x10, {0}, {0}}; static const BYTE dospathchr[] = { 0xfa, 0x23, // '&%$#"! /.-,+*)( @@ -25,6 +28,7 @@ static void rcnvfcb(char *dst, UINT dlen if (c == 0) { break; } +#if defined(OSLANG_SJIS) || defined(OSLANG_EUC) if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { if ((!slen) || (src[0] == '\0')) { break; @@ -37,16 +41,34 @@ static void rcnvfcb(char *dst, UINT dlen dst += 2; dlen -= 2; } - else { + else if (((c - 0x20) & 0xff) < 0x60) { + if (((c - 'a') & 0xff) < 26) { + c -= 0x20; + } + if (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7))) { + *dst++ = c; + dlen--; + } + } + else if (((c - 0xa0) & 0xff) < 0x40) { + *dst++ = c; + dlen--; + } +#else + if (((c - 0x20) & 0xff) < 0x60) { if (((c - 'a') & 0xff) < 26) { c -= 0x20; } - if ((c >= 0x20) && (c < 0x80) && - (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7)))) { + if (dospathchr[(c >> 3) - (0x20 >> 3)] & (1 << (c & 7))) { *dst++ = c; dlen--; } } + else if (c >= 0x80) { + *dst++ = c; + dlen--; + } +#endif } } @@ -55,7 +77,14 @@ static BOOL realname2fcb(char *fcbname, char *realname; char *ext; +#if defined(OSLANG_EUC) + char sjis[MAX_PATH]; + + codecnv_euc2sjis(sjis, sizeof(sjis), fli->path, sizeof(fli->path)); + realname = sjis; +#else realname = fli->path; +#endif FillMemory(fcbname, 11, ' '); ext = file_getext(realname); rcnvfcb(fcbname+0, 8, realname, ext - realname); @@ -96,9 +125,13 @@ LISTARRAY hostdrvs_getpathlist(const cha break; } CopyMemory(hdd->di.fcbname, fcbname, 11); + hdd->di.caps = fli.caps; hdd->di.size = fli.size; hdd->di.attr = fli.attr; + hdd->di.date = fli.date; + hdd->di.time = fli.time; milstr_ncpy(hdd->realname, fli.path, sizeof(hdd->realname)); + TRACEOUT(("%s -> %11s", fli.path, fcbname)); } } while(file_listnext(flh, &fli) == SUCCESS); if (listarray_getitems(ret) == 0) { @@ -163,14 +196,12 @@ static char *dospath2fcb(char *fcbname, BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) { - BOOL ret; char path[MAX_PATH]; LISTARRAY lst; const HDRVDIR *di; HDRVLST hdl; char fcbname[11]; - ret = SUCCESS; file_cpyname(path, np2cfg.hdrvroot, sizeof(path)); lst = NULL; di = &hddroot; @@ -194,7 +225,7 @@ const HDRVDIR *di; file_catname(path, hdl->realname, sizeof(path)); di = &hdl->di; } - if (hdl) { + if (hdp) { CopyMemory(&hdp->di, di, sizeof(HDRVDIR)); file_cpyname(hdp->path, path, sizeof(hdp->path)); } @@ -206,6 +237,80 @@ hdsgrp_err: return(FAILURE); } +BOOL hostdrvs_newrealpath(HDRVPATH *hdp, char *dospath) { + + char path[MAX_PATH]; + LISTARRAY lst; + HDRVLST hdl; + char fcbname[11]; + char dosname[16]; + UINT i; + char *p; + + file_cpyname(path, np2cfg.hdrvroot, sizeof(path)); + lst = NULL; + if (dospath[0] != '\\') { + goto hdsgrp_err; + } + while(1) { + file_setseparator(path, sizeof(path)); + dospath++; + if (dospath[0] == '\0') { + goto hdsgrp_err; + } + dospath = dospath2fcb(fcbname, dospath); + if (dospath[0] != '\\') { + break; + } + listarray_destroy(lst); + lst = hostdrvs_getpathlist(path); + hdl = (HDRVLST)listarray_enum(lst, hddsea, fcbname); + if ((hdl == NULL) || (!(hdl->di.attr & 0x10))) { + goto hdsgrp_err; + } + file_catname(path, hdl->realname, sizeof(path)); + } + if (dospath[0] != '\0') { + goto hdsgrp_err; + } + listarray_destroy(lst); + lst = hostdrvs_getpathlist(path); + hdl = (HDRVLST)listarray_enum(lst, hddsea, fcbname); + if (hdl != NULL) { + file_catname(path, hdl->realname, sizeof(path)); + if (hdp) { + CopyMemory(&hdp->di, &hdl->di, sizeof(HDRVDIR)); + file_cpyname(hdp->path, path, sizeof(hdp->path)); + } + } + else { + p = dosname; + for (i=0; (i<8) && (fcbname[i] != ' '); i++) { + *p++ = fcbname[i]; + } + if (fcbname[8] != ' ') { + *p++ = '.'; + for (i=8; (i<11) && (fcbname[i] != ' '); i++) { + *p++ = fcbname[i]; + } + } + *p = '\0'; + file_catname(path, dosname, sizeof(path)); + if (hdp) { + CopyMemory(hdp->di.fcbname, fcbname, 11); + hdp->di.size = 0; + hdp->di.attr = 0; + file_cpyname(hdp->path, path, sizeof(hdp->path)); + } + } + listarray_destroy(lst); + return(SUCCESS); + +hdsgrp_err: + listarray_destroy(lst); + return(FAILURE); +} + // ----