blob: 19a4815c26e7b1eaaebc775125c9b71282bcc9f5 (
plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
/*
See license.txt in the root of this project.
*/
# ifndef LMT_UTILITIES_FILE_H
# define LMT_UTILITIES_FILE_H
/*tex
We have to deal with wide characters on windows when it comes to filenames. The same is true for
the commandline and environment variables. Basically we go from utf8 to wide and back.
\starttyping
libraries/zlib/crc32.c : fopen -> minimalistic, goes via lua anyway
libraries/zlib/trees.c : fopen -> minimalistic, goes via lua anyway
libraries/zlib/zutil.h : fopen -> minimalistic, goes via lua anyway
lua/llualib.c : fopen -> utf8_fopen
lua/lenginelib.c : fopen -> utf8_fopen
luacore/lua54/src/lauxlib.c : fopen -> see below
luacore/lua54/src/liolib.c : fopen -> see below
luacore/lua54/src/loadlib.c : fopen -> see below
luaffi/call.c : fopen -> not used
mp/mpw/mp.w : fopen -> overloaded by callback
libraries/pplib/ppload.c : fopen -> will be abstraction (next pplib)
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
libraries/pplib/util/utiliof.c : fopen -> not used
tex/texfileio.c 12: : fopen -> utf8_fopen
\stoptyping
Furthermore:
\starttyping
- system commands (execute) : done
- popen : done
- lua rename : done
- lua remove : done
- command line argv : done
- lua setenv : done
- lua getenv : done
- lfs attributes : done
- lfs chdir : done
- lfs currentdir : done
- lfs dir : done
- lfs mkdir : done
- lfs rmdir : done
- lfs touch : done
- lfs link : done
- lfs symlink : done
- lfs setexecutable : done (needs testing)
- lfs isdir : done
- lfs isfile : done
- lfs iswriteabledir : done
- lfs iswriteablefile : done
- lfs isreadabledir : done
- lfs isreadablefile : done
\stoptyping
Kind of tricky because quite some code (indirectness):
\starttyping
- lua load : via overload ?
- lua dofile : via overload -> loadstring
- lua require : via overload ?
\stoptyping
So: do we patch lua (fopen) or just copy? We can actually assume flat ascii files for libraries
and such so there is no real need unless we load job related files.
I will probably reshuffle some code and maybe more some more here; once I'm sure all works out
well.
*/
# ifdef _WIN32
# include <windows.h>
# include <ctype.h>
# include <stdio.h>
extern LPWSTR aux_utf8_to_wide (const char *utf8str);
extern char *aux_utf8_from_wide (LPWSTR widestr);
extern FILE *aux_utf8_fopen (const char *path, const char *mode);
extern FILE *aux_utf8_popen (const char *path, const char *mode);
extern int aux_utf8_system (const char *cmd);
extern int aux_utf8_remove (const char *name);
extern int aux_utf8_rename (const char *oldname, const char *newname);
extern int aux_utf8_setargv (char * **av, char **argv, int argc);
extern char *aux_utf8_getownpath (const char *file);
# else
# define aux_utf8_fopen fopen
# define aux_utf8_popen popen
# define aux_utf8_system system
# define aux_utf8_remove remove
# define aux_utf8_rename rename
extern int aux_utf8_setargv (char * **av, char **argv, int argc);
extern char *aux_utf8_getownpath (const char *file);
# include <libgen.h>
# endif
# ifdef _WIN32
extern char *aux_basename (const char *name);
extern char *aux_dirname (const char *name);
# else
# define aux_basename basename
# define aux_dirname dirname
# endif
extern int aux_is_readable (const char *filename);
/*tex
We support unix and windows. In fact, we could stick to |/| only. When
scanning filenames entered in \TEX\ we can actually enforce a |/| as
convention.
*/
# ifndef IS_DIR_SEP
# ifdef _WIN32
# define IS_DIR_SEP(ch) ((ch) == '/' || (ch) == '\\')
# else
# define IS_DIR_SEP(ch) ((ch) == '/')
# endif
# endif
# ifndef R_OK
# define F_OK 0x0
# define W_OK 0x2
# define R_OK 0x4
# endif
# ifndef S_ISREG
# define S_ISREG(mode) (mode & _S_IFREG)
# endif
# endif
|