--- np2/generic/hostdrvs.c 2004/01/12 08:01:00 1.5 +++ np2/generic/hostdrvs.c 2005/03/18 09:23:10 1.15 @@ -1,6 +1,9 @@ #include "compiler.h" -#if defined(OSLANG_EUC) -#include "codecnv.h" + +#if defined(SUPPORT_HOSTDRV) + +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) +#include "oemtext.h" #endif #include "dosio.h" #include "pccore.h" @@ -8,9 +11,9 @@ #include "hostdrvs.h" -static const HDRVDIR hddroot = {" ", 0, 0, 0x10, {0}, {0}}; +static const HDRVDIR hddroot = {" ", 0, 0, 0, 0x10, {0}, {0}}; -static const BYTE dospathchr[] = { +static const UINT8 dospathchr[] = { 0xfa, 0x23, // '&%$#"! /.-,+*)( 0xff, 0x03, // 76543210 ?>=<;:98 0xff, 0xff, // GFEDCBA@ ONMLKJIH @@ -18,19 +21,19 @@ static const BYTE dospathchr[] = { 0x01, 0x00, // gfedcba` onmlkjih 0x00, 0x40}; // wvutsrqp ~}|{zyx -static void rcnvfcb(char *dst, UINT dlen, char *src, UINT slen) { + +static void rcnvfcb(char *dst, UINT dlen, const char *src) { REG8 c; - while((slen) && (dlen)) { - slen--; + while(dlen) { c = (UINT8)*src++; if (c == 0) { break; } -#if defined(OSLANG_SJIS) || defined(OSLANG_EUC) +#if defined(OSLANG_SJIS) || defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { - if ((!slen) || (src[0] == '\0')) { + if (src[0] == '\0') { break; } if (dlen < 2) { @@ -72,23 +75,31 @@ static void rcnvfcb(char *dst, UINT dlen } } -static BOOL realname2fcb(char *fcbname, FLINFO *fli) { +static BRESULT realname2fcb(char *fcbname, FLINFO *fli) { - char *realname; - char *ext; + OEMCHAR *ext; +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) + char sjis[MAX_PATH]; +#endif -#if defined(OSLANG_EUC) - char sjis[MAX_PATH]; + FillMemory(fcbname, 11, ' '); - codecnv_euc2sjis(sjis, sizeof(sjis), fli->path, sizeof(fli->path)); - realname = sjis; + ext = file_getext(fli->path); +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) + oemtext_oemtosjis(sjis, sizeof(sjis), ext, (UINT)-1); + rcnvfcb(fcbname+8, 3, sjis); #else - realname = fli->path; + rcnvfcb(fcbname+8, 3, ext); #endif - FillMemory(fcbname, 11, ' '); - ext = file_getext(realname); - rcnvfcb(fcbname+0, 8, realname, ext - realname); - rcnvfcb(fcbname+8, 3, ext, (UINT)-1); + + file_cutext(fli->path); +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) + oemtext_oemtosjis(sjis, sizeof(sjis), fli->path, (UINT)-1); + rcnvfcb(fcbname+0, 8, sjis); +#else + rcnvfcb(fcbname+0, 8, fli->path); +#endif + return(SUCCESS); } @@ -109,7 +120,7 @@ static BOOL hddseadir(void *vpItem, void return(FALSE); } -LISTARRAY hostdrvs_getpathlist(const char *realpath) { +LISTARRAY hostdrvs_getpathlist(const OEMCHAR *realpath) { FLISTH flh; FLINFO fli; @@ -134,13 +145,14 @@ LISTARRAY hostdrvs_getpathlist(const cha break; } CopyMemory(hdd->di.fcbname, fcbname, 11); + hdd->di.exist = 1; 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)); + file_cpyname(hdd->realname, fli.path, NELEMENTS(hdd->realname)); +// TRACEOUT(("%s -> %11s", fli.path, fcbname)); } } while(file_listnext(flh, &fli) == SUCCESS); if (listarray_getitems(ret) == 0) { @@ -205,20 +217,20 @@ static char *dospath2fcb(char *fcbname, BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; LISTARRAY lst; const HDRVDIR *di; HDRVLST hdl; char fcbname[11]; - file_cpyname(path, np2cfg.hdrvroot, sizeof(path)); + file_cpyname(path, np2cfg.hdrvroot, NELEMENTS(path)); lst = NULL; di = &hddroot; while(dospath[0] != '\0') { if ((dospath[0] != '\\') || (!(di->attr & 0x10))) { goto hdsgrp_err; } - file_setseparator(path, sizeof(path)); + file_setseparator(path, NELEMENTS(path)); dospath++; if (dospath[0] == '\0') { di = &hddroot; @@ -231,12 +243,12 @@ const HDRVDIR *di; if (hdl == NULL) { goto hdsgrp_err; } - file_catname(path, hdl->realname, sizeof(path)); + file_catname(path, hdl->realname, NELEMENTS(path)); di = &hdl->di; } if (hdp) { CopyMemory(&hdp->di, di, sizeof(HDRVDIR)); - file_cpyname(hdp->path, path, sizeof(hdp->path)); + file_cpyname(hdp->path, path, NELEMENTS(hdp->path)); } listarray_destroy(lst); return(SUCCESS); @@ -246,7 +258,7 @@ hdsgrp_err: return(FAILURE); } -BOOL hostdrvs_getrealdir(char *path, int size, char *fcb, char *dospath) { +BOOL hostdrvs_getrealdir(OEMCHAR *path, int size, char *fcb, char *dospath) { LISTARRAY lst; HDRVLST hdl; @@ -287,25 +299,29 @@ hdsgrd_err: BOOL hostdrvs_newrealpath(HDRVPATH *hdp, char *dospath) { - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; char fcb[11]; LISTARRAY lst; HDRVLST hdl; char dosname[16]; UINT i; char *p; +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) + OEMCHAR oemname[64]; +#endif - if ((hostdrvs_getrealdir(path, sizeof(path), fcb, dospath) != SUCCESS) || + if ((hostdrvs_getrealdir(path, NELEMENTS(path), fcb, dospath) + != SUCCESS) || (fcb[0] == ' ')) { return(FAILURE); } lst = hostdrvs_getpathlist(path); hdl = (HDRVLST)listarray_enum(lst, hddsea, fcb); if (hdl != NULL) { - file_catname(path, hdl->realname, sizeof(path)); + file_catname(path, hdl->realname, NELEMENTS(path)); if (hdp) { CopyMemory(&hdp->di, &hdl->di, sizeof(HDRVDIR)); - file_cpyname(hdp->path, path, sizeof(hdp->path)); + file_cpyname(hdp->path, path, NELEMENTS(hdp->path)); } } else { @@ -320,11 +336,17 @@ BOOL hostdrvs_newrealpath(HDRVPATH *hdp, } } *p = '\0'; - file_catname(path, dosname, sizeof(path)); + // ここで SJIS->OEMコードに未変換! +#if defined(OSLANG_EUC) || defined(OSLANG_UTF8) || defined(OSLANG_UCS2) + oemtext_sjistooem(oemname, NELEMENTS(oemname), dosname, (UINT)-1); + file_catname(path, oemname, NELEMENTS(path)); +#else + file_catname(path, dosname, NELEMENTS(path)); +#endif if (hdp) { ZeroMemory(&hdp->di, sizeof(hdp->di)); CopyMemory(hdp->di.fcbname, fcb, 11); - file_cpyname(hdp->path, path, sizeof(hdp->path)); + file_cpyname(hdp->path, path, NELEMENTS(hdp->path)); } } listarray_destroy(lst); @@ -334,11 +356,6 @@ BOOL hostdrvs_newrealpath(HDRVPATH *hdp, // ---- -void hostdrvs_fhdlreopen(LISTARRAY fhdl) { - - (void)fhdl; -} - static BOOL fhdlallclose(void *vpItem, void *vpArg) { long fh; @@ -383,3 +400,5 @@ HDRVFILE hostdrvs_fhdlsea(LISTARRAY fhdl return(ret); } +#endif +