|
|
| version 1.4, 2004/01/10 17:36:07 | version 1.11, 2004/07/15 13:48:39 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #if defined(SUPPORT_HOSTDRV) | |
| #if defined(OSLANG_EUC) | #if defined(OSLANG_EUC) |
| #include "codecnv.h" | #include "codecnv.h" |
| #endif | #endif |
| Line 8 | Line 11 |
| #include "hostdrvs.h" | #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 BYTE dospathchr[] = { |
| 0xfa, 0x23, // '&%$#"! /.-,+*)( | 0xfa, 0x23, // '&%$#"! /.-,+*)( |
| Line 28 static void rcnvfcb(char *dst, UINT dlen | Line 31 static void rcnvfcb(char *dst, UINT dlen |
| if (c == 0) { | if (c == 0) { |
| break; | break; |
| } | } |
| #if defined(OSLANG_SJIS) || defined(OSLANG_EUC) | #if defined(OSLANG_SJIS) || defined(OSLANG_EUC) || defined(OSLANG_UTF8) |
| if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if ((((c ^ 0x20) - 0xa1) & 0xff) < 0x3c) { |
| if ((!slen) || (src[0] == '\0')) { | if ((!slen) || (src[0] == '\0')) { |
| break; | break; |
| Line 74 static void rcnvfcb(char *dst, UINT dlen | Line 77 static void rcnvfcb(char *dst, UINT dlen |
| static BOOL realname2fcb(char *fcbname, FLINFO *fli) { | static BOOL realname2fcb(char *fcbname, FLINFO *fli) { |
| #if defined(OSLANG_EUC) || defined(OSLANG_UTF8) | |
| char sjis[MAX_PATH]; | |
| #endif | |
| char *realname; | char *realname; |
| char *ext; | char *ext; |
| #if defined(OSLANG_EUC) | #if defined(OSLANG_EUC) |
| char sjis[MAX_PATH]; | codecnv_euc2sjis(sjis, sizeof(sjis), fli->path, NELEMENTS(fli->path)); |
| realname = sjis; | |
| codecnv_euc2sjis(sjis, sizeof(sjis), fli->path, sizeof(fli->path)); | #elif defined(OSLANG_UTF8) |
| oemtext_oem2sjis(sjis, sizeof(sjis), fli->path, NELEMENTS(fli->path)); | |
| realname = sjis; | realname = sjis; |
| #else | #else |
| realname = fli->path; | realname = fli->path; |
| #endif | #endif |
| FillMemory(fcbname, 11, ' '); | FillMemory(fcbname, 11, ' '); |
| // ToDo: SJISに変換済みなのに OEM依存してる | |
| ext = file_getext(realname); | ext = file_getext(realname); |
| rcnvfcb(fcbname+0, 8, realname, ext - realname); | rcnvfcb(fcbname+0, 8, realname, ext - realname); |
| rcnvfcb(fcbname+8, 3, ext, (UINT)-1); | rcnvfcb(fcbname+8, 3, ext, (UINT)-1); |
| Line 100 static BOOL hddsea(void *vpItem, void *v | Line 108 static BOOL hddsea(void *vpItem, void *v |
| return(FALSE); | return(FALSE); |
| } | } |
| LISTARRAY hostdrvs_getpathlist(const char *realpath) { | static BOOL hddseadir(void *vpItem, void *vpArg) { |
| if ((((HDRVLST)vpItem)->di.attr & 0x10) && | |
| (!memcmp(((HDRVLST)vpItem)->di.fcbname, vpArg, 11))) { | |
| return(TRUE); | |
| } | |
| return(FALSE); | |
| } | |
| LISTARRAY hostdrvs_getpathlist(const OEMCHAR *realpath) { | |
| FLISTH flh; | FLISTH flh; |
| FLINFO fli; | FLINFO fli; |
| Line 125 LISTARRAY hostdrvs_getpathlist(const cha | Line 142 LISTARRAY hostdrvs_getpathlist(const cha |
| break; | break; |
| } | } |
| CopyMemory(hdd->di.fcbname, fcbname, 11); | CopyMemory(hdd->di.fcbname, fcbname, 11); |
| hdd->di.exist = 1; | |
| hdd->di.caps = fli.caps; | hdd->di.caps = fli.caps; |
| hdd->di.size = fli.size; | hdd->di.size = fli.size; |
| hdd->di.attr = fli.attr; | hdd->di.attr = fli.attr; |
| hdd->di.date = fli.date; | hdd->di.date = fli.date; |
| hdd->di.time = fli.time; | hdd->di.time = fli.time; |
| milstr_ncpy(hdd->realname, fli.path, sizeof(hdd->realname)); | file_cpyname(hdd->realname, fli.path, NELEMENTS(hdd->realname)); |
| TRACEOUT(("%s -> %11s", fli.path, fcbname)); | // TRACEOUT(("%s -> %11s", fli.path, fcbname)); |
| } | } |
| } while(file_listnext(flh, &fli) == SUCCESS); | } while(file_listnext(flh, &fli) == SUCCESS); |
| if (listarray_getitems(ret) == 0) { | if (listarray_getitems(ret) == 0) { |
| Line 196 static char *dospath2fcb(char *fcbname, | Line 214 static char *dospath2fcb(char *fcbname, |
| BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) { | BOOL hostdrvs_getrealpath(HDRVPATH *hdp, char *dospath) { |
| char path[MAX_PATH]; | OEMCHAR path[MAX_PATH]; |
| LISTARRAY lst; | LISTARRAY lst; |
| const HDRVDIR *di; | const HDRVDIR *di; |
| HDRVLST hdl; | HDRVLST hdl; |
| char fcbname[11]; | char fcbname[11]; |
| file_cpyname(path, np2cfg.hdrvroot, sizeof(path)); | file_cpyname(path, np2cfg.hdrvroot, NELEMENTS(path)); |
| lst = NULL; | lst = NULL; |
| di = &hddroot; | di = &hddroot; |
| while(dospath[0] != '\0') { | while(dospath[0] != '\0') { |
| if ((dospath[0] != '\\') || (!(di->attr & 0x10))) { | if ((dospath[0] != '\\') || (!(di->attr & 0x10))) { |
| goto hdsgrp_err; | goto hdsgrp_err; |
| } | } |
| file_setseparator(path, sizeof(path)); | file_setseparator(path, NELEMENTS(path)); |
| dospath++; | dospath++; |
| if (dospath[0] == '\0') { | if (dospath[0] == '\0') { |
| di = &hddroot; | di = &hddroot; |
| Line 222 const HDRVDIR *di; | Line 240 const HDRVDIR *di; |
| if (hdl == NULL) { | if (hdl == NULL) { |
| goto hdsgrp_err; | goto hdsgrp_err; |
| } | } |
| file_catname(path, hdl->realname, sizeof(path)); | file_catname(path, hdl->realname, NELEMENTS(path)); |
| di = &hdl->di; | di = &hdl->di; |
| } | } |
| if (hdp) { | if (hdp) { |
| CopyMemory(&hdp->di, di, sizeof(HDRVDIR)); | 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); | listarray_destroy(lst); |
| return(SUCCESS); | return(SUCCESS); |
| Line 237 hdsgrp_err: | Line 255 hdsgrp_err: |
| return(FAILURE); | return(FAILURE); |
| } | } |
| BOOL hostdrvs_newrealpath(HDRVPATH *hdp, char *dospath) { | BOOL hostdrvs_getrealdir(OEMCHAR *path, int size, char *fcb, char *dospath) { |
| char path[MAX_PATH]; | |
| LISTARRAY lst; | LISTARRAY lst; |
| HDRVLST hdl; | HDRVLST hdl; |
| char fcbname[11]; | |
| char dosname[16]; | |
| UINT i; | |
| char *p; | |
| file_cpyname(path, np2cfg.hdrvroot, sizeof(path)); | file_cpyname(path, np2cfg.hdrvroot, size); |
| lst = NULL; | if (dospath[0] == '\\') { |
| if (dospath[0] != '\\') { | file_setseparator(path, size); |
| goto hdsgrp_err; | dospath++; |
| } | |
| else if (dospath[0] != '\0') { | |
| goto hdsgrd_err; | |
| } | } |
| while(1) { | while(1) { |
| file_setseparator(path, sizeof(path)); | dospath = dospath2fcb(fcb, dospath); |
| dospath++; | |
| if (dospath[0] == '\0') { | |
| goto hdsgrp_err; | |
| } | |
| dospath = dospath2fcb(fcbname, dospath); | |
| if (dospath[0] != '\\') { | if (dospath[0] != '\\') { |
| break; | break; |
| } | } |
| listarray_destroy(lst); | |
| lst = hostdrvs_getpathlist(path); | lst = hostdrvs_getpathlist(path); |
| hdl = (HDRVLST)listarray_enum(lst, hddsea, fcbname); | hdl = (HDRVLST)listarray_enum(lst, hddseadir, fcb); |
| if ((hdl == NULL) || (!(hdl->di.attr & 0x10))) { | if (hdl != NULL) { |
| goto hdsgrp_err; | file_catname(path, hdl->realname, size); |
| } | |
| listarray_destroy(lst); | |
| if (hdl == NULL) { | |
| goto hdsgrd_err; | |
| } | } |
| file_catname(path, hdl->realname, sizeof(path)); | file_setseparator(path, size); |
| dospath++; | |
| } | } |
| if (dospath[0] != '\0') { | if (dospath[0] != '\0') { |
| goto hdsgrp_err; | goto hdsgrd_err; |
| } | |
| return(SUCCESS); | |
| hdsgrd_err: | |
| return(FAILURE); | |
| } | |
| BOOL hostdrvs_newrealpath(HDRVPATH *hdp, char *dospath) { | |
| 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) | |
| OEMCHAR oemname[64]; | |
| #endif | |
| if ((hostdrvs_getrealdir(path, NELEMENTS(path), fcb, dospath) | |
| != SUCCESS) || | |
| (fcb[0] == ' ')) { | |
| return(FAILURE); | |
| } | } |
| listarray_destroy(lst); | |
| lst = hostdrvs_getpathlist(path); | lst = hostdrvs_getpathlist(path); |
| hdl = (HDRVLST)listarray_enum(lst, hddsea, fcbname); | hdl = (HDRVLST)listarray_enum(lst, hddsea, fcb); |
| if (hdl != NULL) { | if (hdl != NULL) { |
| file_catname(path, hdl->realname, sizeof(path)); | file_catname(path, hdl->realname, NELEMENTS(path)); |
| if (hdp) { | if (hdp) { |
| CopyMemory(&hdp->di, &hdl->di, sizeof(HDRVDIR)); | CopyMemory(&hdp->di, &hdl->di, sizeof(HDRVDIR)); |
| file_cpyname(hdp->path, path, sizeof(hdp->path)); | file_cpyname(hdp->path, path, NELEMENTS(hdp->path)); |
| } | } |
| } | } |
| else { | else { |
| p = dosname; | p = dosname; |
| for (i=0; (i<8) && (fcbname[i] != ' '); i++) { | for (i=0; (i<8) && (fcb[i] != ' '); i++) { |
| *p++ = fcbname[i]; | *p++ = fcb[i]; |
| } | } |
| if (fcbname[8] != ' ') { | if (fcb[8] != ' ') { |
| *p++ = '.'; | *p++ = '.'; |
| for (i=8; (i<11) && (fcbname[i] != ' '); i++) { | for (i=8; (i<11) && (fcb[i] != ' '); i++) { |
| *p++ = fcbname[i]; | *p++ = fcb[i]; |
| } | } |
| } | } |
| *p = '\0'; | *p = '\0'; |
| file_catname(path, dosname, sizeof(path)); | // ここで SJIS->OEMコードに未変換! |
| #if defined(OSLANG_EUC) | |
| codecnv_sjis2euc(oemname, NELEMENTS(oemname), dosname, (UINT)-1); | |
| file_catname(path, oemname, NELEMENTS(path)); | |
| #elif defined(OSLANG_UTF8) | |
| oemtext_sjis2oem(oemname, NELEMENTS(oemname), dosname, (UINT)-1); | |
| file_catname(path, oemname, NELEMENTS(path)); | |
| #else | |
| file_catname(path, dosname, NELEMENTS(path)); | |
| #endif | |
| if (hdp) { | if (hdp) { |
| CopyMemory(hdp->di.fcbname, fcbname, 11); | ZeroMemory(&hdp->di, sizeof(hdp->di)); |
| hdp->di.size = 0; | CopyMemory(hdp->di.fcbname, fcb, 11); |
| hdp->di.attr = 0; | file_cpyname(hdp->path, path, NELEMENTS(hdp->path)); |
| file_cpyname(hdp->path, path, sizeof(hdp->path)); | |
| } | } |
| } | } |
| listarray_destroy(lst); | listarray_destroy(lst); |
| return(SUCCESS); | return(SUCCESS); |
| hdsgrp_err: | |
| listarray_destroy(lst); | |
| return(FAILURE); | |
| } | } |
| // ---- | // ---- |
| void hostdrvs_fhdlreopen(LISTARRAY fhdl) { | |
| (void)fhdl; | |
| } | |
| static BOOL fhdlallclose(void *vpItem, void *vpArg) { | static BOOL fhdlallclose(void *vpItem, void *vpArg) { |
| long fh; | long fh; |
| Line 363 HDRVFILE hostdrvs_fhdlsea(LISTARRAY fhdl | Line 400 HDRVFILE hostdrvs_fhdlsea(LISTARRAY fhdl |
| return(ret); | return(ret); |
| } | } |
| #endif | |