-
Notifications
You must be signed in to change notification settings - Fork 3
/
gtab-tsin-fname.cpp
71 lines (65 loc) · 1.96 KB
/
gtab-tsin-fname.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "gcin.h"
#include "gtab.h"
#include "gcin-conf.h"
#include "gcin-endian.h"
#include "pho.h"
#include "tsin.h"
#include "tsin-parse.h"
#if WIN32
#include <io.h>
#endif
void get_gcin_user_or_sys_fname(char *name, char fname[]);
gboolean init_tsin_table_fname(INMD *p, char *fname)
{
char fname_idx[256], gtab_phrase_src[256], gtabfname[256];
if (p->filename_append) {
// dbg("filename_append %s\n",p->filename_append);
strcpy(fname, p->filename_append);
strcpy(gtabfname, fname);
} else
if (p->filename) {
get_gcin_user_fname(p->filename, fname);
get_gcin_user_or_sys_fname(p->filename, gtabfname);
} else {
dbg("no file name\n");
return FALSE;
}
strcat(fname, ".tsin-db");
strcat(strcpy(fname_idx, fname), ".idx");
strcat(strcpy(gtab_phrase_src, fname), ".src");
// dbg("init_tsin_table %s\n", fname);
#if UNIX
putenv("GCIN_NO_RELOAD=");
#else
_putenv("GCIN_NO_RELOAD=Y");
#endif
#if UNIX
if (access(fname, W_OK) < 0 || access(fname_idx, W_OK) < 0)
#else
if (_access(fname, 02) < 0 || _access(fname, 02) < 0)
#endif
{
#if UNIX
if (p->phrase_txt) {
char phrase_txt[512];
get_gcin_user_or_sys_fname(p->phrase_txt, phrase_txt);
unix_exec(GCIN_BIN_DIR"/txt2gtab-phrase %s %s %s", phrase_txt, gtabfname, gtab_phrase_src);
unix_exec(GCIN_BIN_DIR"/tsa2d32 %s %s", gtab_phrase_src, fname);
} else {
unix_exec(GCIN_BIN_DIR"/tsin2gtab-phrase %s %s", gtabfname, gtab_phrase_src);
unix_exec(GCIN_BIN_DIR"/tsa2d32 %s %s", gtab_phrase_src, fname);
}
#else
if (p->phrase_txt) {
char phrase_txt[512];
get_gcin_user_or_sys_fname(p->phrase_txt, phrase_txt);
win32exec_va("txt2gtab-phrase", phrase_txt, gtabfname, gtab_phrase_src, NULL);
win32exec_va("tsa2d32", gtab_phrase_src, fname, NULL);
} else {
win32exec_va("tsin2gtab-phrase", gtabfname, gtab_phrase_src, NULL);
win32exec_va("tsa2d32", gtab_phrase_src, fname, NULL);
}
#endif
}
return TRUE;
}