Skip to content

Commit a1eeca1

Browse files
author
vampi
committed
mingw fixes
1 parent cce3dbf commit a1eeca1

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1+
DEBUG=true
2+
LDFLAGS=
3+
CFLAGS=
4+
5+
ifeq ($(DEBUG),true)
6+
LDFLAGS+=-g
7+
CFLAGS+=-g
8+
endif
9+
10+
ifeq ($(OS),Windows_NT)
11+
CFLAGS=-D_INC_TCHAR
12+
LDFLAGS+=-liconv
13+
endif
14+
115
all: fathuman
216

317
fathuman: main.o fatfs/ff.o fatfs/option/cc932.o
4-
gcc $^ -o $@
18+
gcc $^ -o $@ $(LDFLAGS)
519

620
%.o: %.c
7-
gcc -c $< -o $@
21+
gcc -c $< -o $@ $(CFLAGS)
822

923
clean:
1024
rm -f fathuman *.o fatfs/*.o fatfs/option/*.o

main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ FRESULT scan_files (
165165
char cbuf[256], *op = cbuf, *ip = path;
166166
size_t ib = strlen(path), ob = 256;
167167
iconv(ic, &ip, &ib, &op, &ob);
168-
// printf("Opening path [%s] = [%s]\n", path, cbuf);
169168
res = f_opendir(&dir, path); /* Open the directory */
170169
if (res == FR_OK) {
171170
i = strlen(path);
@@ -207,7 +206,6 @@ FRESULT scan_files (
207206
size_t inbytes = strlen(fnamebuf), outbytes = sizeof(convbuf);
208207
errno = 0;
209208
iconv(ic, &ip, &inbytes, &op, &outbytes);
210-
// if(errno) printf("iconv error %s\n", strerror(errno));
211209
iconv(ic, NULL, NULL, NULL, NULL);
212210

213211
printf("%s %s %s\n", fsizebuf, timebuf, convbuf);
@@ -241,7 +239,11 @@ int main (int argc, char **argv) {
241239

242240
ERR_WRAP(f_mount(&fs, "", 1));
243241

244-
ic = iconv_open("utf8//ignore", "shift_JIS");
242+
ic = iconv_open("UTF-8//ignore", "Shift_JIS");
243+
if(ic == (iconv_t)-1) {
244+
fprintf(stderr, "Could not init iconv: %s (%d)\n", strerror(errno), errno);
245+
return 1;
246+
}
245247

246248
if(!strcmp(argv[1], "list")) {
247249
char scan_path[512];

0 commit comments

Comments
 (0)