From efa13a879df590ce0043a5b4f97597484bf264e1 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 13 Aug 2014 15:48:16 +1000 Subject: [PATCH] Move 3rd Party source to a new directory. Rationalise Fatfs code and fix a couple of configuration issues. --- .../fatfs-0.10b}/doc/00index_e.html | 238 +- .../fatfs-0.10b}/doc/00index_j.html | 236 +- .../fatfs-0.10b}/doc/css_e.css | 130 +- .../fatfs-0.10b}/doc/css_j.css | 136 +- .../fatfs-0.10b}/doc/css_p.css | 2 +- .../fatfs-0.10b}/doc/en/appnote.html | 549 +- .../fatfs-0.10b}/doc/en/chdir.html | 162 +- .../fatfs-0.10b}/doc/en/chdrive.html | 120 +- .../fatfs-0.10b}/doc/en/chmod.html | 178 +- .../fatfs-0.10b}/doc/en/close.html | 132 +- .../fatfs-0.10b}/doc/en/closedir.html | 128 +- .../fatfs-0.10b}/doc/en/dinit.html | 92 +- .../fatfs-0.10b}/doc/en/dioctl.html | 180 +- .../fatfs-0.10b}/doc/en/dread.html | 142 +- .../fatfs-0.10b}/doc/en/dstat.html | 96 +- .../fatfs-0.10b}/doc/en/dwrite.html | 152 +- .../fatfs-0.10b}/doc/en/eof.html | 124 +- .../fatfs-0.10b}/doc/en/error.html | 124 +- .../fatfs-0.10b}/doc/en/fattime.html | 114 +- .../fatfs-0.10b}/doc/en/fdisk.html | 194 +- .../fatfs-0.10b}/doc/en/filename.html | 156 +- .../fatfs-0.10b}/doc/en/forward.html | 278 +- .../fatfs-0.10b}/doc/en/getcwd.html | 140 +- .../fatfs-0.10b}/doc/en/getfree.html | 190 +- .../fatfs-0.10b}/doc/en/getlabel.html | 164 +- .../fatfs-0.10b}/doc/en/gets.html | 130 +- .../fatfs-0.10b}/doc/en/lseek.html | 258 +- .../fatfs-0.10b}/doc/en/mkdir.html | 160 +- .../fatfs-0.10b}/doc/en/mkfs.html | 146 +- .../fatfs-0.10b}/doc/en/mount.html | 166 +- .../fatfs-0.10b}/doc/en/open.html | 346 +- .../fatfs-0.10b}/doc/en/opendir.html | 150 +- .../fatfs-0.10b}/doc/en/printf.html | 0 .../fatfs-0.10b}/doc/en/putc.html | 124 +- .../fatfs-0.10b}/doc/en/puts.html | 124 +- .../fatfs-0.10b}/doc/en/rc.html | 174 +- .../fatfs-0.10b}/doc/en/read.html | 148 +- .../fatfs-0.10b}/doc/en/readdir.html | 250 +- .../fatfs-0.10b}/doc/en/rename.html | 170 +- .../fatfs-0.10b}/doc/en/sdir.html | 80 +- .../fatfs-0.10b}/doc/en/setlabel.html | 178 +- .../fatfs-0.10b}/doc/en/sfatfs.html | 108 +- .../fatfs-0.10b}/doc/en/sfile.html | 98 +- .../fatfs-0.10b}/doc/en/sfileinfo.html | 140 +- .../fatfs-0.10b}/doc/en/size.html | 124 +- .../fatfs-0.10b}/doc/en/stat.html | 148 +- .../fatfs-0.10b}/doc/en/sync.html | 132 +- .../fatfs-0.10b}/doc/en/tell.html | 124 +- .../fatfs-0.10b}/doc/en/truncate.html | 132 +- .../fatfs-0.10b}/doc/en/unlink.html | 150 +- .../fatfs-0.10b}/doc/en/utime.html | 198 +- .../fatfs-0.10b}/doc/en/write.html | 148 +- .../fatfs-0.10b}/doc/img/app1.c | 86 +- .../fatfs-0.10b}/doc/img/app2.c | 140 +- .../fatfs-0.10b}/doc/img/app3.c | 212 +- .../fatfs-0.10b}/doc/img/app4.c | 636 +- .../fatfs-0.10b}/doc/img/f1.png | Bin .../fatfs-0.10b}/doc/img/f2.png | Bin .../fatfs-0.10b}/doc/img/f3.png | Bin .../fatfs-0.10b}/doc/img/f4.png | Bin .../fatfs-0.10b}/doc/img/f5.png | Bin .../fatfs-0.10b}/doc/img/f6.png | Bin .../fatfs-0.10b}/doc/img/f7.png | Bin .../fatfs-0.10b}/doc/img/funcs.png | Bin .../fatfs-0.10b}/doc/img/layers.png | Bin .../fatfs-0.10b}/doc/img/layers3.png | Bin .../fatfs-0.10b}/doc/img/modules.png | Bin .../fatfs-0.10b}/doc/img/rwtest.png | Bin .../fatfs-0.10b}/doc/img/rwtest2.png | Bin .../fatfs-0.10b}/doc/img/rwtest3.png | Bin .../fatfs-0.10b}/doc/ja/appnote.html | 563 +- .../fatfs-0.10b}/doc/ja/chdir.html | 162 +- .../fatfs-0.10b}/doc/ja/chdrive.html | 122 +- .../fatfs-0.10b}/doc/ja/chmod.html | 166 +- .../fatfs-0.10b}/doc/ja/close.html | 132 +- .../fatfs-0.10b}/doc/ja/closedir.html | 128 +- .../fatfs-0.10b}/doc/ja/dinit.html | 92 +- .../fatfs-0.10b}/doc/ja/dioctl.html | 190 +- .../fatfs-0.10b}/doc/ja/dread.html | 142 +- .../fatfs-0.10b}/doc/ja/dstat.html | 96 +- .../fatfs-0.10b}/doc/ja/dwrite.html | 152 +- .../fatfs-0.10b}/doc/ja/eof.html | 124 +- .../fatfs-0.10b}/doc/ja/error.html | 124 +- .../fatfs-0.10b}/doc/ja/fattime.html | 114 +- .../fatfs-0.10b}/doc/ja/fdisk.html | 194 +- .../fatfs-0.10b}/doc/ja/filename.html | 152 +- .../fatfs-0.10b}/doc/ja/forward.html | 280 +- .../fatfs-0.10b}/doc/ja/getcwd.html | 140 +- .../fatfs-0.10b}/doc/ja/getfree.html | 190 +- .../fatfs-0.10b}/doc/ja/getlabel.html | 164 +- .../fatfs-0.10b}/doc/ja/gets.html | 130 +- .../fatfs-0.10b}/doc/ja/lseek.html | 258 +- .../fatfs-0.10b}/doc/ja/mkdir.html | 160 +- .../fatfs-0.10b}/doc/ja/mkfs.html | 146 +- .../fatfs-0.10b}/doc/ja/mount.html | 164 +- .../fatfs-0.10b}/doc/ja/open.html | 342 +- .../fatfs-0.10b}/doc/ja/opendir.html | 152 +- .../fatfs-0.10b}/doc/ja/printf.html | 186 +- .../fatfs-0.10b}/doc/ja/putc.html | 124 +- .../fatfs-0.10b}/doc/ja/puts.html | 124 +- .../fatfs-0.10b}/doc/ja/rc.html | 170 +- .../fatfs-0.10b}/doc/ja/read.html | 150 +- .../fatfs-0.10b}/doc/ja/readdir.html | 252 +- .../fatfs-0.10b}/doc/ja/rename.html | 164 +- .../fatfs-0.10b}/doc/ja/sdir.html | 80 +- .../fatfs-0.10b}/doc/ja/setlabel.html | 178 +- .../fatfs-0.10b}/doc/ja/sfatfs.html | 110 +- .../fatfs-0.10b}/doc/ja/sfile.html | 96 +- .../fatfs-0.10b}/doc/ja/sfileinfo.html | 140 +- .../fatfs-0.10b}/doc/ja/size.html | 124 +- .../fatfs-0.10b}/doc/ja/stat.html | 148 +- .../fatfs-0.10b}/doc/ja/sync.html | 132 +- .../fatfs-0.10b}/doc/ja/tell.html | 124 +- .../fatfs-0.10b}/doc/ja/truncate.html | 134 +- .../fatfs-0.10b}/doc/ja/unlink.html | 148 +- .../fatfs-0.10b}/doc/ja/utime.html | 198 +- .../fatfs-0.10b}/doc/ja/write.html | 150 +- .../fatfs-0.10b}/doc/updates.txt | 292 +- .../fatfs-0.10b}/src/00readme.txt | 316 +- 3rdparty/fatfs-0.10b/src/diskio.c | 236 + .../fatfs-0.10b}/src/diskio.h | 160 +- .../fatfs => 3rdparty/fatfs-0.10b}/src/ff.c | 9176 +++---- .../fatfs => 3rdparty/fatfs-0.10b}/src/ff.h | 684 +- 3rdparty/fatfs-0.10b/src/ffconf.h | 228 + .../fatfs-0.10b}/src/integer.h | 66 +- .../fatfs-0.10b}/src/option/cc932.c | 7596 +++--- .../fatfs-0.10b}/src/option/cc936.c | 21946 ++++++++-------- .../fatfs-0.10b}/src/option/cc949.c | 17206 ++++++------ .../fatfs-0.10b}/src/option/cc950.c | 13658 +++++----- .../fatfs-0.10b}/src/option/ccsbcs.c | 1080 +- .../fatfs-0.10b}/src/option/syscall.c | 306 +- .../fatfs-0.10b}/src/option/unicode.c | 34 +- src/gfile/fatfs/src/ffconf.h => ffconf.h | 3 +- src/gfile/fatfs/fatfs.c | 21 - src/gfile/fatfs/fatfs.mk | 6 - src/gfile/fatfs/fatfs_syscall.c | 80 - src/gfile/fatfs/readme.txt | 8 - src/gfile/{fatfs => }/fatfs_chibios_diskio.c | 7 +- src/gfile/fatfs_wrapper.c | 89 + src/gfile/fatfs_wrapper.h | 32 + src/gfile/inc_fatfs.c | 7 +- src/gfile/sys_make.mk | 7 +- 142 files changed, 45379 insertions(+), 44913 deletions(-) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/00index_e.html (88%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/00index_j.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/css_e.css (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/css_j.css (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/css_p.css (99%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/appnote.html (90%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/chdir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/chdrive.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/chmod.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/close.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/closedir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/dinit.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/dioctl.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/dread.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/dstat.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/dwrite.html (92%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/eof.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/error.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/fattime.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/fdisk.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/filename.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/forward.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/getcwd.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/getfree.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/getlabel.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/gets.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/lseek.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/mkdir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/mkfs.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/mount.html (93%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/open.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/opendir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/printf.html (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/putc.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/puts.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/rc.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/read.html (94%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/readdir.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/rename.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/sdir.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/setlabel.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/sfatfs.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/sfile.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/sfileinfo.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/size.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/stat.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/sync.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/tell.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/truncate.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/unlink.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/utime.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/en/write.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/app1.c (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/app2.c (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/app3.c (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/app4.c (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f1.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f2.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f3.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f4.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f5.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f6.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/f7.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/funcs.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/layers.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/layers3.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/modules.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/rwtest.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/rwtest2.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/img/rwtest3.png (100%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/appnote.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/chdir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/chdrive.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/chmod.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/close.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/closedir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/dinit.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/dioctl.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/dread.html (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/dstat.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/dwrite.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/eof.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/error.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/fattime.html (89%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/fdisk.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/filename.html (99%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/forward.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/getcwd.html (92%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/getfree.html (82%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/getlabel.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/gets.html (85%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/lseek.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/mkdir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/mkfs.html (92%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/mount.html (85%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/open.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/opendir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/printf.html (88%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/putc.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/puts.html (81%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/rc.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/read.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/readdir.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/rename.html (94%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/sdir.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/setlabel.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/sfatfs.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/sfile.html (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/sfileinfo.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/size.html (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/stat.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/sync.html (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/tell.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/truncate.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/unlink.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/utime.html (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/ja/write.html (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/doc/updates.txt (86%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/00readme.txt (98%) create mode 100644 3rdparty/fatfs-0.10b/src/diskio.c rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/diskio.h (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/ff.c (97%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/ff.h (97%) create mode 100644 3rdparty/fatfs-0.10b/src/ffconf.h rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/integer.h (95%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/cc932.c (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/cc936.c (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/cc949.c (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/cc950.c (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/ccsbcs.c (98%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/syscall.c (96%) rename {src/gfile/fatfs => 3rdparty/fatfs-0.10b}/src/option/unicode.c (95%) rename src/gfile/fatfs/src/ffconf.h => ffconf.h (99%) delete mode 100644 src/gfile/fatfs/fatfs.c delete mode 100644 src/gfile/fatfs/fatfs.mk delete mode 100644 src/gfile/fatfs/fatfs_syscall.c delete mode 100644 src/gfile/fatfs/readme.txt rename src/gfile/{fatfs => }/fatfs_chibios_diskio.c (98%) create mode 100644 src/gfile/fatfs_wrapper.c create mode 100644 src/gfile/fatfs_wrapper.h diff --git a/src/gfile/fatfs/doc/00index_e.html b/3rdparty/fatfs-0.10b/doc/00index_e.html similarity index 88% rename from src/gfile/fatfs/doc/00index_e.html rename to 3rdparty/fatfs-0.10b/doc/00index_e.html index 1e5a9865..99ec2a7f 100644 --- a/src/gfile/fatfs/doc/00index_e.html +++ b/3rdparty/fatfs-0.10b/doc/00index_e.html @@ -1,120 +1,118 @@ - - - - - - - - - - - -FatFs - Generic FAT File System Module - - - -

FatFs - Generic FAT File System Module

-
- -
-layer -

FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k and etc... Petit FatFs module is also available here↗ for tiny microcontrollers.

- -

Features

- -
- - -
-

Application Interface

-

FatFs module provides following functions to the applications. In other words, this list describes what FatFs can do to access the FAT volumes.

- -
- - -
-

Disk I/O Interface

-

Since the FatFs module is completely separated from disk I/O layer, it requires following functions to access the storage device. When O/S related feature is enabled, it will require process/memory functions in addition. However the low level disk I/O module is not a part of FatFs module, so that it must be provided by user. The sample implementations are also available in the downloads.

- -
- - -
-

Resources

-

The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.

- -
- - -
-

Return

- - + + + + + + + + + +FatFs - Generic FAT File System Module + + + +

FatFs - Generic FAT File System Module

+
+ +
+layer +

FatFs is a generic FAT file system module for small embedded systems. The FatFs is written in compliance with ANSI C and completely separated from the disk I/O layer. Therefore it is independent of hardware architecture. It can be incorporated into small microcontrollers with limited resource, such as AVR, 8051, PIC, ARM, Z80, 68k and etc. Also Petit FatFs module for tiny microcontrollers is available here.

+ +

Features

+ +
+ + +
+

Application Interface

+

FatFs module provides following functions to the applications. In other words, this list describes what FatFs can do to access the FAT volumes.

+ +
+ + +
+

Device Control Interface

+

Since the FatFs module is a file system driver, it is completely separated from physical devices, such as memory card, harddisk and any type of storage devices. The low level device control module is not a part of FatFs module. FatFs accesses the storage device via a simple interface described below. These functions are provided by implementer. Sample implementations for some platforms are also available in the downloads.

+ +
+ + +
+

Resources

+

The FatFs module is a free software opened for education, research and development. You can use, modify and/or redistribute it for personal projects or commercial products without any restriction under your responsibility. For further information, refer to the application note.

+ +
+ + +
+

Return

+ + diff --git a/src/gfile/fatfs/doc/00index_j.html b/3rdparty/fatfs-0.10b/doc/00index_j.html similarity index 98% rename from src/gfile/fatfs/doc/00index_j.html rename to 3rdparty/fatfs-0.10b/doc/00index_j.html index d5496e95..da94847d 100644 --- a/src/gfile/fatfs/doc/00index_j.html +++ b/3rdparty/fatfs-0.10b/doc/00index_j.html @@ -1,118 +1,118 @@ - - - - - - - - - - - -FatFs 汎用FATファイルシステム・モジュール - - - -

FatFs 汎用FATファイルシステム・モジュール

-
- -
-layer -

FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクしたぷちFatFs↗もあります。

-

FatFsモジュールの特徴

- -
- - -
-

上位レイヤ・インターフェース

-

FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。

- -
- - -
-

下位レイヤ・インターフェース

-

FatFsモジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。

- -
- - -
-

資料

-

FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。

- -
- - -
-

戻る

- - + + + + + + + + + + + +FatFs 汎用FATファイルシステム・モジュール + + + +

FatFs 汎用FATファイルシステム・モジュール

+
+ +
+layer +

FatFsは小規模な組み込みシステム向けの汎用FATファイルシステム・モジュールです。ANSI C準拠でハードウェア・アーキテクチャには依存しないので、必要なワーク・エリアが確保できれば、8051, PIC, AVR, SH, Z80, 68k, H8, ARMなど安価なマイコンでも使用可能です。FatFsをシュリンクしたぷちFatFs↗もあります。

+

FatFsモジュールの特徴

+ +
+ + +
+

上位レイヤ・インターフェース

+

FatFsモジュールは、アプリケーション・レイヤに対し、次のファイル操作関数(API)を提供します。つまり、このリストはFatFsにできることをシンプルに示しています。

+ +
+ + +
+

下位レイヤ・インターフェース

+

FatFsモジュールは、単なるファイル・システム・レイヤなので、ストレージ・デバイス制御レイヤは含まれません。使用するストレージに対応した制御関数は、ユーザによって提供される必要があります。FatFsモジュールは、下位レイヤに対し少なくとも次のインターフェースを要求します。OS関連機能を有効にしたときは、これに加えてプロセス/メモリ関連関数も必要になります。サンプル・プロジェクトに下位レイヤの実装例を示します。

+ +
+ + +
+

資料

+

FatFsモジュールはフリー・ソフトウェアとして教育・研究・開発用に公開しています。どのような利用目的(個人利用から商用まで)でも使用・改変・配布について一切の制限はありませんが、全て利用者の責任の下での利用とします。詳しくはアプリケーション・ノートを参照してください。

+ +
+ + +
+

戻る

+ + diff --git a/src/gfile/fatfs/doc/css_e.css b/3rdparty/fatfs-0.10b/doc/css_e.css similarity index 98% rename from src/gfile/fatfs/doc/css_e.css rename to 3rdparty/fatfs-0.10b/doc/css_e.css index 2fa0cc1c..1b544eb6 100644 --- a/src/gfile/fatfs/doc/css_e.css +++ b/3rdparty/fatfs-0.10b/doc/css_e.css @@ -1,65 +1,65 @@ -* {margin: 0; padding: 0; border-width: 0;} -body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} -a:link {color: blue;} -a:visited {color: darkmagenta;} -a:hover {background-color: #a0ffff;} -a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} -abbr {border-width: 1px;} - -p {margin: 0 0 0.3em 1em;} -i {margin: 0 0.3em 0 0;} -b {margin: 0 0.1em;} -em {font-style: normal; font-weight: bold; margin: 0 0.1em;} -strong {} -pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;} -pre span.c {color: green;} -pre span.k {color: blue;} -pre span.arg {font-style: italic;} -tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } -tt.arg {font-style: italic;} -ol {margin: 0.5em 2.5em;} -ul {margin: 0.5em 2em;} -dl {margin: 0.5em 1em;} -dd {margin: 0 2em;} -dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} -dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; } -dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} -hr {border-width: 1px; margin: 1em;} -div.abst {font-family: sans-serif;} -div.para {clear: both; font-family: serif;} -div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } -.equ {text-indent: 0; margin: 1em 2em 1em;} -.indent {margin-left: 2em;} -.rset {float: right; margin: 0.3em 0 0.5em 0.5em;} -.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;} -ul.flat li {list-style-type: none; margin: 0;} -a.imglnk img {border: 1px solid;} -.iequ {white-space: nowrap; font-weight: bold;} -.clr {clear: both;} -.it {font-style: italic;} -.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap} -.ral {text-align: right; } -.lal {text-align: left; } -.cal {text-align: center; } - -h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} -p.hdd {float: right; text-align: right; margin-top: 0.5em;} -hr.hds {clear: both; margin-bottom: 1em;} - -h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} -h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;} -h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;} -h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;} -small {font-size: 80%;} -.indent {margin-left: 2em;} - -/* Tables */ -table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; } -th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;} -td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} -table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} -table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} -table caption {font-family: sans-serif; font-weight: bold;} -tr.lst3 td { border-width: 2px 1px 1px; } - -p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} +* {margin: 0; padding: 0; border-width: 0;} +body {margin: 8px; background-color: #e0ffff; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} +a:link {color: blue;} +a:visited {color: darkmagenta;} +a:hover {background-color: #a0ffff;} +a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} +abbr {border-width: 1px;} + +p {margin: 0 0 0.3em 1em;} +i {margin: 0 0.3em 0 0;} +b {margin: 0 0.1em;} +em {font-style: normal; font-weight: bold; margin: 0 0.1em;} +strong {} +pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; font-size: 85%; font-family: "Consolas", "Courier New", monospace; background-color: white;} +pre span.c {color: green;} +pre span.k {color: blue;} +pre span.arg {font-style: italic;} +tt {margin: 0 0.2em; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } +tt.arg {font-style: italic;} +ol {margin: 0.5em 2.5em;} +ul {margin: 0.5em 2em;} +dl {margin: 0.5em 1em;} +dd {margin: 0 2em;} +dt {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; } +dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +hr {border-width: 1px; margin: 1em;} +div.abst {font-family: sans-serif;} +div.para {clear: both; font-family: serif;} +div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } +.equ {text-indent: 0; margin: 1em 2em 1em;} +.indent {margin-left: 2em;} +.rset {float: right; margin: 0.3em 0 0.5em 0.5em;} +.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;} +ul.flat li {list-style-type: none; margin: 0;} +a.imglnk img {border: 1px solid;} +.iequ {white-space: nowrap; font-weight: bold;} +.clr {clear: both;} +.it {font-style: italic;} +.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap} +.ral {text-align: right; } +.lal {text-align: left; } +.cal {text-align: center; } + +h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} +p.hdd {float: right; text-align: right; margin-top: 0.5em;} +hr.hds {clear: both; margin-bottom: 1em;} + +h2 {font-size: 2em; font-family: sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} +h3 {font-size: 1.5em; font-family: sans-serif; margin: 1.5em 0 0.5em;} +h4 {font-size: 1.2em; font-family: sans-serif; margin: 1em 0 0.2em;} +h5 {font-size: 1em; font-family: sans-serif; margin: 0.5em 0 0em;} +small {font-size: 80%;} +.indent {margin-left: 2em;} + +/* Tables */ +table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; } +th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top; white-space: nowrap;} +td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} +table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace;} +table caption {font-family: sans-serif; font-weight: bold;} +tr.lst3 td { border-width: 2px 1px 1px; } + +p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} diff --git a/src/gfile/fatfs/doc/css_j.css b/3rdparty/fatfs-0.10b/doc/css_j.css similarity index 98% rename from src/gfile/fatfs/doc/css_j.css rename to 3rdparty/fatfs-0.10b/doc/css_j.css index b226a8b7..35164201 100644 --- a/src/gfile/fatfs/doc/css_j.css +++ b/3rdparty/fatfs-0.10b/doc/css_j.css @@ -1,68 +1,68 @@ -@charset "Shift_JIS"; -/* Common style sheet for Tech Notes */ - -* {margin: 0; padding: 0; border-width: 0;} -body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"lr o", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;} -a:link {color: blue;} -a:visited {color: darkmagenta;} -a:hover {background-color: #a0ffff;} -a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} -abbr {border-width: 1px;} - -p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} -i {margin: 0 0.3em 0 0;} -b {margin: 0 0.1em;} -em {font-style: normal; font-weight: bold; margin: 0 0.1em;} -strong {} -pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace; background-color: white;} -pre span.c {color: green;} -pre span.k {color: blue;} -pre span.arg {font-style: italic;} -tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace;} -tt.arg {font-style: italic;} -ol {margin: 0.5em 2.5em;} -ul {margin: 0.5em 2em;} -dl {margin: 0.5em 1em;} -dd {margin: 0em 2em;} -dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace;} -dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;} -dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace; letter-spacing: 0; } -hr {border-width: 1px; margin: 1em;} -div.abst {font-family: "lr oSVbN",sans-serif;} -div.para {clear: both; font-family: "lr o",serif;} -div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } -.equ {text-indent: 0; margin: 1em 2em 1em;} -.indent {margin-left: 2em;} -.rset {float: right; margin: 0.3em 0 0.5em 0.5em;} -.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;} -ul.flat li {list-style-type: none; margin: 0;} -a.imglnk img {border: 1px solid;} -.iequ {white-space: nowrap; font-weight: bold;} -.clr {clear: both;} -.it {font-style: italic;} -.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap} -.ral {text-align: right; } -.lal {text-align: left; } -.cal {text-align: center; } - -h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} -p.hdd {float: right; text-align: right; margin-top: 0.5em;} -hr.hds {clear: both; margin-bottom: 1em;} - -h2 {font-size: 2em; font-family: "lr oSVbN",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} -h3 {font-size: 1.5em; font-family: "lr oSVbN",sans-serif; margin: 1.5em 0 0.5em;} -h4 {font-size: 1.2em; font-family: "lr oSVbN",sans-serif; margin: 1em 0 0.2em;} -h5 {font-size: 1em; font-family: "lr oSVbN",sans-serif; margin: 0.5em 0 0em;} -small {font-size: 80%;} -.indent {margin-left: 2em;} - -/* Tables */ -table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;} -th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;} -td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} -table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;} -table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;} -table caption {font-family: sans-serif; font-weight: bold;} -tr.lst3 td {border-width: 2px 1px 1px; } - -p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} +@charset "Shift_JIS"; +/* Common style sheet for Tech Notes */ + +* {margin: 0; padding: 0; border-width: 0;} +body {margin: 8px; background-color: #e0ffff; font-color: black; font-family:"lr o", serif; line-height: 150%; letter-spacing: 1px; max-width: 1024px;} +a:link {color: blue;} +a:visited {color: darkmagenta;} +a:hover {background-color: #a0ffff;} +a:active {color: darkmagenta; overflow: hidden; outline:none; position: relative; top: 1px; left: 1px;} +abbr {border-width: 1px;} + +p {text-indent: 1em; margin: 0 0 0.3em 0.5em;} +i {margin: 0 0.3em 0 0;} +b {margin: 0 0.1em;} +em {font-style: normal; font-weight: bold; margin: 0 0.1em;} +strong {} +pre {border: 1px dashed gray; margin: 0.5em 1em; padding: 0.5em; line-height: 1.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace; background-color: white;} +pre span.c {color: green;} +pre span.k {color: blue;} +pre span.arg {font-style: italic;} +tt {margin: 0 0.2em; letter-spacing: 0; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace;} +tt.arg {font-style: italic;} +ol {margin: 0.5em 2.5em;} +ul {margin: 0.5em 2em;} +dl {margin: 0.5em 1em;} +dd {margin: 0em 2em;} +dt {font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace;} +dl.par dt {margin: 0.5em 0 0 0 ; font-style: italic; letter-spacing: 0;} +dl.ret dt {margin: 0.5em 0 0 0 ; font-size: 0.85em; font-family: "Consolas", "Courier New", "lr SVbN", monospace; letter-spacing: 0; } +hr {border-width: 1px; margin: 1em;} +div.abst {font-family: "lr oSVbN",sans-serif;} +div.para {clear: both; font-family: "lr o",serif;} +div.ret a {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; } +.equ {text-indent: 0; margin: 1em 2em 1em;} +.indent {margin-left: 2em;} +.rset {float: right; margin: 0.3em 0 0.5em 0.5em;} +.lset {float: left; margin: 0.3em 0.5em 0.5em 0.5em;} +ul.flat li {list-style-type: none; margin: 0;} +a.imglnk img {border: 1px solid;} +.iequ {white-space: nowrap; font-weight: bold;} +.clr {clear: both;} +.it {font-style: italic;} +.mfd {font-size: 0.7em; padding: 0 1px; border: 1px solid; white-space : nowrap} +.ral {text-align: right; } +.lal {text-align: left; } +.cal {text-align: center; } + +h1 {line-height: 1em; font-size: 2em; font-family: sans-serif; padding: 0.3em 0 0.3em;} +p.hdd {float: right; text-align: right; margin-top: 0.5em;} +hr.hds {clear: both; margin-bottom: 1em;} + +h2 {font-size: 2em; font-family: "lr oSVbN",sans-serif; background-color: #d8d8FF; padding: 0.5em 0.5em; margin: 0 0 0.5em;} +h3 {font-size: 1.5em; font-family: "lr oSVbN",sans-serif; margin: 1.5em 0 0.5em;} +h4 {font-size: 1.2em; font-family: "lr oSVbN",sans-serif; margin: 1em 0 0.2em;} +h5 {font-size: 1em; font-family: "lr oSVbN",sans-serif; margin: 0.5em 0 0em;} +small {font-size: 80%;} +.indent {margin-left: 2em;} + +/* Tables */ +table {margin: 0.5em 1em; border-collapse: collapse; border: 2px solid black; letter-spacing: 0;} +th {background-color: white; border-style: solid; border-width: 1px 1px 2px; border-color: black; padding: 0 3px; vertical-align: top;} +td {background-color: white; border: 1px solid black; padding: 0 3px; vertical-align: top; line-height: 1.3em;} +table.lst td:first-child {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;} +table.lst2 td {font-size: 0.85em; font-family: "Consolas", "Courier New", monospace; white-space: nowrap;} +table caption {font-family: sans-serif; font-weight: bold;} +tr.lst3 td {border-width: 2px 1px 1px; } + +p.foot {clear: both; text-indent: 0; margin: 1em 0.5em 1em;} diff --git a/src/gfile/fatfs/doc/css_p.css b/3rdparty/fatfs-0.10b/doc/css_p.css similarity index 99% rename from src/gfile/fatfs/doc/css_p.css rename to 3rdparty/fatfs-0.10b/doc/css_p.css index f8589aa6..bc7b5b09 100644 --- a/src/gfile/fatfs/doc/css_p.css +++ b/3rdparty/fatfs-0.10b/doc/css_p.css @@ -1 +1 @@ -body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} +body {margin: 8px; background-color: #ffecf0; font-color: black; font-family: serif; line-height: 133%; max-width: 1024px;} diff --git a/src/gfile/fatfs/doc/en/appnote.html b/3rdparty/fatfs-0.10b/doc/en/appnote.html similarity index 90% rename from src/gfile/fatfs/doc/en/appnote.html rename to 3rdparty/fatfs-0.10b/doc/en/appnote.html index 8e77d1e8..f7974e23 100644 --- a/src/gfile/fatfs/doc/en/appnote.html +++ b/3rdparty/fatfs-0.10b/doc/en/appnote.html @@ -1,274 +1,275 @@ - - - - - - - - -FatFs Module Application Note - - - -

FatFs Module Application Note

-
    -
  1. How to Port
  2. -
  3. Limits
  4. -
  5. Memory Usage
  6. -
  7. Module Size Reduction
  8. -
  9. Long File Name
  10. -
  11. Unicode API
  12. -
  13. Re-entrancy
  14. -
  15. Duplicated File Access
  16. -
  17. Performance Effective File Access
  18. -
  19. Considerations on Flash Memory Media
  20. -
  21. Critical Section
  22. -
  23. Extended Use of FatFs API
  24. -
  25. About FatFs License
  26. -
-
- -
-

How to Port

- -

Basic considerations

-

The FatFs module is assuming following conditions on portability.

- - -

System organizations

-

The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.

-

dependency diagram

-

(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.

-

functional diagram

- -

Which function is required?

-

You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.

- - - - - - - - - - -
FunctionRequired when:Note
disk_status
disk_initialize
disk_read
AlwaysDisk I/O functions.
Samples available in ffsample.zip.
There are many implementations on the web.
disk_write
get_fattime
disk_ioctl (CTRL_SYNC)
_FS_READONLY == 0
disk_ioctl (GET_SECTOR_COUNT)
disk_ioctl (GET_BLOCK_SIZE)
_USE_MKFS == 1
disk_ioctl (GET_SECTOR_SIZE)_MAX_SS != _MIN_SS
disk_ioctl (CTRL_ERASE_SECTOR)_USE_ERASE == 1
ff_convert
ff_wtoupper
_USE_LFN >= 1Unicode support functions.
Available in option/unicode.c.
ff_cre_syncobj
ff_del_syncobj
ff_req_grant
ff_rel_grant
_FS_REENTRANT == 1O/S dependent functions.
Samples available in option/syscall.c.
ff_mem_alloc
ff_mem_free
_USE_LFN == 3
-
- -
-

Limits

- -
- -
-

Memory Usage

- - - - - - - - - - - - -
ARM7
32bit
ARM7
Thumb
CM3
Thumb-2
AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
_WORD_ACCESS00010001011
text (Full, R/W)1067571716617133551094011722132628113904860327952
text (Min, R/W) 672746314331 8569 7262 7720 90885287580039485183
text (Full, R/O) 473131472889 6235 5170 5497 64823833397228623719
text (Min, R/O) 355924852295 4575 4064 4240 50192993310422142889
bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*4 + 2
Work area
(_FS_TINY == 0)
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
V*560
+ F*544
V*560
+ F*550
V*560
+ F*544
V*560
+ F*544
V*560
+ F*544
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
Work area
(_FS_TINY == 1)
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*32
V*560
+ F*36
V*560
+ F*32
V*560
+ F*32
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
-

These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, V denotes number of volumes and F denotes number of open files. All samples are optimezed in code size.

-
-FatFs R0.10a options:
-_FS_READONLY     0 (R/W) or 1 (R/O)
-_FS_MINIMIZE     0 (Full function) or 3 (Minimized function)
-_USE_STRFUNC     0 (Disable string functions)
-_USE_MKFS        0 (Disable f_mkfs function)
-_USE_FORWARD     0 (Disable f_forward function)
-_USE_FASTSEEK    0 (Disable fast seek feature)
-_CODE_PAGE       932 (Japanese Shift-JIS)
-_USE_LFN         0 (Disable LFN feature)
-_MAX_SS          512 (Fixed sector size)
-_FS_RPATH        0 (Disable relative path feature)
-_FS_LABEL        0 (Disable volume label functions)
-_VOLUMES         V (Number of logical drives to be used)
-_MULTI_PARTITION 0 (Single partition per drive)
-_FS_REENTRANT    0 (Disable thread safe)
-_FS_LOCK         0 (Disable file lock control)
-
-
- -
-

Module Size Reduction

-

Follwing table shows which API function is removed by configuration options for the module size reduction.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_FS_LABEL_USE_MKFS_USE_FORWARD_MULTI_PARTITION
0123010  1/201201010101
f_mount
f_open
f_close
f_read
f_writex
f_syncx
f_lseekx
f_opendirxx
f_closedirxx
f_readdirxx
f_statxxx
f_getfreexxxx
f_truncatexxxx
f_unlinkxxxx
f_mkdirxxxx
f_chmodxxxx
f_utimexxxx
f_renamexxxx
f_chdirx
f_chdrivex
f_getcwdxx
f_getlabelx
f_setlabelxx
f_forwardx
f_mkfsxx
f_fdiskxxx
f_putcxx
f_putsxx
f_printfxx
f_getsx
-
- -
-

Long File Name

-

FatFs module supports long file name (LFN). The two different file names, SFN and LFN, of a file is transparent in the file functions except for f_readdir() function. The LFN feature is disabled by default. To enable it, set _USE_LFN to 1, 2 or 3, and add option/unicode.c to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by _MAX_LFN according to the available memory size. The size of long file name will reach up to 255 characters, so that the _MAX_LFN should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the given file name, the file function fails with FR_INVALID_NAME. When enable the LFN feature with re-entrant configuration, _USE_LFN must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies (_MAX_LFN + 1) * 2 bytes.

- - - - - - - - -
LFN cfg on ARM7TDMI
Code pageProgram size
SBCS+3.7K
932(Shift-JIS)+62K
936(GBK)+177K
949(Korean)+139K
950(Big5)+111K
-

When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.

-

Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.

-
- -
-

Unicode API

-

By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API (_LFN_UNICODE). This means the FatFs supports the True-LFN feature. For more information, refer to the description in the file name.

-
- -
-

Re-entrancy

-

The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe with _FS_REENTRANT option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant() must be added to the project.

-

When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves file function. If wait time exceeded a period defined by _TIMEOUT, the file function will abort with FR_TIMEOUT. The timeout feature might not be supported by some RTOS.

-

There is an exception for f_mount(), f_mkfs(), f_fdisk() function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.

-

Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.

-
- -
-

Duplicated File Access

-

FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.

-

The file lock control can also be available by _FS_LOCK option. The value defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with FR_LOCKED. If number of open files and sub-directories gets larger than _FS_LOCK, the open function will fail with FR_TOO_MANY_OPEN_FILES.

-
- -
-

Performance Effective File Access

-

For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by f_read() function.

-

Figure 1. Sector misaligned read (short)
- -

-

Figure 2. Sector misaligned read (long)
- -

-

Figure 3. Fully sector aligned read
- -

-

The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option _FS_TINY determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.

-

Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read() function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.

-

Therefore taking effort to sector aligned read/write accesss eliminates buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.

-
- -
-

Considerations on Flash Memory Media

-

To maximize the write performance of flash memory media, such as SDC, CFC and U Disk, it must be controlled in consideration of its characteristitcs.

-

Using Mutiple-Sector Write

-
-Figure 6. Comparison between Multiple/Single Sector Write
-fig.6 -
-

The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. This graph is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. The number of write transactions also affects the life time of the flash memory media. Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature.

-

Forcing Memory Erase

-

When remove a file with f_remove() function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting _USE_ERASE to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also f_remove() function will take a time when remove a large file. Most applications will not need this feature.

-
- -
-

Critical Section

-

If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.

-
-Figure 4. Long critical section
-fig.4 -
-
-Figure 5. Minimized critical section
-fig.5 -
-
-

An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.

- -

Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using f_sync() function as shown in Figure 5.

-
- -
-

Extended Use of FatFs API

-

These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.

-
    -
  1. Open or create a file for append
  2. -
  3. Empty a directory
  4. -
  5. Allocate contiguous area to the file
  6. -
  7. Function/Compatible checker for low level disk I/O module
  8. -
-
- -
-

About FatFs License

-

FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the FatFs license document that included in the source files.

-
/*----------------------------------------------------------------------------/
-/  FatFs - FAT file system module  R0.10b                    (C)ChaN, 2014
-/-----------------------------------------------------------------------------/
-/ FatFs module is a generic FAT file system module for small embedded systems.
-/ This is a free software that opened for education, research and commercial
-/ developments under license policy of following trems.
-/
-/  Copyright (C) 2014, ChaN, all right reserved.
-/
-/ * The FatFs module is a free software and there is NO WARRANTY.
-/ * No restriction on use. You can use, modify and redistribute it for
-/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
-/ * Redistributions of source code must retain the above copyright notice.
-/
-/-----------------------------------------------------------------------------/
-

Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library and any form without source code, are not specified in order to extend usability to commercial use. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification, the license can also be changed to GNU GPL or BSD-style license.

-
- -

Return

- - + + + + + + + + +FatFs Module Application Note + + + +

FatFs Module Application Note

+
    +
  1. How to Port
  2. +
  3. Limits
  4. +
  5. Memory Usage
  6. +
  7. Module Size Reduction
  8. +
  9. Long File Name
  10. +
  11. Unicode API
  12. +
  13. Re-entrancy
  14. +
  15. Duplicated File Access
  16. +
  17. Performance Effective File Access
  18. +
  19. Considerations on Flash Memory Media
  20. +
  21. Critical Section
  22. +
  23. Extended Use of FatFs API
  24. +
  25. About FatFs License
  26. +
+
+ +
+

How to Port

+ +

Basic considerations

+

The FatFs module is assuming following conditions on portability.

+ + +

System organizations

+

The dependency diagram shown below is a typical configuration of the embedded system with FatFs module.

+

dependency diagram

+

(a) If a working disk module with FatFs API is provided, no additional function is needed. (b) To attach existing disk drivers with different API, glue functions are needed to translate the APIs between FatFs and the drivers.

+

functional diagram

+ +

Which function is required?

+

You need to provide only low level disk I/O functions that required by FatFs module and nothing else. If a working disk module for the target is already existing, you need to write only glue functions to attach it to the FatFs module. If not, you need to port any other disk module or write it from scratch. Most of defined functions are not that always required. For example, disk write function is not required in read-only configuration. Following table shows which function is required depends on configuration options.

+ + + + + + + + + + +
FunctionRequired when:Note
disk_status
disk_initialize
disk_read
AlwaysDisk I/O functions.
Samples available in ffsample.zip.
There are many implementations on the web.
disk_write
get_fattime
disk_ioctl (CTRL_SYNC)
_FS_READONLY == 0
disk_ioctl (GET_SECTOR_COUNT)
disk_ioctl (GET_BLOCK_SIZE)
_USE_MKFS == 1
disk_ioctl (GET_SECTOR_SIZE)_MAX_SS != _MIN_SS
disk_ioctl (CTRL_ERASE_SECTOR)_USE_ERASE == 1
ff_convert
ff_wtoupper
_USE_LFN >= 1Unicode support functions.
Available in option/unicode.c.
ff_cre_syncobj
ff_del_syncobj
ff_req_grant
ff_rel_grant
_FS_REENTRANT == 1O/S dependent functions.
Samples available in option/syscall.c.
ff_mem_alloc
ff_mem_free
_USE_LFN == 3
+
+ +
+

Limits

+ +
+ +
+

Memory Usage

+ + + + + + + + + + + + +
ARM7
32bit
ARM7
Thumb
CM3
Thumb-2
AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
_WORD_ACCESS00010001011
text (Full, R/W)1067571716617133551094011722132628113904860327952
text (Min, R/W) 672746314331 8569 7262 7720 90885287580039485183
text (Full, R/O) 473131472889 6235 5170 5497 64823833397228623719
text (Min, R/O) 355924852295 4575 4064 4240 50192993310422142889
bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*4 + 2
Work area
(_FS_TINY == 0)
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
V*560
+ F*544
V*560
+ F*550
V*560
+ F*544
V*560
+ F*544
V*560
+ F*544
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
Work area
(_FS_TINY == 1)
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*32
V*560
+ F*36
V*560
+ F*32
V*560
+ F*32
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
+

These are the memory usage on some target systems with following condition. The memory sizes are in unit of byte, V denotes number of volumes and F denotes number of open files. All samples are optimezed in code size.

+
+FatFs R0.10a options:
+_FS_READONLY     0 (R/W) or 1 (R/O)
+_FS_MINIMIZE     0 (Full function) or 3 (Minimized function)
+_USE_STRFUNC     0 (Disable string functions)
+_USE_MKFS        0 (Disable f_mkfs function)
+_USE_FORWARD     0 (Disable f_forward function)
+_USE_FASTSEEK    0 (Disable fast seek feature)
+_CODE_PAGE       932 (Japanese Shift-JIS)
+_USE_LFN         0 (Disable LFN feature)
+_MAX_SS          512 (Fixed sector size)
+_FS_RPATH        0 (Disable relative path feature)
+_FS_LABEL        0 (Disable volume label functions)
+_VOLUMES         V (Number of logical drives to be used)
+_MULTI_PARTITION 0 (Single partition per drive)
+_FS_REENTRANT    0 (Disable thread safe)
+_FS_LOCK         0 (Disable file lock control)
+
+
+ +
+

Module Size Reduction

+

Follwing table shows which API function is removed by configuration options for the module size reduction.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_FS_LABEL_USE_MKFS_USE_FORWARD_MULTI_PARTITION
0123010  1/201201010101
f_mount
f_open
f_close
f_read
f_writex
f_syncx
f_lseekx
f_opendirxx
f_closedirxx
f_readdirxx
f_statxxx
f_getfreexxxx
f_truncatexxxx
f_unlinkxxxx
f_mkdirxxxx
f_chmodxxxx
f_utimexxxx
f_renamexxxx
f_chdirx
f_chdrivex
f_getcwdxx
f_getlabelx
f_setlabelxx
f_forwardx
f_mkfsxx
f_fdiskxxx
f_putcxx
f_putsxx
f_printfxx
f_getsx
+
+ +
+

Long File Name

+

FatFs module supports LFN (long file name). The two different file names, SFN (short file name) and LFN, of a file is transparent on the API except for f_readdir() function. The LFN feature is disabled by default. To enable it, set _USE_LFN to 1, 2 or 3, and add option/unicode.c to the project. The LFN feature requiers a certain working buffer in addition. The buffer size can be configured by _MAX_LFN according to the available memory. The length of an LFN will reach up to 255 characters, so that the _MAX_LFN should be set to 255 for full featured LFN operation. If the size of working buffer is insufficient for the input file name, the file function fails with FR_INVALID_NAME. When enable the LFN feature with re-entrant configuration, _USE_LFN must be set to 2 or 3. In this case, the file function allocates the working buffer on the stack or heap. The working buffer occupies (_MAX_LFN + 1) * 2 bytes.

+ + + + + + + + +
LFN cfg on ARM7TDMI
Code pageProgram size
SBCS+3.7K
932(Shift-JIS)+62K
936(GBK)+177K
949(Korean)+139K
950(Big5)+111K
+

When the LFN feature is enabled, the module size will be increased depends on the selected code page. Right table shows how many bytes increased when LFN feature is enabled with some code pages. Especially, in the CJK region, tens of thousands of characters are being used. Unfortunately, it requires a huge OEM-Unicode bidirectional conversion table and the module size will be drastically increased that shown in the table. As the result, the FatFs with LFN feature with those code pages will not able to be implemented to most 8-bit microcontrollers.

+

Note that the LFN feature on the FAT file system is a patent of Microsoft Corporation. This is not the case on FAT32 but most FAT32 drivers come with the LFN feature. FatFs can swich the LFN feature off by configuration option. When enable LFN feature on the commercial products, a license from Microsoft may be required depends on the final destination.

+
+ +
+

Unicode API

+

By default, FatFs uses ANSI/OEM code set on the API under LFN configuration. FatFs can also switch the character encoding to Unicode on the API by _LFN_UNICODE option. This means that the FatFs supports the True-LFN feature. For more information, refer to the description in the file name.

+
+ +
+

Re-entrancy

+

The file operations to the different volume is always re-entrant and can work simultaneously. The file operations to the same volume is not re-entrant but it can also be configured to thread-safe by _FS_REENTRANT option. In this case, also the OS dependent synchronization object control functions, ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant() and ff_rel_grant() must be added to the project. There are some examples in the option/syscall.c.

+

When a file function is called while the volume is in use by any other task, the file function is suspended until that task leaves the file function. If wait time exceeded a period defined by _TIMEOUT, the file function will abort with FR_TIMEOUT. The timeout feature might not be supported by some RTOS.

+

There is an exception for f_mount(), f_mkfs(), f_fdisk() function. These functions are not re-entrant to the same volume or corresponding physical drive. When use these functions, all other tasks must unmount the volume and avoid to access the volume.

+

Note that this section describes on the re-entrancy of the FatFs module itself but also the low level disk I/O layer will need to be re-entrant.

+
+ +
+

Duplicated File Access

+

FatFs module does not support the read/write collision control of duplicated open to a file. The duplicated open is permitted only when each of open method to a file is read mode. The duplicated open with one or more write mode to a file is always prohibited, and also open file must not be renamed and deleted. A violation of these rules can cause data colluption.

+

The file lock control can also be available by _FS_LOCK option. The value defines the number of open objects to manage simultaneously. In this case, if any open, rename or remove that violating the file shareing rule that described above is attempted, the file function will fail with FR_LOCKED. If number of open objects, files and sub-directories, gets larger than _FS_LOCK, the f_open(), f_optndir() function will fail with FR_TOO_MANY_OPEN_FILES.

+
+ +
+

Performance Effective File Access

+

For good read/write throughput on the small embedded systems with limited size of memory, application programmer should consider what process is done in the FatFs module. The file data on the volume is transferred in following sequence by f_read() function.

+

Figure 1. Sector misaligned read (short)
+ +

+

Figure 2. Sector misaligned read (long)
+ +

+

Figure 3. Fully sector aligned read
+ +

+

The file I/O buffer is a sector buffer to read/write a partial data on the sector. The sector buffer is either file private sector buffer on each file object or shared sector buffer in the file system object. The buffer configuration option _FS_TINY determins which sector buffer is used for the file data transfer. When tiny buffer (1) is selected, data memory consumption is reduced 512 bytes each file object. In this case, FatFs module uses only a sector buffer in the file system object for file data transfer and FAT/directory access. The disadvantage of the tiny buffer configuration is: the FAT data cached in the sector buffer will be lost by file data transfer and it must be reloaded at every cluster boundary. However it will be suitable for most application from view point of the decent performance and low memory comsumption.

+

Figure 1 shows that a partial sector, sector misaligned part of the file, is transferred via the file I/O buffer. At long data transfer shown in Figure 2, middle of transfer data that covers one or more sector is transferred to the application buffer directly. Figure 3 shows that the case of entier transfer data is aligned to the sector boundary. In this case, file I/O buffer is not used. On the direct transfer, the maximum extent of sectors are read with disk_read() function at a time but the multiple sector transfer is divided at cluster boundary even if it is contiguous.

+

Therefore taking effort to sector aligned read/write accesss eliminates buffered data transfer and the read/write performance will be improved. Besides the effect, cached FAT data will not be flushed by file data transfer at the tiny configuration, so that it can achieve same performance as non-tiny configuration with small memory footprint.

+
+ +
+

Considerations on Flash Memory Media

+

To maximize the write performance of flash memory media, such as SDC, CFC and U Disk, it must be controlled in consideration of its characteristitcs.

+

Using Mutiple-Sector Write

+
+Figure 6. Comparison between Multiple/Single Sector Write
+fig.6 +
+

The write throughput of the flash memory media becomes the worst at single sector write transaction. The write throughput increases as the number of sectors per a write transaction. This effect more appers at faster interface speed and the performance ratio often becomes grater than ten. This graph is clearly explaining how fast is multiple block write (W:16K, 32 sectors) than single block write (W:100, 1 sector), and also larger card tends to be slow at single block write. The number of write transactions also affects the life time of the flash memory media. Therefore the application program should write the data in large block as possible. The ideal write chunk size and alighment is size of sector, and size of cluster is the best. Of course all layers between the application and the storage device must have consideration on multiple sector write, however most of open-source disk drivers lack it. Do not split a multiple sector write request into single sector write transactions or the write throughput gets poor. Note that FatFs module and its sample disk drivers supprt multiple sector read/write feature.

+

Forcing Memory Erase

+

When remove a file with f_remove() function, the data clusters occupied by the file are marked 'free' on the FAT. But the data sectors containing the file data are not that applied any process, so that the file data left occupies a part of the flash memory array as 'live block'. If the file data is forced erased on removing the file, those data blocks will be turned in to the free block pool. This may skip internal block erase operation to the data block on next write operation. As the result the write performance might be improved. FatFs can manage this feature by setting _USE_ERASE to 1. Note that this is an expectation of internal process of the flash memory storage and not that always effective. Also f_remove() function will take a time when remove a large file. Most applications will not need this feature.

+
+ +
+

Critical Section

+

If a write operation to the FAT volume is interrupted due to any accidental failure, such as sudden blackout, incorrect disk removal and unrecoverable disk error, the FAT structure on the volume can be broken. Following images shows the critical section of the FatFs module.

+
+Figure 4. Long critical section
+fig.4 +
+
+Figure 5. Minimized critical section
+fig.5 +
+
+

An interruption in the red section can cause a cross link; as a result, the object being changed can be lost. If an interruption in the yellow section is occured, there is one or more possibility listed below.

+ +

Each case does not affect the files that not opened in write mode. To minimize risk of data loss, the critical section can be minimized by minimizing the time that file is opened in write mode or using f_sync() function as shown in Figure 5.

+
+ +
+

Extended Use of FatFs API

+

These are examples of extended use of FatFs APIs. New item will be added whenever a useful code is found.

+
    +
  1. Open or create a file for append
  2. +
  3. Empty a directory
  4. +
  5. Allocate contiguous area to the file
  6. +
  7. Function/Compatible checker for low level disk I/O module
  8. +
  9. FAT image creator
  10. +
+
+ +
+

About FatFs License

+

FatFs has being developped as a personal project of author, ChaN. It is free from the code anyone else wrote. Following code block shows a copy of the FatFs license document that included in the source files.

+
/*----------------------------------------------------------------------------/
+/  FatFs - FAT file system module  R0.10b                    (C)ChaN, 2014
+/-----------------------------------------------------------------------------/
+/ FatFs module is a generic FAT file system module for small embedded systems.
+/ This is a free software that opened for education, research and commercial
+/ developments under license policy of following trems.
+/
+/  Copyright (C) 2014, ChaN, all right reserved.
+/
+/ * The FatFs module is a free software and there is NO WARRANTY.
+/ * No restriction on use. You can use, modify and redistribute it for
+/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+/ * Redistributions of source code must retain the above copyright notice.
+/
+/-----------------------------------------------------------------------------/
+

Therefore FatFs license is one of the BSD-style licenses but there is a significant feature. Because FatFs is for embedded projects, the conditions of redistributions in binary form, such as embedded code, hex file, binary library or any forms without source code, are not specified in order to extend usability for commercial products. The documentation of the distributions need not include about FatFs and its license document, and it may also. This is equivalent to the BSD 1-Clause License. Of course FatFs is compatible with the projects under GNU GPL. When redistribute the FatFs with any modification or branch it as a folk, the license can also be changed to GNU GPL or BSD-style license.

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/chdir.html b/3rdparty/fatfs-0.10b/doc/en/chdir.html similarity index 96% rename from src/gfile/fatfs/doc/en/chdir.html rename to 3rdparty/fatfs-0.10b/doc/en/chdir.html index 063b8f56..64317707 100644 --- a/src/gfile/fatfs/doc/en/chdir.html +++ b/3rdparty/fatfs-0.10b/doc/en/chdir.html @@ -1,81 +1,81 @@ - - - - - - - - -FatFs - f_chdir - - - - -
-

f_chdir

-

The f_chdir function changes the current directory of a drive.

-
-FRESULT f_chdir (
-  const TCHAR* path /* [IN] Path name */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to the null-terminated string that specifies a directory to go.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_PATH, -FR_INVALID_NAME, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_chdir() function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.

-
- - -
-

QuickInfo

-

Available when _FS_RPATH >= 1.

-
- - -
-

Example

-
-    /* Change current direcoty of the current drive (dir1 under root dir) */
-    f_chdir("/dir1");
-
-    /* Change current direcoty of drive 2 (parent dir) */
-    f_chdir("2:..");
-
-
- -
-

See Also

-

f_chdrive, f_getcwd

-
- -

Return

- - + + + + + + + + +FatFs - f_chdir + + + + +
+

f_chdir

+

The f_chdir function changes the current directory of a drive.

+
+FRESULT f_chdir (
+  const TCHAR* path /* [IN] Path name */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to the null-terminated string that specifies a directory to go.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_PATH, +FR_INVALID_NAME, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_chdir() function changes the current directory of the logical drive. The current directory of a drive is initialized to the root directory when the drive is auto-mounted. Note that the current directory is retained in the each file system object so that it also affects other tasks that using the volume.

+
+ + +
+

QuickInfo

+

Available when _FS_RPATH >= 1.

+
+ + +
+

Example

+
+    /* Change current direcoty of the current drive (dir1 under root dir) */
+    f_chdir("/dir1");
+
+    /* Change current direcoty of drive 2 (parent dir) */
+    f_chdir("2:..");
+
+
+ +
+

See Also

+

f_chdrive, f_getcwd

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/chdrive.html b/3rdparty/fatfs-0.10b/doc/en/chdrive.html similarity index 96% rename from src/gfile/fatfs/doc/en/chdrive.html rename to 3rdparty/fatfs-0.10b/doc/en/chdrive.html index 665e5430..fdc15774 100644 --- a/src/gfile/fatfs/doc/en/chdrive.html +++ b/3rdparty/fatfs-0.10b/doc/en/chdrive.html @@ -1,60 +1,60 @@ - - - - - - - - -FatFs - f_chdrive - - - - -
-

f_chdrive

-

The f_chdrive function changes the current drive.

-
-FRESULT f_chdrive (
-  const TCHAR* path  /* [IN] Logical drive number */
-);
-
-
- -
-

Parameters

-
-
path
-
Specifies the logical drive number to be set as the current drive.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_INVALID_DRIVE -

-
- - -
-

Description

-

The f_chdrive() function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.

-
- -
-

QuickInfo

-

Available when _FS_RPATH >= 1 and _VOLUMES >= 2.

-
- - -
-

See Also

-

f_chdir, f_getcwd

-
- -

Return

- - + + + + + + + + +FatFs - f_chdrive + + + + +
+

f_chdrive

+

The f_chdrive function changes the current drive.

+
+FRESULT f_chdrive (
+  const TCHAR* path  /* [IN] Logical drive number */
+);
+
+
+ +
+

Parameters

+
+
path
+
Specifies the logical drive number to be set as the current drive.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_INVALID_DRIVE +

+
+ + +
+

Description

+

The f_chdrive() function changes the current drive. The initial value of the current drive number is 0. Note that the current drive is retained in a static variable so that it also affects other tasks that using the file functions.

+
+ +
+

QuickInfo

+

Available when _FS_RPATH >= 1 and _VOLUMES >= 2.

+
+ + +
+

See Also

+

f_chdir, f_getcwd

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/chmod.html b/3rdparty/fatfs-0.10b/doc/en/chmod.html similarity index 96% rename from src/gfile/fatfs/doc/en/chmod.html rename to 3rdparty/fatfs-0.10b/doc/en/chmod.html index 6d539746..755ff318 100644 --- a/src/gfile/fatfs/doc/en/chmod.html +++ b/3rdparty/fatfs-0.10b/doc/en/chmod.html @@ -1,89 +1,89 @@ - - - - - - - - -FatFs - f_chmod - - - - -
-

f_chmod

-

The f_chmod function changes the attribute of a file or sub-directory.

-
-FRESULT f_chmod (
-  const TCHAR* path, /* [IN] Object name */
-  BYTE attr,         /* [IN] Attribute flags */
-  BYTE mask          /* [IN] Attribute masks */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to the null-terminated string that specifies an object to be changed
-
attr
-
Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.
- - - - - - -
AttributeDescription
AM_RDORead only
AM_ARCArchive
AM_SYSSystem
AM_HIDHidden
-
-
mask
-
Attribute mask that specifies which attribute is changed. The specified attributes are set or cleard and others are left unchanged.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_chmod() function changes the attribute of a file or sub-directory.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

Example

-
-    /* Set read-only flag, clear archive flag and others are left unchanged. */
-    f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
-
-
- -

Return

- - + + + + + + + + +FatFs - f_chmod + + + + +
+

f_chmod

+

The f_chmod function changes the attribute of a file or sub-directory.

+
+FRESULT f_chmod (
+  const TCHAR* path, /* [IN] Object name */
+  BYTE attr,         /* [IN] Attribute flags */
+  BYTE mask          /* [IN] Attribute masks */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to the null-terminated string that specifies an object to be changed
+
attr
+
Attribute flags to be set in one or more combination of the following flags. The specified flags are set and others are cleard.
+ + + + + + +
AttributeDescription
AM_RDORead only
AM_ARCArchive
AM_SYSSystem
AM_HIDHidden
+
+
mask
+
Attribute mask that specifies which attribute is changed. The specified attributes are set or cleard and others are left unchanged.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_chmod() function changes the attribute of a file or sub-directory.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

Example

+
+    /* Set read-only flag, clear archive flag and others are left unchanged. */
+    f_chmod("file.txt", AR_RDO, AR_RDO | AR_ARC);
+
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/close.html b/3rdparty/fatfs-0.10b/doc/en/close.html similarity index 97% rename from src/gfile/fatfs/doc/en/close.html rename to 3rdparty/fatfs-0.10b/doc/en/close.html index f3423fa1..0746700b 100644 --- a/src/gfile/fatfs/doc/en/close.html +++ b/3rdparty/fatfs-0.10b/doc/en/close.html @@ -1,66 +1,66 @@ - - - - - - - - -FatFs - f_close - - - - -
-

f_close

-

The f_close function closes an open file.

-
-FRESULT f_close (
-  FIL* fp     /* [IN] Pointer to the file object */
-);
-
-
- -
-

Parameter

-
-
fp
-
Pointer to the open file object structure to be closed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_close() function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.

-

Note that if the file object is in read-only mode and _FS_LOCK option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.

-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, f_read, f_write, f_sync, FIL, FATFS

-
- -

Return

- - + + + + + + + + +FatFs - f_close + + + + +
+

f_close

+

The f_close function closes an open file.

+
+FRESULT f_close (
+  FIL* fp     /* [IN] Pointer to the file object */
+);
+
+
+ +
+

Parameter

+
+
fp
+
Pointer to the open file object structure to be closed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_close() function closes an open file object. If any data has been written to the file, the cached information of the file is written back to the volume. After the function succeeded, the file object is no longer valid and it can be discarded.

+

Note that if the file object is in read-only mode and _FS_LOCK option is not enabled, the file object can also be discarded without this process. However this is not recommended for future compatibility.

+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, f_read, f_write, f_sync, FIL, FATFS

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/closedir.html b/3rdparty/fatfs-0.10b/doc/en/closedir.html similarity index 96% rename from src/gfile/fatfs/doc/en/closedir.html rename to 3rdparty/fatfs-0.10b/doc/en/closedir.html index 4f97b6be..05ef6f69 100644 --- a/src/gfile/fatfs/doc/en/closedir.html +++ b/3rdparty/fatfs-0.10b/doc/en/closedir.html @@ -1,64 +1,64 @@ - - - - - - - - -FatFs - f_closedir - - - - -
-

f_closedir

-

The f_closedir function closes an open directory.

-
-FRESULT f_closedir (
-  DIR* dp     /* [IN] Pointer to the directory object */
-);
-
-
- -
-

Parameter

-
-
dp
-
Pointer to the open directory object structure to be closed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_INT_ERR, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_closedir() function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.

-

Note that the directory object can also be discarded without this process if _FS_LOCK option is not enabled. However this is not recommended for future compatibility.

-
- - -
-

QuickInfo

-

Available when _FS_MINIMIZE <= 1.

-
- - -
-

See Also

-

f_opendir, f_readdir, DIR

-
- -

Return

- - + + + + + + + + +FatFs - f_closedir + + + + +
+

f_closedir

+

The f_closedir function closes an open directory.

+
+FRESULT f_closedir (
+  DIR* dp     /* [IN] Pointer to the directory object */
+);
+
+
+ +
+

Parameter

+
+
dp
+
Pointer to the open directory object structure to be closed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_INT_ERR, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_closedir() function closes an open directory object. After the function succeeded, the directory object is no longer valid and it can be discarded.

+

Note that the directory object can also be discarded without this process if _FS_LOCK option is not enabled. However this is not recommended for future compatibility.

+
+ + +
+

QuickInfo

+

Available when _FS_MINIMIZE <= 1.

+
+ + +
+

See Also

+

f_opendir, f_readdir, DIR

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/dinit.html b/3rdparty/fatfs-0.10b/doc/en/dinit.html similarity index 97% rename from src/gfile/fatfs/doc/en/dinit.html rename to 3rdparty/fatfs-0.10b/doc/en/dinit.html index c22df47a..4675dd9b 100644 --- a/src/gfile/fatfs/doc/en/dinit.html +++ b/3rdparty/fatfs-0.10b/doc/en/dinit.html @@ -1,46 +1,46 @@ - - - - - - - - -FatFs - disk_initialize - - - - -
-

disk_initialize

-

The disk_initialize function initializes the storage device.

-
-DSTATUS disk_initialize (
-  BYTE pdrv           /* [IN] Physical drive number */
-);
-
-
- -
-

Parameter

-
-
pdrv
-
Physical drive number to identify the target device.
-
-
- - -
-

Return Values

-

This function returns a disk status as the result. For details of the disk status, refer to the disk_status() function.

-
- -
-

Description

-

This function initializes a storage device and put it ready to generic read/write data. When the function succeeded, STA_NOINIT flag in the return value is cleared.

-

Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use f_mount() function instead. This function is called at volume mount process by FatFs module to manage the media change.

-
- -

Return

- - + + + + + + + + +FatFs - disk_initialize + + + + +
+

disk_initialize

+

The disk_initialize function initializes the storage device.

+
+DSTATUS disk_initialize (
+  BYTE pdrv           /* [IN] Physical drive number */
+);
+
+
+ +
+

Parameter

+
+
pdrv
+
Physical drive number to identify the target device.
+
+
+ + +
+

Return Values

+

This function returns a disk status as the result. For details of the disk status, refer to the disk_status() function.

+
+ +
+

Description

+

This function initializes a storage device and put it ready to generic read/write data. When the function succeeded, STA_NOINIT flag in the return value is cleared.

+

Application program MUST NOT call this function, or FAT structure on the volume can be broken. To re-initialize the file system, use f_mount() function instead. This function is called at volume mount process by FatFs module to manage the media change.

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/dioctl.html b/3rdparty/fatfs-0.10b/doc/en/dioctl.html similarity index 98% rename from src/gfile/fatfs/doc/en/dioctl.html rename to 3rdparty/fatfs-0.10b/doc/en/dioctl.html index 8cd30af2..fec70c8b 100644 --- a/src/gfile/fatfs/doc/en/dioctl.html +++ b/3rdparty/fatfs-0.10b/doc/en/dioctl.html @@ -1,90 +1,90 @@ - - - - - - - - -FatFs - disk_ioctl - - - - -
-

disk_ioctl

-

The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.

-
-DRESULT disk_ioctl (
-  BYTE pdrv,     /* [IN] Drive number */
-  BYTE cmd,      /* [IN] Control command code */
-  void* buff     /* [I/O] Parameter and data buffer */
-);
-
-
- -
-

Parameters

-
-
pdrv
-
Physical drive number to identify the target device.
-
cmd
-
Command code.
-
buff
-
Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
An error occured.
-
RES_PARERR
-
The command code or parameter is invalid.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -
-

Description

-

The FatFs module requires only five device independent commands described below.

- - - - - - - - -
Standard ioctl command used by FatFs
CommandDescription
CTRL_SYNCMake sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the disk_write() function. Required at _FS_READONLY == 0.
GET_SECTOR_COUNTReturns number of available sectors on the drive into the DWORD variable pointed by buff. This command is used by only f_mkfs() and f_fdisk() function to determine the volume/partition size to be created. Required at _USE_MKFS == 1 or _MULTI_PARTITION == 1.
GET_SECTOR_SIZEReturns sector size of the media into the WORD variable pointed by buff. Valid return values of this command are 512, 1024, 2048 or 4096. This command is required at variable sector size configuration, _MAX_SS > _MIN_SS. Never used at fixed sector size configuration, _MAX_SS == _MIN_SS, and it must work at that sector size.
GET_BLOCK_SIZEReturns erase block size of the flash memory in unit of sector into the DWORD variable pointed by buff. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk media. This command is used by only f_mkfs() function and it attempts to align data area to the erase block boundary. Required at _USE_MKFS == 1.
CTRL_ERASE_SECTORInforms device that the data on the block of sectors specified by a DWORD array {<start sector>, <end sector>} pointed by buff is no longer needed and may be erased. The device would force erased the memory block. This is a command similar to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and f_mkfs() function. Required at _USE_ERASE == 1.
- -

FatFs never uses any device dependent command and user defined command. Following table shows an example of non-standard commands usable for some applications.

- - - - - - - - - - - - - - - - - -
Example of optional ioctl command
CommandDescription
CTRL_FORMATCreate a physical format on the media. If buff is not null, it is pointer to the call-back function for progress notification.
CTRL_POWER_IDLEPut the device idle state. STA_NOINIT in status flag may not be set if the device would go active state by generic read/write function.
CTRL_POWER_OFFPut the device off state. Shut-down the power to the device and deinitialize the device interface if needed. STA_NOINIT in status flag must be set. The device goes active state by disk_initialize() function.
CTRL_LOCKLock media eject mechanism.
CTRL_UNLOCKUnlock media eject mechanism.
CTRL_EJECTEject media cartridge. STA_NOINIT and STA_NODISK in status flag are set after the function succeeded.
MMC_GET_TYPEGet card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by buff. (MMC/SDC specific command)
MMC_GET_CSDGet CSD register into a 16-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_CIDGet CID register into a 16-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_OCRGet OCR register into a 4-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_SDSTATGet SDSTATUS register into a 64-byte buffer pointed by buff. (SDC specific command)
ATA_GET_REVGet the revision string into a 16-byte buffer pointed by buff. (ATA/CFC specific command)
ATA_GET_MODELGet the model string into a 40-byte buffer pointed by buff. (ATA/CFC specific command)
ATA_GET_SNGet the serial number string into a 20-byte buffer pointed by buff. (ATA/CFC specific command)
-
- -

Return

- - + + + + + + + + +FatFs - disk_ioctl + + + + +
+

disk_ioctl

+

The disk_ioctl function cntrols device specific features and miscellaneous functions other than generic read/write.

+
+DRESULT disk_ioctl (
+  BYTE pdrv,     /* [IN] Drive number */
+  BYTE cmd,      /* [IN] Control command code */
+  void* buff     /* [I/O] Parameter and data buffer */
+);
+
+
+ +
+

Parameters

+
+
pdrv
+
Physical drive number to identify the target device.
+
cmd
+
Command code.
+
buff
+
Pointer to the parameter depends on the command code. Do not care if no parameter to be passed.
+
+
+ + +
+

Return Value

+
+
RES_OK (0)
+
The function succeeded.
+
RES_ERROR
+
An error occured.
+
RES_PARERR
+
The command code or parameter is invalid.
+
RES_NOTRDY
+
The device has not been initialized.
+
+
+ + +
+

Description

+

The FatFs module requires only five device independent commands described below.

+ + + + + + + + +
Standard ioctl command used by FatFs
CommandDescription
CTRL_SYNCMake sure that the device has finished pending write process. If the disk I/O module has a write back cache, the dirty buffers must be written back to the media immediately. Nothing to do for this command if each write operation to the media is completed within the disk_write() function. Required at _FS_READONLY == 0.
GET_SECTOR_COUNTReturns number of available sectors on the drive into the DWORD variable pointed by buff. This command is used by only f_mkfs() and f_fdisk() function to determine the volume/partition size to be created. Required at _USE_MKFS == 1 or _MULTI_PARTITION == 1.
GET_SECTOR_SIZEReturns sector size of the media into the WORD variable pointed by buff. Valid return values of this command are 512, 1024, 2048 or 4096. This command is required at variable sector size configuration, _MAX_SS > _MIN_SS. Never used at fixed sector size configuration, _MAX_SS == _MIN_SS, and it must work at that sector size.
GET_BLOCK_SIZEReturns erase block size of the flash memory in unit of sector into the DWORD variable pointed by buff. The allowable value is from 1 to 32768 in power of 2. Return 1 if the erase block size is unknown or disk media. This command is used by only f_mkfs() function and it attempts to align data area to the erase block boundary. Required at _USE_MKFS == 1.
CTRL_ERASE_SECTORInforms device that the data on the block of sectors specified by a DWORD array {<start sector>, <end sector>} pointed by buff is no longer needed and may be erased. The device would force erased the memory block. This is a command similar to Trim command of ATA device. When this feature is not supported or not a flash memory media, nothing to do for this command. The FatFs does not check the result code and the file function is not affected even if the sectors ware not erased well. This command is called on removing a cluster chain and f_mkfs() function. Required at _USE_ERASE == 1.
+ +

FatFs never uses any device dependent command and user defined command. Following table shows an example of non-standard commands usable for some applications.

+ + + + + + + + + + + + + + + + + +
Example of optional ioctl command
CommandDescription
CTRL_FORMATCreate a physical format on the media. If buff is not null, it is pointer to the call-back function for progress notification.
CTRL_POWER_IDLEPut the device idle state. STA_NOINIT in status flag may not be set if the device would go active state by generic read/write function.
CTRL_POWER_OFFPut the device off state. Shut-down the power to the device and deinitialize the device interface if needed. STA_NOINIT in status flag must be set. The device goes active state by disk_initialize() function.
CTRL_LOCKLock media eject mechanism.
CTRL_UNLOCKUnlock media eject mechanism.
CTRL_EJECTEject media cartridge. STA_NOINIT and STA_NODISK in status flag are set after the function succeeded.
MMC_GET_TYPEGet card type. The type flags, bit0:MMCv3, bit1:SDv1, bit2:SDv2+ and bit3:LBA, is stored to a BYTE variable pointed by buff. (MMC/SDC specific command)
MMC_GET_CSDGet CSD register into a 16-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_CIDGet CID register into a 16-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_OCRGet OCR register into a 4-byte buffer pointed by buff. (MMC/SDC specific command)
MMC_GET_SDSTATGet SDSTATUS register into a 64-byte buffer pointed by buff. (SDC specific command)
ATA_GET_REVGet the revision string into a 16-byte buffer pointed by buff. (ATA/CFC specific command)
ATA_GET_MODELGet the model string into a 40-byte buffer pointed by buff. (ATA/CFC specific command)
ATA_GET_SNGet the serial number string into a 20-byte buffer pointed by buff. (ATA/CFC specific command)
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/dread.html b/3rdparty/fatfs-0.10b/doc/en/dread.html similarity index 97% rename from src/gfile/fatfs/doc/en/dread.html rename to 3rdparty/fatfs-0.10b/doc/en/dread.html index f81cf906..3f9bc039 100644 --- a/src/gfile/fatfs/doc/en/dread.html +++ b/3rdparty/fatfs-0.10b/doc/en/dread.html @@ -1,71 +1,71 @@ - - - - - - - - -FatFs - disk_read - - - - -
-

disk_read

-

The disk_read function reads sector(s) from the storage device.

-
-DRESULT disk_read (
-  BYTE pdrv,     /* [IN] Physical drive number */
-  BYTE* buff,    /* [OUT] Pointer to the read data buffer */
-  DWORD sector,  /* [IN] Start sector number */
-  UINT count     /* [IN] Number of sectros to read */
-);
-
-
- -
-

Parameters

-
-
pdrv
-
Physical drive number to identify the target device.
-
buff
-
Pointer to the byte array to store the read data.
-
sector
-
Start sector number in logical block address (LBA).
-
count
-
Number of sectors to read. FatFs specifis it in range of from 1 to 128.
-
-
- - -
-

Return Value

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the read operation and could not recover it.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -
-

Description

-

The memory address specified by buff is not that always aligned to word boundary because the type of argument is defined as BYTE*. The misaligned read/write request can occure at direct transfer. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.

- -

Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.

-
- - -

Return

- - + + + + + + + + +FatFs - disk_read + + + + +
+

disk_read

+

The disk_read function reads sector(s) from the storage device.

+
+DRESULT disk_read (
+  BYTE pdrv,     /* [IN] Physical drive number */
+  BYTE* buff,    /* [OUT] Pointer to the read data buffer */
+  DWORD sector,  /* [IN] Start sector number */
+  UINT count     /* [IN] Number of sectros to read */
+);
+
+
+ +
+

Parameters

+
+
pdrv
+
Physical drive number to identify the target device.
+
buff
+
Pointer to the byte array to store the read data.
+
sector
+
Start sector number in logical block address (LBA).
+
count
+
Number of sectors to read. FatFs specifis it in range of from 1 to 128.
+
+
+ + +
+

Return Value

+
+
RES_OK (0)
+
The function succeeded.
+
RES_ERROR
+
Any hard error occured during the read operation and could not recover it.
+
RES_PARERR
+
Invalid parameter.
+
RES_NOTRDY
+
The device has not been initialized.
+
+
+ + +
+

Description

+

The memory address specified by buff is not that always aligned to word boundary because the type of argument is defined as BYTE*. The misaligned read/write request can occure at direct transfer. If the bus architecture, especially DMA controller, does not allow misaligned memory access, it should be solved in this function. There are some workarounds described below to avoid this issue.

+ +

Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will not get good read throughput.

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/dstat.html b/3rdparty/fatfs-0.10b/doc/en/dstat.html similarity index 97% rename from src/gfile/fatfs/doc/en/dstat.html rename to 3rdparty/fatfs-0.10b/doc/en/dstat.html index 5ae2775e..d2b0242b 100644 --- a/src/gfile/fatfs/doc/en/dstat.html +++ b/3rdparty/fatfs-0.10b/doc/en/dstat.html @@ -1,48 +1,48 @@ - - - - - - - - -FatFs - disk_status - - - - -
-

disk_status

-

The disk_status function returns the current disk status.

-
-DSTATUS disk_status (
-  BYTE pdrv     /* [IN] Physical drive number */
-);
-
-
- -
-

Parameter

-
-
pdrv
-
Physical drive number to identify the target device.
-
-
- - -
-

Return Values

-

The disk status is returned in combination of following flags. FatFs refers only STA_NOINIT and STA_PROTECT.

-
-
STA_NOINIT
-
Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of disk_initialize() function. It is cleared on disk_initialize() function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with f_mount() function after the media change.
-
STA_NODISK
-
Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.
-
STA_PROTECT
-
Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid while no medium in the drive.
-
-
- -

Return

- - + + + + + + + + +FatFs - disk_status + + + + +
+

disk_status

+

The disk_status function returns the current disk status.

+
+DSTATUS disk_status (
+  BYTE pdrv     /* [IN] Physical drive number */
+);
+
+
+ +
+

Parameter

+
+
pdrv
+
Physical drive number to identify the target device.
+
+
+ + +
+

Return Values

+

The disk status is returned in combination of following flags. FatFs refers only STA_NOINIT and STA_PROTECT.

+
+
STA_NOINIT
+
Indicates that the device is not initialized. This flag is set on system reset, media removal or failure of disk_initialize() function. It is cleared on disk_initialize() function succeeded. Media change that occurs asynchronously must be captured and reflect it to the status flags, or auto-mount feature will not work correctly. When media change detection feature is not supported, application program needs to de-initialize the file system object with f_mount() function after the media change.
+
STA_NODISK
+
Indicates that no medium in the drive. This is always cleared on fixed disk drive. Note that FatFs does not refer this flag.
+
STA_PROTECT
+
Indicates that the medium is write protected. This is always cleared on the drives without write protect feature. Not valid while no medium in the drive.
+
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/dwrite.html b/3rdparty/fatfs-0.10b/doc/en/dwrite.html similarity index 92% rename from src/gfile/fatfs/doc/en/dwrite.html rename to 3rdparty/fatfs-0.10b/doc/en/dwrite.html index a99f6019..616acf68 100644 --- a/src/gfile/fatfs/doc/en/dwrite.html +++ b/3rdparty/fatfs-0.10b/doc/en/dwrite.html @@ -1,76 +1,76 @@ - - - - - - - - -FatFs - disk_write - - - - -
-

disk_write

-

The disk_write writes sector(s) to the storage device.

-
-DRESULT disk_write (
-  BYTE drv,         /* [IN] Physical drive number */
-  const BYTE* buff, /* [IN] Pointer to the data to be written */
-  DWORD sector,     /* [IN] Sector number to write from */
-  UINT count        /* [IN] Number of sectors to write */
-);
-
-
- -
-

Parameters

-
-
pdrv
-
Physical drive number to identify the target device.
-
buff
-
Pointer to the byte array to be written. The size of data to be written is sector size * count bytes.
-
sector
-
Start sector number in logical block address (LBA).
-
count
-
Number of sectors to write. FatFs specifis it in range of from 1 to 128.
-
-
- - -
-

Return Values

-
-
RES_OK (0)
-
The function succeeded.
-
RES_ERROR
-
Any hard error occured during the write operation and could not recover it.
-
RES_WRPRT
-
The medium is write protected.
-
RES_PARERR
-
Invalid parameter.
-
RES_NOTRDY
-
The device has not been initialized.
-
-
- - -
-

Description

-

The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE. For more information, refer to the description of disk_read() function.

-

Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.

-

FatFs expects delayed write feature of the disk functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But data on the buff is invalid after return from this function. The write completion request is done by CTRL_SYNC command of disk_ioctl() function. Therefore, if delayed write feature is implemented, the write throughput may be improved.

-

Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.

-
- - -
-

QuickInfo

-

This function is not needed when _FS_READONLY == 1.

-
- - -

Return

- - + + + + + + + + +FatFs - disk_write + + + + +
+

disk_write

+

The disk_write writes sector(s) to the storage device.

+
+DRESULT disk_write (
+  BYTE drv,         /* [IN] Physical drive number */
+  const BYTE* buff, /* [IN] Pointer to the data to be written */
+  DWORD sector,     /* [IN] Sector number to write from */
+  UINT count        /* [IN] Number of sectors to write */
+);
+
+
+ +
+

Parameters

+
+
pdrv
+
Physical drive number to identify the target device.
+
buff
+
Pointer to the byte array to be written. The size of data to be written is sector size * count bytes.
+
sector
+
Start sector number in logical block address (LBA).
+
count
+
Number of sectors to write. FatFs specifis it in range of from 1 to 128.
+
+
+ + +
+

Return Values

+
+
RES_OK (0)
+
The function succeeded.
+
RES_ERROR
+
Any hard error occured during the write operation and could not recover it.
+
RES_WRPRT
+
The medium is write protected.
+
RES_PARERR
+
Invalid parameter.
+
RES_NOTRDY
+
The device has not been initialized.
+
+
+ + +
+

Description

+

The specified memory address is not that always aligned to word boundary because the type of pointer is defined as BYTE*. For more information, refer to the description of disk_read() function.

+

Generally, a multiple sector transfer request must not be split into single sector transactions to the storage device, or you will never get good write throughput.

+

FatFs expects delayed write feature of the disk functions. The write operation to the media need not to be completed due to write operation is in progress or only stored it into the cache buffer when return from this function. But data on the buff is invalid after return from this function. The write completion request is done by CTRL_SYNC command of disk_ioctl() function. Therefore, if delayed write feature is implemented, the write throughput may be improved.

+

Application program MUST NOT call this function, or FAT structure on the volume can be collapsed.

+
+ + +
+

QuickInfo

+

This function is not needed when _FS_READONLY == 1.

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/eof.html b/3rdparty/fatfs-0.10b/doc/en/eof.html similarity index 96% rename from src/gfile/fatfs/doc/en/eof.html rename to 3rdparty/fatfs-0.10b/doc/en/eof.html index 384c8d88..9501b094 100644 --- a/src/gfile/fatfs/doc/en/eof.html +++ b/3rdparty/fatfs-0.10b/doc/en/eof.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_eof - - - - -
-

f_eof

-

The f_eof function tests for end-of-file on a file.

-
-int f_eof (
-  FIL* fp   /* [IN] File object */
-);
-
-
- - -
-

Parameters

-
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Values

-

The f_eof() function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.

-
- - -
-

Description

-

In this revision, this function is implemented as a macro.

-
-#define f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
-
-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, f_lseek, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_eof + + + + +
+

f_eof

+

The f_eof function tests for end-of-file on a file.

+
+int f_eof (
+  FIL* fp   /* [IN] File object */
+);
+
+
+ + +
+

Parameters

+
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Values

+

The f_eof() function returns a non-zero value if the read/write pointer has reached end of the file; otherwise it returns a zero.

+
+ + +
+

Description

+

In this revision, this function is implemented as a macro.

+
+#define f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
+
+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, f_lseek, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/error.html b/3rdparty/fatfs-0.10b/doc/en/error.html similarity index 96% rename from src/gfile/fatfs/doc/en/error.html rename to 3rdparty/fatfs-0.10b/doc/en/error.html index 7405d9e0..2a875189 100644 --- a/src/gfile/fatfs/doc/en/error.html +++ b/3rdparty/fatfs-0.10b/doc/en/error.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_error - - - - -
-

f_error

-

The f_error tests for an error on a file.

-
-int f_error (
-  FIL* fp   /* [IN] File object */
-);
-
-
- - -
-

Parameters

-
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Values

-

Returns a non-zero value if a hard error has occured; otherwise it returns a zero.

-
- - -
-

Description

-

In this revision, this function is implemented as a macro.

-
-#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
-
-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_error + + + + +
+

f_error

+

The f_error tests for an error on a file.

+
+int f_error (
+  FIL* fp   /* [IN] File object */
+);
+
+
+ + +
+

Parameters

+
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Values

+

Returns a non-zero value if a hard error has occured; otherwise it returns a zero.

+
+ + +
+

Description

+

In this revision, this function is implemented as a macro.

+
+#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
+
+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/fattime.html b/3rdparty/fatfs-0.10b/doc/en/fattime.html similarity index 96% rename from src/gfile/fatfs/doc/en/fattime.html rename to 3rdparty/fatfs-0.10b/doc/en/fattime.html index d8c245ec..1736e87f 100644 --- a/src/gfile/fatfs/doc/en/fattime.html +++ b/3rdparty/fatfs-0.10b/doc/en/fattime.html @@ -1,57 +1,57 @@ - - - - - - - - -FatFs - get_fattime - - - - -
-

get_fattime

-

The get_fattime function gets current time.

-
-DWORD get_fattime (void);
-
-
- - -
-

Return Value

-

Currnet time is returned with packed into a DWORD value. The bit field is as follows:

-
-
bit31:25
-
Year origin from the 1980 (0..127)
-
bit24:21
-
Month (1..12)
-
bit20:16
-
Day of the month(1..31)
-
bit15:11
-
Hour (0..23)
-
bit10:5
-
Minute (0..59)
-
bit4:0
-
Second / 2 (0..29)
-
-
- - -
-

Description

-

The get_fattime() function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.

-
- - -
-

QuickInfo

-

This function is not needed when _FS_READONLY == 1.

-
- - -

Return

- - + + + + + + + + +FatFs - get_fattime + + + + +
+

get_fattime

+

The get_fattime function gets current time.

+
+DWORD get_fattime (void);
+
+
+ + +
+

Return Value

+

Currnet time is returned with packed into a DWORD value. The bit field is as follows:

+
+
bit31:25
+
Year origin from the 1980 (0..127)
+
bit24:21
+
Month (1..12)
+
bit20:16
+
Day of the month(1..31)
+
bit15:11
+
Hour (0..23)
+
bit10:5
+
Minute (0..59)
+
bit4:0
+
Second / 2 (0..29)
+
+
+ + +
+

Description

+

The get_fattime() function shall return any valid time even if the system does not support a real time clock. If a zero is returned, the file will not have a valid timestamp.

+
+ + +
+

QuickInfo

+

This function is not needed when _FS_READONLY == 1.

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/fdisk.html b/3rdparty/fatfs-0.10b/doc/en/fdisk.html similarity index 97% rename from src/gfile/fatfs/doc/en/fdisk.html rename to 3rdparty/fatfs-0.10b/doc/en/fdisk.html index ad4e4fd6..40e5e4b3 100644 --- a/src/gfile/fatfs/doc/en/fdisk.html +++ b/3rdparty/fatfs-0.10b/doc/en/fdisk.html @@ -1,97 +1,97 @@ - - - - - - - - -FatFs - f_fdisk - - - - -
-

f_fdisk

-

The f_fdisk fucntion divides a physical drive.

-
-FRESULT f_fdisk (
-  BYTE  pdrv,         /* [IN] Physical drive number */
-  const DWORD part[], /* [IN] Partition size */
-  void* work          /* [IN] Work area */
-);
-
-
- -
-

Parameters

-
-
pdrv
-
Specifies the physical drive to be divided.
-
part[]
-
Partition map table. It must have four items.
-
work
-
Pointer to the function work area. The size must be at least _MAX_SS bytes.
-
-
- -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_NOT_READY, -FR_WRITE_PROTECTED, -FR_INVALID_PARAMETER -

-
- -
-

Description

-

The f_fdisk() function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The part[] with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.

-
- -
-

QuickInfo

-

Available when _FS_READOLNY == 0, _USE_MKFS == 1 and _MULTI_PARTITION == 1.

-
- -
-

Example

-
-    /* Volume management table defined by user (required when _MULTI_PARTITION == 1) */
-
-    PARTITION VolToPart[] = {
-        {0, 1},    /* Logical drive 0 ==> Physical drive 0, 1st partition */
-        {0, 2},    /* Logical drive 1 ==> Physical drive 0, 2nd partition */
-        {1, 0}     /* Logical drive 2 ==> Physical drive 1, auto detection */
-    };
-
-
-    /* Initialize a brand-new disk drive mapped to physical drive 0 */
-
-    FATFS fs;
-    DWORD plist[] = {50, 50, 0, 0};  /* Divide drive into two partitions */
-    BYTE work[_MAX_SS];
-
-    f_fdisk(0, plist, work);    /* Divide physical drive 0 */
-
-    f_mount(&fs, "0:", 0);      /* Register work area to the logical drive 0 */
-    f_mkfs("0:", 0, 0);         /* Create FAT volume on the logical drive 0. 2nd argument is ignored. */
-    f_mount(0, "0:", 0);        /* Unregister work area from the logical drive 0 */
-
-    f_mount(&fs, "1:", 0);      /* Register a work area to the logical drive 1 */
-    f_mkfs("1:", 0, 0);         /* Create FAT volume on the logical drive 1. 2nd argument is ignored. */
-    f_mount(0, "1:", 0);        /* Unregister work area from the logical drive 1 */
-
-
-
- -
-

See Also

-

Volume management, f_mkfs

-
- -

Return

- - + + + + + + + + +FatFs - f_fdisk + + + + +
+

f_fdisk

+

The f_fdisk fucntion divides a physical drive.

+
+FRESULT f_fdisk (
+  BYTE  pdrv,         /* [IN] Physical drive number */
+  const DWORD part[], /* [IN] Partition size */
+  void* work          /* [IN] Work area */
+);
+
+
+ +
+

Parameters

+
+
pdrv
+
Specifies the physical drive to be divided.
+
part[]
+
Partition map table. It must have four items.
+
work
+
Pointer to the function work area. The size must be at least _MAX_SS bytes.
+
+
+ +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_NOT_READY, +FR_WRITE_PROTECTED, +FR_INVALID_PARAMETER +

+
+ +
+

Description

+

The f_fdisk() function creates a partition table into the MBR of the physical drive. The partitioning rule is in generic FDISK format, so that it can create upto four primary partitions. Logical volumes in the extended partition is not supported. The part[] with four items specifies how to divide the physical drive. The first item specifies the size of first primary partition and fourth item specifies the fourth primary partition. If the value is less than or equal to 100, it specifies percentage of the partition in the entire disk space. If it is larger than 100, it specifies the partition size in unit of sector.

+
+ +
+

QuickInfo

+

Available when _FS_READOLNY == 0, _USE_MKFS == 1 and _MULTI_PARTITION == 1.

+
+ +
+

Example

+
+    /* Volume management table defined by user (required when _MULTI_PARTITION == 1) */
+
+    PARTITION VolToPart[] = {
+        {0, 1},    /* Logical drive 0 ==> Physical drive 0, 1st partition */
+        {0, 2},    /* Logical drive 1 ==> Physical drive 0, 2nd partition */
+        {1, 0}     /* Logical drive 2 ==> Physical drive 1, auto detection */
+    };
+
+
+    /* Initialize a brand-new disk drive mapped to physical drive 0 */
+
+    FATFS fs;
+    DWORD plist[] = {50, 50, 0, 0};  /* Divide drive into two partitions */
+    BYTE work[_MAX_SS];
+
+    f_fdisk(0, plist, work);    /* Divide physical drive 0 */
+
+    f_mount(&fs, "0:", 0);      /* Register work area to the logical drive 0 */
+    f_mkfs("0:", 0, 0);         /* Create FAT volume on the logical drive 0. 2nd argument is ignored. */
+    f_mount(0, "0:", 0);        /* Unregister work area from the logical drive 0 */
+
+    f_mount(&fs, "1:", 0);      /* Register a work area to the logical drive 1 */
+    f_mkfs("1:", 0, 0);         /* Create FAT volume on the logical drive 1. 2nd argument is ignored. */
+    f_mount(0, "1:", 0);        /* Unregister work area from the logical drive 1 */
+
+
+
+ +
+

See Also

+

Volume management, f_mkfs

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/filename.html b/3rdparty/fatfs-0.10b/doc/en/filename.html similarity index 98% rename from src/gfile/fatfs/doc/en/filename.html rename to 3rdparty/fatfs-0.10b/doc/en/filename.html index 1209947f..22c87988 100644 --- a/src/gfile/fatfs/doc/en/filename.html +++ b/3rdparty/fatfs-0.10b/doc/en/filename.html @@ -1,78 +1,78 @@ - - - - - - - - -FatFs - Path Names - - - -

Path Names

- -
-

Format of the path names

-

The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:

-
"[drive:][/]directory/file"
-

The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (_USE_LFN > 0). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as default drive (drive 0 or current drive).

-

Control characters ('\0' to '\x1F') are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.

-

In default configuration (_FS_RPATH == 0), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.

-

When relative path feature is enabled (_FS_RPATH == 1), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set with f_chdir function. Dot names are also allowed for the path name. The default drive is the current drive set with f_chdrive function.

- - - - - - - - - - - - - - -
Path name_FS_RPATH == 0_FS_RPATH == 1
file.txtA file in the root directory of the drive 0A file in the current directory of the current drive
/file.txtA file in the root directory of the drive 0A file in the root directory of the current drive
The root directory of the drive 0The current directory of the current drive
/The root directory of the drive 0The root directory of the current drive
2:The root directory of the drive 2The current directory of the drive 2
2:/The root directory of the drive 2The root directory of the drive 2
2:file.txtA file in the root directory of the drive 2A file in the current directory of the drive 2
../file.txtInvalid nameA file in the parent directory
.Invalid nameThis directory
..Invalid nameParent directory of the current directory
dir1/..Invalid nameThe current directory
/..Invalid nameThe root directory (sticks the top level)
-

When option _STR_VOLUME_ID is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral.

-
- -


-
-

Unicode API

-

The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments which specify the file names are defined as TCHAR. It is an alias of char in default. The code set used to the file name string is ANSI/OEM specifid by _CODE_PAGE. When _LFN_UNICODE is set to 1, the type of the TCHAR is switched to WCHAR to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, _T(s) and _TEXT(s) macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.

-
- f_open(fp, "filename.txt", FA_READ);      /* ANSI/OEM string */
- f_open(fp, L"filename.txt", FA_READ);     /* Unicode string */
- f_open(fp, _T("filename.txt"), FA_READ);  /* Changed by configuration */
-
-
- -


-
-

Volume Management

-

The FatFs module needs dynamic work area called file system object for each volume (logical drive). It is registered to the FatFs module by f_mount() function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.

-

When _MULTI_PARTITION == 1 is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve relationship between logical drives and partitions. Following code is an example of a volume management table.

-
-Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
-         Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
-
-PARTITION VolToPart[] = {
-    {0, 1},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
-    {0, 2},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
-    {0, 3},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
-    {1, 0}      /* Logical drive 3 ==> Physical drive 1 (auto detection) */
-};
-
-relationship between logical drive and physical drive
-
-

There are some considerations on using _MULTI_PARTITION configuration.

- -
- - - + + + + + + + + +FatFs - Path Names + + + +

Path Names

+ +
+

Format of the path names

+

The format of path name on the FatFs module is similer to the filename specs of DOS/Windos as follows:

+
"[drive:][/]directory/file"
+

The FatFs module supports long file name (LFN) and 8.3 format file name (SFN). The LFN can be used when LFN feature is enabled (_USE_LFN > 0). The sub directories are separated with a \ or / in the same way as DOS/Windows API. Duplicated separators are skipped and ignored. Only a difference is that the logical drive is specified in a numeral with a colon. When drive number is omitted, the drive number is assumed as default drive (drive 0 or current drive).

+

Control characters ('\0' to '\x1F') are recognized as end of the path name. Leading/embedded spaces in the path name are valid as a part of the name at LFN configuration but they are recognized as end of the path name at non-LFN configuration. Trailing spaces and dots are ignored.

+

In default configuration (_FS_RPATH == 0), it does not have a concept of current directory like OS oriented file system. All objects on the volume are always specified in full path name that follows from the root directory. Dot directory names are not allowed. Heading separator is ignored and it can be exist or omitted. The default drive is fixed to drive 0.

+

When relative path feature is enabled (_FS_RPATH == 1), specified path is followed from the root directory if a heading separator is exist. If not, it is followed from the current directory of the drive set with f_chdir function. Dot names are also allowed for the path name. The default drive is the current drive set with f_chdrive function.

+ + + + + + + + + + + + + + +
Path name_FS_RPATH == 0_FS_RPATH == 1
file.txtA file in the root directory of the drive 0A file in the current directory of the current drive
/file.txtA file in the root directory of the drive 0A file in the root directory of the current drive
The root directory of the drive 0The current directory of the current drive
/The root directory of the drive 0The root directory of the current drive
2:The root directory of the drive 2The current directory of the drive 2
2:/The root directory of the drive 2The root directory of the drive 2
2:file.txtA file in the root directory of the drive 2A file in the current directory of the drive 2
../file.txtInvalid nameA file in the parent directory
.Invalid nameThis directory
..Invalid nameParent directory of the current directory
dir1/..Invalid nameThe current directory
/..Invalid nameThe root directory (sticks the top level)
+

When option _STR_VOLUME_ID is specified, also pre-defined strings can be used as drive identifier in the path name instead of a numeral.

+
+ +


+
+

Unicode API

+

The path names are input/output in either ANSI/OEM code (SBCS/DBCS) or Unicode depends on the configuration options. The type of arguments which specify the file names are defined as TCHAR. It is an alias of char in default. The code set used to the file name string is ANSI/OEM specifid by _CODE_PAGE. When _LFN_UNICODE is set to 1, the type of the TCHAR is switched to WCHAR to support Unicode (UTF-16 encoding). In this case, the LFN feature is fully supported and the Unicode specific characters, such as ✝☪✡☸☭, can also be used for the path name. It also affects data types and encoding of the string I/O functions. To define literal strings, _T(s) and _TEXT(s) macro are available to select either ANSI/OEM or Unicode automatically. The code shown below is an example to define the literal strings.

+
+ f_open(fp, "filename.txt", FA_READ);      /* ANSI/OEM string */
+ f_open(fp, L"filename.txt", FA_READ);     /* Unicode string */
+ f_open(fp, _T("filename.txt"), FA_READ);  /* Changed by configuration */
+
+
+ +


+
+

Volume Management

+

The FatFs module needs dynamic work area called file system object for each volume (logical drive). It is registered to the FatFs module by f_mount() function. By default, each logical drive is bound to the physical drive with the same drive number and an FAT volume on the drive is serched by auto detect feature. It loads boot sectors and checks it if it is an FAT boot sector in order of sector 0 as SFD format, 1st partition, 2nd partition, 3rd partition and 4th partition as FDISK format.

+

When _MULTI_PARTITION == 1 is specified by configuration option, each individual logical drive is bound to the partition on the physical drive specified by volume management table. The volume management table must be defined by user to resolve relationship between logical drives and partitions. Following code is an example of a volume management table.

+
+Example: Logical drive 0-2 are tied to three pri-partitions on the physical drive 0 (fixed disk)
+         Logical drive 3 is tied to an FAT volume on the physical drive 1 (removable disk)
+
+PARTITION VolToPart[] = {
+    {0, 1},     /* Logical drive 0 ==> Physical drive 0, 1st partition */
+    {0, 2},     /* Logical drive 1 ==> Physical drive 0, 2nd partition */
+    {0, 3},     /* Logical drive 2 ==> Physical drive 0, 3rd partition */
+    {1, 0}      /* Logical drive 3 ==> Physical drive 1 (auto detection) */
+};
+
+relationship between logical drive and physical drive
+
+

There are some considerations on using _MULTI_PARTITION configuration.

+ +
+ + + diff --git a/src/gfile/fatfs/doc/en/forward.html b/3rdparty/fatfs-0.10b/doc/en/forward.html similarity index 97% rename from src/gfile/fatfs/doc/en/forward.html rename to 3rdparty/fatfs-0.10b/doc/en/forward.html index 714c48d1..68b84e63 100644 --- a/src/gfile/fatfs/doc/en/forward.html +++ b/3rdparty/fatfs-0.10b/doc/en/forward.html @@ -1,139 +1,139 @@ - - - - - - - - -FatFs - f_forward - - - - -
-

f_forward

-

The f_forward function reads the file data and forward it to the data streaming device.

-
-FRESULT f_forward (
-  FIL* fp,                        /* [IN] File object */
-  UINT (*func)(const BYTE*,UINT), /* [IN] Data streaming function */
-  UINT btf,                       /* [IN] Number of bytes to forward */
-  UINT* bf                        /* [OUT] Number of bytes forwarded */
-);
-
-
- -
-

Parameters

-
-
fp
-
Pointer to the open file object.
-
func
-
Pointer to the user-defined data streaming function. For details, refer to the sample code.
-
btf
-
Number of bytes to forward in range of UINT.
-
bf
-
Pointer to the UINT variable to return number of bytes forwarded.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_forward() function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of *bf is less than btf without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.

-
- - -
-

QuickInfo

-

Available when _USE_FORWARD == 1 and _FS_TINY == 1.

-
- - -
-

Example (Audio playback)

-
-/*------------------------------------------------------------------------*/
-/* Sample code of data transfer function to be called back from f_forward */
-/*------------------------------------------------------------------------*/
-
-UINT out_stream (   /* Returns number of bytes sent or stream status */
-    const BYTE *p,  /* Pointer to the data block to be sent */
-    UINT btf        /* >0: Transfer call (Number of bytes to be sent). 0: Sense call */
-)
-{
-    UINT cnt = 0;
-
-
-    if (btf == 0) {     /* Sense call */
-        /* Return stream status (0: Busy, 1: Ready) */
-        /* When once it returned ready to sense call, it must accept a byte at least */
-        /* at subsequent transfer call, or f_forward will fail with FR_INT_ERR. */
-        if (FIFO_READY) cnt = 1;
-    }
-    else {              /* Transfer call */
-        do {    /* Repeat while there is any data to be sent and the stream is ready */
-            FIFO_PORT = *p++;
-            cnt++;
-        } while (cnt < btf && FIFO_READY);
-    }
-
-    return cnt;
-}
-
-
-/*------------------------------------------------------------------------*/
-/* Sample code using f_forward function                                   */
-/*------------------------------------------------------------------------*/
-
-FRESULT play_file (
-    char *fn        /* Pointer to the audio file name to be played */
-)
-{
-    FRESULT rc;
-    FIL fil;
-    UINT dmy;
-
-    /* Open the audio file in read only mode */
-    rc = f_open(&fil, fn, FA_READ);
-    if (rc) return rc;
-
-    /* Repeat until the file pointer reaches end of the file */
-    while (rc == FR_OK && fil.fptr < fil.fsize) {
-
-        /* any other processes... */
-
-        /* Fill output stream periodicaly or on-demand */
-        rc = f_forward(&fil, out_stream, 1000, &dmy);
-    }
-
-    /* Close the file and return */
-    f_close(&fil);
-    return rc;
-}
-
-
- - -
-

See Also

-

f_open, fgets, f_write, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_forward + + + + +
+

f_forward

+

The f_forward function reads the file data and forward it to the data streaming device.

+
+FRESULT f_forward (
+  FIL* fp,                        /* [IN] File object */
+  UINT (*func)(const BYTE*,UINT), /* [IN] Data streaming function */
+  UINT btf,                       /* [IN] Number of bytes to forward */
+  UINT* bf                        /* [OUT] Number of bytes forwarded */
+);
+
+
+ +
+

Parameters

+
+
fp
+
Pointer to the open file object.
+
func
+
Pointer to the user-defined data streaming function. For details, refer to the sample code.
+
btf
+
Number of bytes to forward in range of UINT.
+
bf
+
Pointer to the UINT variable to return number of bytes forwarded.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_forward() function reads the data from the file and forward it to the outgoing stream without data buffer. This is suitable for small memory system because it does not require any data buffer at application module. The file pointer of the file object increases in number of bytes forwarded. In case of *bf is less than btf without error, it means the requested bytes could not be transferred due to end of file or stream goes busy during data transfer.

+
+ + +
+

QuickInfo

+

Available when _USE_FORWARD == 1 and _FS_TINY == 1.

+
+ + +
+

Example (Audio playback)

+
+/*------------------------------------------------------------------------*/
+/* Sample code of data transfer function to be called back from f_forward */
+/*------------------------------------------------------------------------*/
+
+UINT out_stream (   /* Returns number of bytes sent or stream status */
+    const BYTE *p,  /* Pointer to the data block to be sent */
+    UINT btf        /* >0: Transfer call (Number of bytes to be sent). 0: Sense call */
+)
+{
+    UINT cnt = 0;
+
+
+    if (btf == 0) {     /* Sense call */
+        /* Return stream status (0: Busy, 1: Ready) */
+        /* When once it returned ready to sense call, it must accept a byte at least */
+        /* at subsequent transfer call, or f_forward will fail with FR_INT_ERR. */
+        if (FIFO_READY) cnt = 1;
+    }
+    else {              /* Transfer call */
+        do {    /* Repeat while there is any data to be sent and the stream is ready */
+            FIFO_PORT = *p++;
+            cnt++;
+        } while (cnt < btf && FIFO_READY);
+    }
+
+    return cnt;
+}
+
+
+/*------------------------------------------------------------------------*/
+/* Sample code using f_forward function                                   */
+/*------------------------------------------------------------------------*/
+
+FRESULT play_file (
+    char *fn        /* Pointer to the audio file name to be played */
+)
+{
+    FRESULT rc;
+    FIL fil;
+    UINT dmy;
+
+    /* Open the audio file in read only mode */
+    rc = f_open(&fil, fn, FA_READ);
+    if (rc) return rc;
+
+    /* Repeat until the file pointer reaches end of the file */
+    while (rc == FR_OK && fil.fptr < fil.fsize) {
+
+        /* any other processes... */
+
+        /* Fill output stream periodicaly or on-demand */
+        rc = f_forward(&fil, out_stream, 1000, &dmy);
+    }
+
+    /* Close the file and return */
+    f_close(&fil);
+    return rc;
+}
+
+
+ + +
+

See Also

+

f_open, fgets, f_write, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/getcwd.html b/3rdparty/fatfs-0.10b/doc/en/getcwd.html similarity index 96% rename from src/gfile/fatfs/doc/en/getcwd.html rename to 3rdparty/fatfs-0.10b/doc/en/getcwd.html index df84287e..34848b7b 100644 --- a/src/gfile/fatfs/doc/en/getcwd.html +++ b/3rdparty/fatfs-0.10b/doc/en/getcwd.html @@ -1,70 +1,70 @@ - - - - - - - - -FatFs - f_getcwd - - - - -
-

f_getcwd

-

The f_getcwd function retrieves the current directory.

-
-FRESULT f_getcwd (
-  TCHAR* buff, /* [OUT] Buffer to return path name */
-  UINT len     /* [IN] The length of the buffer */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to the buffer to receive the current directory string.
-
len
-
Size of the buffer in unit of TCHAR.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_getcwd() function retrieves full path name of the current directory of the current drive. When _VOLUMES is larger than 1, a logical drive number is added to top of the path name.

-
- - -
-

QuickInfo

-

Available when _FS_RPATH == 2.

-
- - -
-

See Also

-

f_chdrive, f_chdir

-
- -

Return

- - + + + + + + + + +FatFs - f_getcwd + + + + +
+

f_getcwd

+

The f_getcwd function retrieves the current directory.

+
+FRESULT f_getcwd (
+  TCHAR* buff, /* [OUT] Buffer to return path name */
+  UINT len     /* [IN] The length of the buffer */
+);
+
+
+ +
+

Parameters

+
+
buff
+
Pointer to the buffer to receive the current directory string.
+
len
+
Size of the buffer in unit of TCHAR.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_getcwd() function retrieves full path name of the current directory of the current drive. When _VOLUMES is larger than 1, a logical drive number is added to top of the path name.

+
+ + +
+

QuickInfo

+

Available when _FS_RPATH == 2.

+
+ + +
+

See Also

+

f_chdrive, f_chdir

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/getfree.html b/3rdparty/fatfs-0.10b/doc/en/getfree.html similarity index 97% rename from src/gfile/fatfs/doc/en/getfree.html rename to 3rdparty/fatfs-0.10b/doc/en/getfree.html index 5a689751..9f169b07 100644 --- a/src/gfile/fatfs/doc/en/getfree.html +++ b/3rdparty/fatfs-0.10b/doc/en/getfree.html @@ -1,95 +1,95 @@ - - - - - - - - -FatFs - f_getfree - - - - -
-

f_getfree

-

The f_getfree function gets number of the free clusters on the volume.

-
-FRESULT f_getfree (
-  const TCHAR* path,  /* [IN] Logical drive number */
-  DWORD* nclst,       /* [OUT] Number of free clusters */
-  FATFS** fatfs       /* [OUT] Corresponding file system object */
-);
-
-
- -
-

Parameters

-
-
path
-
Pinter to the null-terminated string that specifies the logical drive. A null-string means the default drive.
-
nclst
-
Pointer to the DWORD variable to store number of free clusters.
-
fatfs
-
Pointer to pointer that to store a pointer to the corresponding file system object.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT -

-
- - -
-

Descriptions

-

The f_getfree() function gets number of free clusters on the volume. The member csize in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by _FS_NOFSINFO option.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

Example

-
-    FATFS *fs;
-    DWORD fre_clust, fre_sect, tot_sect;
-
-
-    /* Get volume information and free clusters of drive 1 */
-    res = f_getfree("1:", &fre_clust, &fs);
-    if (res) die(res);
-
-    /* Get total sectors and free sectors */
-    tot_sect = (fs->n_fatent - 2) * fs->csize;
-    fre_sect = fre_clust * fs->csize;
-
-    /* Print the free space (assuming 512 bytes/sector) */
-    printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
-           tot_sect / 2, fre_sect / 2);
-
-
- - -
-

See Also

-

FATFS

-
- -

Return

- - + + + + + + + + +FatFs - f_getfree + + + + +
+

f_getfree

+

The f_getfree function gets number of the free clusters on the volume.

+
+FRESULT f_getfree (
+  const TCHAR* path,  /* [IN] Logical drive number */
+  DWORD* nclst,       /* [OUT] Number of free clusters */
+  FATFS** fatfs       /* [OUT] Corresponding file system object */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pinter to the null-terminated string that specifies the logical drive. A null-string means the default drive.
+
nclst
+
Pointer to the DWORD variable to store number of free clusters.
+
fatfs
+
Pointer to pointer that to store a pointer to the corresponding file system object.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT +

+
+ + +
+

Descriptions

+

The f_getfree() function gets number of free clusters on the volume. The member csize in the file system object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by _FS_NOFSINFO option.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

Example

+
+    FATFS *fs;
+    DWORD fre_clust, fre_sect, tot_sect;
+
+
+    /* Get volume information and free clusters of drive 1 */
+    res = f_getfree("1:", &fre_clust, &fs);
+    if (res) die(res);
+
+    /* Get total sectors and free sectors */
+    tot_sect = (fs->n_fatent - 2) * fs->csize;
+    fre_sect = fre_clust * fs->csize;
+
+    /* Print the free space (assuming 512 bytes/sector) */
+    printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
+           tot_sect / 2, fre_sect / 2);
+
+
+ + +
+

See Also

+

FATFS

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/getlabel.html b/3rdparty/fatfs-0.10b/doc/en/getlabel.html similarity index 96% rename from src/gfile/fatfs/doc/en/getlabel.html rename to 3rdparty/fatfs-0.10b/doc/en/getlabel.html index 736792fd..81b27368 100644 --- a/src/gfile/fatfs/doc/en/getlabel.html +++ b/3rdparty/fatfs-0.10b/doc/en/getlabel.html @@ -1,82 +1,82 @@ - - - - - - - - -FatFs - f_getlabel - - - - -
-

f_getlabel

-

The f_getlabel function returns volume label and volume serial number of a drive.

-
-FRESULT f_getlabel (
-  const TCHAR* path,  /* [IN] Drive number */
-  TCHAR* label,       /* [OUT] Volume label */
-  DWORD* vsn          /* [OUT] Volume serial number */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to the null-terminated string that specifies the logical drive. Null-string specifies the default drive.
-
label
-
Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.
-
vsn
-
Pointer to the DWORD variable to store the volume serial number. Set null pointer if this information is not needed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT -

-
- - -
-

QuickInfo

-

Available when _USE_LABEL == 1.

-
- - -
-

Example

-
-    char str[12];
-
-    /* Get volume label of the default drive */
-    f_getlabel("", str, 0);
-
-    /* Get volume label of the drive 2 */
-    f_getlabel("2:", str, 0);
-
-
- - -
-

See Also

-f_setlabel -
- - -

Return

- - + + + + + + + + +FatFs - f_getlabel + + + + +
+

f_getlabel

+

The f_getlabel function returns volume label and volume serial number of a drive.

+
+FRESULT f_getlabel (
+  const TCHAR* path,  /* [IN] Drive number */
+  TCHAR* label,       /* [OUT] Volume label */
+  DWORD* vsn          /* [OUT] Volume serial number */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to the null-terminated string that specifies the logical drive. Null-string specifies the default drive.
+
label
+
Pointer to the buffer to store the volume label. The buffer size must be at least 12 items. If the volume has no label, a null-string will be returned. Set null pointer if this information is not needed.
+
vsn
+
Pointer to the DWORD variable to store the volume serial number. Set null pointer if this information is not needed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT +

+
+ + +
+

QuickInfo

+

Available when _USE_LABEL == 1.

+
+ + +
+

Example

+
+    char str[12];
+
+    /* Get volume label of the default drive */
+    f_getlabel("", str, 0);
+
+    /* Get volume label of the drive 2 */
+    f_getlabel("2:", str, 0);
+
+
+ + +
+

See Also

+f_setlabel +
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/gets.html b/3rdparty/fatfs-0.10b/doc/en/gets.html similarity index 97% rename from src/gfile/fatfs/doc/en/gets.html rename to 3rdparty/fatfs-0.10b/doc/en/gets.html index c8439523..f4474a62 100644 --- a/src/gfile/fatfs/doc/en/gets.html +++ b/3rdparty/fatfs-0.10b/doc/en/gets.html @@ -1,65 +1,65 @@ - - - - - - - - -FatFs - f_gets - - - - -
-

f_gets

-

The f_gets reads a string from the file.

-
-TCHAR* f_gets (
-  TCHAR* buff, /* [OUT] Read buffer */
-  int len,     /* [IN] Size of the read buffer */
-  FIL* fp      /* [IN] File object */
-);
-
-
- -
-

Parameters

-
-
buff
-
Pointer to read buffer to store the read string.
-
len
-
Size of the read buffer in unit of character.
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Values

-

When the function succeeded, buff will be returuned.

-
- - -
-

Description

-

The f_gets() function is a wrapper function of f_read() function. The read operation continues until a '\n' is stored, reached end of the file or the buffer is filled with len - 1 characters. The read string is terminated with a '\0'. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with f_eof() and f_error() macros.

-

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

-
- - -
-

QuickInfo

-

Available when _USE_STRFUNC is 1 or 2. When it is set to 2, '\r's contained in the file are stripped out.

-
- - -
-

See Also

-

f_open, f_read, f_putc, f_puts, f_printf, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_gets + + + + +
+

f_gets

+

The f_gets reads a string from the file.

+
+TCHAR* f_gets (
+  TCHAR* buff, /* [OUT] Read buffer */
+  int len,     /* [IN] Size of the read buffer */
+  FIL* fp      /* [IN] File object */
+);
+
+
+ +
+

Parameters

+
+
buff
+
Pointer to read buffer to store the read string.
+
len
+
Size of the read buffer in unit of character.
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Values

+

When the function succeeded, buff will be returuned.

+
+ + +
+

Description

+

The f_gets() function is a wrapper function of f_read() function. The read operation continues until a '\n' is stored, reached end of the file or the buffer is filled with len - 1 characters. The read string is terminated with a '\0'. When no character to read or any error occured during read operation, it returns a null pointer. The status of EOF and error can be examined with f_eof() and f_error() macros.

+

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), data types on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

+
+ + +
+

QuickInfo

+

Available when _USE_STRFUNC is 1 or 2. When it is set to 2, '\r's contained in the file are stripped out.

+
+ + +
+

See Also

+

f_open, f_read, f_putc, f_puts, f_printf, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/lseek.html b/3rdparty/fatfs-0.10b/doc/en/lseek.html similarity index 96% rename from src/gfile/fatfs/doc/en/lseek.html rename to 3rdparty/fatfs-0.10b/doc/en/lseek.html index e3185adf..fa59aa9d 100644 --- a/src/gfile/fatfs/doc/en/lseek.html +++ b/3rdparty/fatfs-0.10b/doc/en/lseek.html @@ -1,129 +1,129 @@ - - - - - - - - -FatFs - f_lseek - - - - -
-

f_lseek

-

The f_lseek function moves the file read/write pointer of an open file object. It can also be used to expand the file size (cluster pre-allocation).

- -
-FRESULT f_lseek (
-  FIL* fp,   /* [IN] File object */
-  DWORD ofs  /* [IN] File read/write pointer */
-);
-
-
- -
-

Parameters

-
-
fp
-
Pointer to the open file object.
-
ofs
-
Byte offset from top of the file.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_lseek() function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified in write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the f_lseek() function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.

- -

Fast seek feature is enabled when _USE_FASTSEEK is set to 1 and the member cltbl in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using CLMT (cluster link map table). The fast seek feature is also applied to f_read()/f_write() function, however, the file size cannot be expanded by f_write()/f_lseek() function.

-

The CLMT must be created in the user defined DWORD array prior to use the fast seek feature. To create the CLMT, set address of the DWORD array to the member cltbl in the file object, set the array size in unit of items into the first item and call the f_lseek() function with ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured at subsequent f_read()/f_write()/f_lseek() function to the file. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.

-
- - -
-

QuickInfo

-

Available when _FS_MINIMIZE <= 2.

-
- - -
-

Example

-
-    /* Open file */
-    fp = malloc(sizeof (FIL));
-    res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
-    if (res) ...
-
-    /* Move to offset of 5000 from top of the file */
-    res = f_lseek(fp, 5000);
-
-    /* Move to end of the file to append data */
-    res = f_lseek(fp, f_size(fp));
-
-    /* Forward 3000 bytes */
-    res = f_lseek(fp, f_tell(fp) + 3000);
-
-    /* Rewind 2000 bytes (take care on wraparound) */
-    res = f_lseek(fp, f_tell(fp) - 2000);
-
-
-/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
-
-    res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE);   /* Create a file */
-
-    res = f_lseek(fp, PRE_SIZE);             /* Expand file size (cluster pre-allocation) */
-    if (res || f_tell(fp) != PRE_SIZE) ...   /* Check if the file has been expanded */
-
-    res = f_lseek(fp, DATA_START);           /* Record data stream WITHOUT cluster allocation delay */
-    ...                                      /* DATA_START and write block size should be aligned to sector boundary */
-
-    res = f_truncate(fp);                    /* Truncate unused area */
-    res = f_lseek(fp, 0);                    /* Put file header */
-    ...
-
-    res = f_close(fp);
-
-
-/* Using fast seek feature */
-
-    DWORD clmt[SZ_TBL];                    /* Cluster link map table buffer */
-
-    res = f_lseek(fp, ofs1);               /* This is normal seek (cltbl is nulled on file open) */
-
-    fp->cltbl = clmt;                      /* Enable fast seek feature (cltbl != NULL) */
-    clmt[0] = SZ_TBL;                      /* Set table size */
-    res = f_lseek(fp, CREATE_LINKMAP);     /* Create CLMT */
-    ...
-
-    res = f_lseek(fp, ofs2);               /* This is fast seek */
-
-
- - -
-

See Also

-

f_open, f_truncate, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_lseek + + + + +
+

f_lseek

+

The f_lseek function moves the file read/write pointer of an open file object. It can also be used to expand the file size (cluster pre-allocation).

+ +
+FRESULT f_lseek (
+  FIL* fp,   /* [IN] File object */
+  DWORD ofs  /* [IN] File read/write pointer */
+);
+
+
+ +
+

Parameters

+
+
fp
+
Pointer to the open file object.
+
ofs
+
Byte offset from top of the file.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_lseek() function moves the file read/write pointer of an open file. The offset can be specified in only origin from top of the file. When an offset beyond the file size is specified at write mode, the file size is expanded to the specified offset. The file data in the expanded area is undefined because no data is written to the file. This is suitable to pre-allocate a cluster chain quickly, for fast write operation. After the f_lseek() function succeeded, the current read/write pointer should be checked in order to make sure the read/write pointer has been moved correctry. In case of the current read/write pointer is not the expected value, either of followings has been occured.

+ +

Fast seek feature is enabled when _USE_FASTSEEK is set to 1 and the member cltbl in the file object is not NULL. This feature enables fast backward/long seek operations without FAT access by using CLMT (cluster link map table). The fast seek feature is also applied to f_read()/f_write() function, however, the file size cannot be expanded by f_write()/f_lseek() function.

+

The CLMT must be created in the user defined DWORD array prior to use the fast seek feature. To create the CLMT, set address of the DWORD array to the member cltbl in the file object, set the array size in unit of items into the first item and call the f_lseek() function with ofs = CREATE_LINKMAP. After the function succeeded and CLMT is created, no FAT access is occured at subsequent f_read()/f_write()/f_lseek() function to the file. If the function failed with FR_NOT_ENOUGH_CORE, the given array size is insufficient for the file and number of items required is returned into the first item of the array. The required array size is (number of fragments + 1) * 2 items. For example, when the file is fragmented in 5, 12 items will be required for the CLMT.

+
+ + +
+

QuickInfo

+

Available when _FS_MINIMIZE <= 2.

+
+ + +
+

Example

+
+    /* Open file */
+    fp = malloc(sizeof (FIL));
+    res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
+    if (res) ...
+
+    /* Move to offset of 5000 from top of the file */
+    res = f_lseek(fp, 5000);
+
+    /* Move to end of the file to append data */
+    res = f_lseek(fp, f_size(fp));
+
+    /* Forward 3000 bytes */
+    res = f_lseek(fp, f_tell(fp) + 3000);
+
+    /* Rewind 2000 bytes (take care on wraparound) */
+    res = f_lseek(fp, f_tell(fp) - 2000);
+
+
+/* Cluster pre-allocation (to prevent buffer overrun on streaming write) */
+
+    res = f_open(fp, recfile, FA_CREATE_NEW | FA_WRITE);   /* Create a file */
+
+    res = f_lseek(fp, PRE_SIZE);             /* Expand file size (cluster pre-allocation) */
+    if (res || f_tell(fp) != PRE_SIZE) ...   /* Check if the file has been expanded */
+
+    res = f_lseek(fp, DATA_START);           /* Record data stream WITHOUT cluster allocation delay */
+    ...                                      /* DATA_START and write block size should be aligned to sector boundary */
+
+    res = f_truncate(fp);                    /* Truncate unused area */
+    res = f_lseek(fp, 0);                    /* Put file header */
+    ...
+
+    res = f_close(fp);
+
+
+/* Using fast seek feature */
+
+    DWORD clmt[SZ_TBL];                    /* Cluster link map table buffer */
+
+    res = f_lseek(fp, ofs1);               /* This is normal seek (cltbl is nulled on file open) */
+
+    fp->cltbl = clmt;                      /* Enable fast seek feature (cltbl != NULL) */
+    clmt[0] = SZ_TBL;                      /* Set table size */
+    res = f_lseek(fp, CREATE_LINKMAP);     /* Create CLMT */
+    ...
+
+    res = f_lseek(fp, ofs2);               /* This is fast seek */
+
+
+ + +
+

See Also

+

f_open, f_truncate, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/mkdir.html b/3rdparty/fatfs-0.10b/doc/en/mkdir.html similarity index 96% rename from src/gfile/fatfs/doc/en/mkdir.html rename to 3rdparty/fatfs-0.10b/doc/en/mkdir.html index c2c1f4db..34f83e86 100644 --- a/src/gfile/fatfs/doc/en/mkdir.html +++ b/3rdparty/fatfs-0.10b/doc/en/mkdir.html @@ -1,80 +1,80 @@ - - - - - - - - -FatFs - f_mkdir - - - - -
-

f_mkdir

-

The f_mkdir function creates a new directory.

-
-FRESULT f_mkdir (
-  const TCHAR* path /* [IN] Directory name */
-);
-
-
- -
-

Parameter

-
-
path
-
Pointer to the null-terminated string that specifies the directory name to create.
-
-
- - -
-

Return Value

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_PATH, -FR_INVALID_NAME, -FR_DENIED, -FR_EXIST, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

This function creates a new directory.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

Example

-
-    res = f_mkdir("sub1");
-    if (res) die(res);
-    res = f_mkdir("sub1/sub2");
-    if (res) die(res);
-    res = f_mkdir("sub1/sub2/sub3");
-    if (res) die(res);
-
-
- -

Return

- - + + + + + + + + +FatFs - f_mkdir + + + + +
+

f_mkdir

+

The f_mkdir function creates a new directory.

+
+FRESULT f_mkdir (
+  const TCHAR* path /* [IN] Directory name */
+);
+
+
+ +
+

Parameter

+
+
path
+
Pointer to the null-terminated string that specifies the directory name to create.
+
+
+ + +
+

Return Value

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_PATH, +FR_INVALID_NAME, +FR_DENIED, +FR_EXIST, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

This function creates a new directory.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

Example

+
+    res = f_mkdir("sub1");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2/sub3");
+    if (res) die(res);
+
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/mkfs.html b/3rdparty/fatfs-0.10b/doc/en/mkfs.html similarity index 98% rename from src/gfile/fatfs/doc/en/mkfs.html rename to 3rdparty/fatfs-0.10b/doc/en/mkfs.html index 573bdd79..58e63750 100644 --- a/src/gfile/fatfs/doc/en/mkfs.html +++ b/3rdparty/fatfs-0.10b/doc/en/mkfs.html @@ -1,73 +1,73 @@ - - - - - - - - -FatFs - f_mkfs - - - - -
-

f_mkfs

-

The f_mkfs fucntion creates an FAT file system on the logical drive.

-
-FRESULT f_mkfs (
-  const TCHAR* path,  /* [IN] Logical drive number */
-  BYTE  sfd,          /* [IN] Partitioning rule */
-  UINT  au            /* [IN] Size of the allocation unit */
-);
-
-
- -
-

Parameters

-
-
path
-
Pinter to the null-terminated string that specifies the logical drive to be formatted. If there is no drive number, it means the default drive.
-
sfd
-
Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.
-
au
-
Specifies size of the allocation unit (cluter) in unit of byte. The value must be sector size * n (n is 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.
-
-
- -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_NOT_READY, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_MKFS_ABORTED, -FR_INVALID_PARAMETER -

-
- -
-

Description

-

The f_mkfs() function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.

-

If the logical drive has been bound to any partition (1-4) by multiple partition feature (_MULTI_PARTITION), the FAT volume is created into the specified partition. In this case, the second argument sfd is ignored. The physical drive must have been partitioned with f_fdisk() function or any other partitioning tool prior to use this function.

-

Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and super-floppy media.

-

The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.

-

When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.

-
- -
-

QuickInfo

-

Available when _FS_READOLNY == 0 and _USE_MKFS == 1.

-
- -
-

See Also

-

Volume management, f_fdisk

-
- -

Return

- - + + + + + + + + +FatFs - f_mkfs + + + + +
+

f_mkfs

+

The f_mkfs fucntion creates an FAT file system on the logical drive.

+
+FRESULT f_mkfs (
+  const TCHAR* path,  /* [IN] Logical drive number */
+  BYTE  sfd,          /* [IN] Partitioning rule */
+  UINT  au            /* [IN] Size of the allocation unit */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pinter to the null-terminated string that specifies the logical drive to be formatted. If there is no drive number, it means the default drive.
+
sfd
+
Specifies partitioning rule (FDISK(0) or SFD(1)). This argument will be ignored on some case.
+
au
+
Specifies size of the allocation unit (cluter) in unit of byte. The value must be sector size * n (n is 1 to 128 and power of 2). When a zero is given, the cluster size is determined depends on the volume size.
+
+
+ +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_NOT_READY, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_MKFS_ABORTED, +FR_INVALID_PARAMETER +

+
+ +
+

Description

+

The f_mkfs() function creates an FAT volume on the logical drive. When FDISK format is specified, a primary partition occupies the entire disk space is created and then an FAT volume is created on the partition. When SFD format is specified, the FAT volume starts from the first sector of the physical drive.

+

If the logical drive has been bound to any partition (1-4) by multiple partition feature (_MULTI_PARTITION), the FAT volume is created into the specified partition. In this case, the second argument sfd is ignored. The physical drive must have been partitioned with f_fdisk() function or any other partitioning tool prior to use this function.

+

Note that there are two partitioning rules, FDISK and SFD. The FDISK partitioning is usually used for harddisk, MMC, SDC, CFC and U Disk. It can divide a physical drive into one or more partitions with a partition table on the MBR. However Windows does not support multiple partition on the removable media. The SFD is non-partitioned method. The FAT volume starts from the first sector on the physical drive without partition table. It is usually used for floppy disk, Microdrive, optical disk and super-floppy media.

+

The FAT sub-type, FAT12/FAT16/FAT32, is determined by number of clusters on the volume and nothing else, according to the FAT specification issued by Microsoft. Thus which FAT sub-type is selected, is depends on the volume size and the specified cluster size. The cluster size affects performance of the file system and large cluster increases the performance.

+

When the number of clusters gets near the FAT sub-type boundaries, the function can fail with FR_MKFS_ABORTED.

+
+ +
+

QuickInfo

+

Available when _FS_READOLNY == 0 and _USE_MKFS == 1.

+
+ +
+

See Also

+

Volume management, f_fdisk

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/mount.html b/3rdparty/fatfs-0.10b/doc/en/mount.html similarity index 93% rename from src/gfile/fatfs/doc/en/mount.html rename to 3rdparty/fatfs-0.10b/doc/en/mount.html index e5370596..f96b2fe4 100644 --- a/src/gfile/fatfs/doc/en/mount.html +++ b/3rdparty/fatfs-0.10b/doc/en/mount.html @@ -1,83 +1,83 @@ - - - - - - - - -FatFs - f_mount - - - - -
-

f_mount

-

The f_mount fucntion registers/unregisters file system object to the FatFs module.

-
-FRESULT f_mount (
-  FATFS*       fatfs, /* [IN] File system object */
-  const TCHAR* path,  /* [IN] Logical drive number */
-  BYTE         opt    /* [IN] Initialization option */
-);
-
-
- -
-

Parameters

-
-
fatfs
-
Pointer to the new file system object to be registered. Null pointer unregisters the registered file system object.
-
path
-
Pointer to the null-terminated string that specifies the logical drive. The string with no drive number means the default drive.
-
opt
-
Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the FAT volume is available.
-
-
- -
-

Return Values

-

-FR_OK, -FR_INVALID_DRIVE, -FR_DISK_ERR, -FR_NOT_READY, -FR_NO_FILESYSTEM -

-
- - -
-

Description

-

The f_mount() function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:

-
    -
  1. Determines the logical drive which specified by path.
  2. -
  3. Clears and unregisters the regsitered work area of the drive.
  4. -
  5. Clears and registers the new work area to the drive if fatfs is not NULL.
  6. -
  7. Performs volume mount process to the drive if forced mount is specified.
  8. -
-

The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for f_fdisk() function. To unregister a work area, specify a NULL to the fatfs, and then the work area can be discarded.

-

If forced mount is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. No activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.

- -

If the function with forced mount failed, it means that the file system object is registered but the volume is currently not available. Mount process will also be attempted in subsequent file access functions.

-

If implementation of the disk I/O layer lacks media change detection, application program needs to perform a f_mount() after each media change to force cleared the file system object.

-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, FATFS

-
- -

Return

- - + + + + + + + + +FatFs - f_mount + + + + +
+

f_mount

+

The f_mount fucntion registers/unregisters file system object to the FatFs module.

+
+FRESULT f_mount (
+  FATFS*       fs,    /* [IN] File system object */
+  const TCHAR* path,  /* [IN] Logical drive number */
+  BYTE         opt    /* [IN] Initialization option */
+);
+
+
+ +
+

Parameters

+
+
fs
+
Pointer to the new file system object to be registered. Null pointer unregisters the registered file system object.
+
path
+
Pointer to the null-terminated string that specifies the logical drive. The string with no drive number means the default drive.
+
opt
+
Initialization option. 0: Do not mount now (to be mounted later), 1: Force mounted the volume to check if the FAT volume is available.
+
+
+ +
+

Return Values

+

+FR_OK, +FR_INVALID_DRIVE, +FR_DISK_ERR, +FR_NOT_READY, +FR_NO_FILESYSTEM +

+
+ + +
+

Description

+

The f_mount() function registers/unregisters a file system object used for the logical drive to the FatFs module as follows:

+
    +
  1. Determines the logical drive which specified by path.
  2. +
  3. Clears and unregisters the regsitered work area of the drive.
  4. +
  5. Clears and registers the new work area to the drive if fs is not NULL.
  6. +
  7. Performs volume mount process to the drive if forced mount is specified.
  8. +
+

The file system object is the work area needed for each logical drive. It must be given to the logical drive with this function prior to use any other file functions except for f_fdisk() function. To unregister a work area, specify a NULL to the fs, and then the work area can be discarded.

+

If forced mount is not specified, this function always succeeds regardless of the physical drive status due to delayed mount feature. It only clears (de-initializes) the given work area and registers its address to the internal table. No activity of the physical drive in this function. It can also be used to force de-initialized the registered work area of a logical drive. The volume mount processes, initialize the corresponding physical drive, find the FAT volume in it and initialize the work area, is performed in the subsequent file access functions when either or both of following condition is true.

+ +

If the function with forced mount failed, it means that the file system object is registered but the volume is currently not available. Mount process will also be attempted in subsequent file access functions.

+

If implementation of the disk I/O layer lacks media change detection, application program needs to perform a f_mount() after each media change to force cleared the file system object.

+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, FATFS

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/open.html b/3rdparty/fatfs-0.10b/doc/en/open.html similarity index 97% rename from src/gfile/fatfs/doc/en/open.html rename to 3rdparty/fatfs-0.10b/doc/en/open.html index d61a7a45..8fb30a35 100644 --- a/src/gfile/fatfs/doc/en/open.html +++ b/3rdparty/fatfs-0.10b/doc/en/open.html @@ -1,173 +1,173 @@ - - - - - - - - -FatFs - f_open - - - - -
-

f_open

-

The f_open function creates a file object to be used to access the file.

-
-FRESULT f_open (
-  FIL* fp,           /* [OUT] Pointer to the file object structure */
-  const TCHAR* path, /* [IN] File name */
-  BYTE mode          /* [IN] Mode flags */
-);
-
-
- -
-

Parameters

-
-
fp
-
Pointer to the blank file object structure to be created.
-
path
-
Pointer to a null-terminated string that specifies the file name to open or create.
-
mode
-
Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.
- - - - - - - - -
ValueDescription
FA_READSpecifies read access to the object. Data can be read from the file. Combine with FA_WRITE for read-write access.
FA_WRITESpecifies write access to the object. Data can be written to the file. Combine with FA_READ for read-write access.
FA_OPEN_EXISTINGOpens the file. The function fails if the file is not existing. (Default)
FA_OPEN_ALWAYSOpens the file if it is existing. If not, a new file is created.
-To append data to the file, use f_lseek() function after file open in this method.
FA_CREATE_NEWCreates a new file. The function fails with FR_EXIST if the file is existing.
FA_CREATE_ALWAYSCreates a new file. If the file is existing, it will be truncated and overwritten.
-
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_DENIED, -FR_EXIST, -FR_INVALID_OBJECT, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_LOCKED, -FR_NOT_ENOUGH_CORE, -FR_TOO_MANY_OPEN_FILES -

-
- - -
-

Description

-

After f_open() function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. To close an open file, use f_close() function. If the file is modified and not closed properly, the file data will be collapsed.

-

If duplicated file open is needed, read here carefully. However duplicated open of a file with write mode flag is always prohibited.

-

Before using any file function, a work area (file system object) must be registered to the logical drive with f_mount() function. All API functions except for f_fdisk() function can work after this procedure.

-
- - -
-

QuickInfo

-

Always available. The mode flags, FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS, are not available when _FS_READONLY == 1.

-
- - -
-

Example

-
-/* Read a text file and display it */
-
-FATFS FatFs;   /* Work area (file system object) for logical drive */
-
-int main (void)
-{
-    FIL fil;       /* File object */
-    char line[82]; /* Line buffer */
-    FRESULT fr;    /* FatFs return code */
-
-
-    /* Register work area to the default drive */
-    f_mount(&FatFs, "", 0);
-
-    /* Open a text file */
-    fr = f_open(&fil, "message.txt", FA_READ);
-    if (fr) return (int)fr;
-
-    /* Read all lines and display it */
-    while (f_gets(line, sizeof line, &fil))
-        printf(line);
-
-    /* Close the file */
-    f_close(&fil);
-
-    return 0;
-}
-
-
-/* Copy a file "file.bin" on the drive 1 to drive 0 */
-
-int main (void)
-{
-    FATFS fs[2];         /* Work area (file system object) for logical drives */
-    FIL fsrc, fdst;      /* File objects */
-    BYTE buffer[4096];   /* File copy buffer */
-    FRESULT fr;          /* FatFs function common result code */
-    UINT br, bw;         /* File read/write count */
-
-
-    /* Register work area for each logical drive */
-    f_mount(&fs[0], "0:", 0);
-    f_mount(&fs[1], "1:", 0);
-
-    /* Open source file on the drive 1 */
-    fr = f_open(&fsrc, "1:file.bin", FA_OPEN_EXISTING | FA_READ);
-    if (fr) return (int)fr;
-
-    /* Create destination file on the drive 0 */
-    fr = f_open(&fdst, "0:file.bin", FA_CREATE_ALWAYS | FA_WRITE);
-    if (fr) return (int)fr;
-
-    /* Copy source to destination */
-    for (;;) {
-        fr = f_read(&fsrc, buffer, sizeof buffer, &br);  /* Read a chunk of source file */
-        if (fr || br == 0) break; /* error or eof */
-        fr = f_write(&fdst, buffer, br, &bw);            /* Write it to the destination file */
-        if (fr || bw < br) break; /* error or disk full */
-    }
-
-    /* Close open files */
-    f_close(&fsrc);
-    f_close(&fdst);
-
-    /* Unregister work area prior to discard it */
-    f_mount(NULL, "0:", 0);
-    f_mount(NULL, "1:", 0);
-
-    return (int)fr;
-}
-
-
- - -
-

See Also

-

f_read, f_write, f_close, FIL, FATFS

-
- -

Return

- - + + + + + + + + +FatFs - f_open + + + + +
+

f_open

+

The f_open function creates a file object to be used to access the file.

+
+FRESULT f_open (
+  FIL* fp,           /* [OUT] Pointer to the file object structure */
+  const TCHAR* path, /* [IN] File name */
+  BYTE mode          /* [IN] Mode flags */
+);
+
+
+ +
+

Parameters

+
+
fp
+
Pointer to the blank file object structure to be created.
+
path
+
Pointer to a null-terminated string that specifies the file name to open or create.
+
mode
+
Mode flags that specifies the type of access and open method for the file. It is specified by a combination of following flags.
+ + + + + + + + +
ValueDescription
FA_READSpecifies read access to the object. Data can be read from the file. Combine with FA_WRITE for read-write access.
FA_WRITESpecifies write access to the object. Data can be written to the file. Combine with FA_READ for read-write access.
FA_OPEN_EXISTINGOpens the file. The function fails if the file is not existing. (Default)
FA_OPEN_ALWAYSOpens the file if it is existing. If not, a new file is created.
+To append data to the file, use f_lseek() function after file open in this method.
FA_CREATE_NEWCreates a new file. The function fails with FR_EXIST if the file is existing.
FA_CREATE_ALWAYSCreates a new file. If the file is existing, it will be truncated and overwritten.
+
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_DENIED, +FR_EXIST, +FR_INVALID_OBJECT, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_LOCKED, +FR_NOT_ENOUGH_CORE, +FR_TOO_MANY_OPEN_FILES +

+
+ + +
+

Description

+

After f_open() function succeeded, the file object is valid. The file object is used for subsequent read/write functions to identify the file. To close an open file, use f_close() function. If the file is modified and not closed properly, the file data will be collapsed.

+

If duplicated file open is needed, read here carefully. However duplicated open of a file with write mode flag is always prohibited.

+

Before using any file function, a work area (file system object) must be registered to the logical drive with f_mount() function. All API functions except for f_fdisk() function can work after this procedure.

+
+ + +
+

QuickInfo

+

Always available. The mode flags, FA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW and FA_OPEN_ALWAYS, are not available when _FS_READONLY == 1.

+
+ + +
+

Example

+
+/* Read a text file and display it */
+
+FATFS FatFs;   /* Work area (file system object) for logical drive */
+
+int main (void)
+{
+    FIL fil;       /* File object */
+    char line[82]; /* Line buffer */
+    FRESULT fr;    /* FatFs return code */
+
+
+    /* Register work area to the default drive */
+    f_mount(&FatFs, "", 0);
+
+    /* Open a text file */
+    fr = f_open(&fil, "message.txt", FA_READ);
+    if (fr) return (int)fr;
+
+    /* Read all lines and display it */
+    while (f_gets(line, sizeof line, &fil))
+        printf(line);
+
+    /* Close the file */
+    f_close(&fil);
+
+    return 0;
+}
+
+
+/* Copy a file "file.bin" on the drive 1 to drive 0 */
+
+int main (void)
+{
+    FATFS fs[2];         /* Work area (file system object) for logical drives */
+    FIL fsrc, fdst;      /* File objects */
+    BYTE buffer[4096];   /* File copy buffer */
+    FRESULT fr;          /* FatFs function common result code */
+    UINT br, bw;         /* File read/write count */
+
+
+    /* Register work area for each logical drive */
+    f_mount(&fs[0], "0:", 0);
+    f_mount(&fs[1], "1:", 0);
+
+    /* Open source file on the drive 1 */
+    fr = f_open(&fsrc, "1:file.bin", FA_OPEN_EXISTING | FA_READ);
+    if (fr) return (int)fr;
+
+    /* Create destination file on the drive 0 */
+    fr = f_open(&fdst, "0:file.bin", FA_CREATE_ALWAYS | FA_WRITE);
+    if (fr) return (int)fr;
+
+    /* Copy source to destination */
+    for (;;) {
+        fr = f_read(&fsrc, buffer, sizeof buffer, &br);  /* Read a chunk of source file */
+        if (fr || br == 0) break; /* error or eof */
+        fr = f_write(&fdst, buffer, br, &bw);            /* Write it to the destination file */
+        if (fr || bw < br) break; /* error or disk full */
+    }
+
+    /* Close open files */
+    f_close(&fsrc);
+    f_close(&fdst);
+
+    /* Unregister work area prior to discard it */
+    f_mount(NULL, "0:", 0);
+    f_mount(NULL, "1:", 0);
+
+    return (int)fr;
+}
+
+
+ + +
+

See Also

+

f_read, f_write, f_close, FIL, FATFS

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/opendir.html b/3rdparty/fatfs-0.10b/doc/en/opendir.html similarity index 96% rename from src/gfile/fatfs/doc/en/opendir.html rename to 3rdparty/fatfs-0.10b/doc/en/opendir.html index 2fd4e457..77442ef9 100644 --- a/src/gfile/fatfs/doc/en/opendir.html +++ b/3rdparty/fatfs-0.10b/doc/en/opendir.html @@ -1,75 +1,75 @@ - - - - - - - - -FatFs - f_opendir - - - - -
-

f_opendir

-

The f_opendir function opens a directory.

-
-FRESULT f_opendir (
-  DIR* dp,           /* [OUT] Pointer to the directory object structure */
-  const TCHAR* path  /* [IN] Directory name */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the blank directory object to create a new one.
-
path
-
Pinter to the null-terminated string that specifies the directory name to be opened.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_PATH, -FR_INVALID_NAME, -FR_INVALID_OBJECT, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE, -FR_TOO_MANY_OPEN_FILES -

-
- - -
-

Description

-

The f_opendir() function opens an exsisting directory and creates a directory object for subsequent f_readdir() function.

-
- - -
-

QuickInfo

-

Available when _FS_MINIMIZE <= 1.

-
- - -
-

See Also

-

f_readdir, f_closedir, DIR

-
- -

Return

- - + + + + + + + + +FatFs - f_opendir + + + + +
+

f_opendir

+

The f_opendir function opens a directory.

+
+FRESULT f_opendir (
+  DIR* dp,           /* [OUT] Pointer to the directory object structure */
+  const TCHAR* path  /* [IN] Directory name */
+);
+
+
+ +
+

Parameters

+
+
dp
+
Pointer to the blank directory object to create a new one.
+
path
+
Pinter to the null-terminated string that specifies the directory name to be opened.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_PATH, +FR_INVALID_NAME, +FR_INVALID_OBJECT, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE, +FR_TOO_MANY_OPEN_FILES +

+
+ + +
+

Description

+

The f_opendir() function opens an exsisting directory and creates a directory object for subsequent f_readdir() function.

+
+ + +
+

QuickInfo

+

Available when _FS_MINIMIZE <= 1.

+
+ + +
+

See Also

+

f_readdir, f_closedir, DIR

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/printf.html b/3rdparty/fatfs-0.10b/doc/en/printf.html similarity index 100% rename from src/gfile/fatfs/doc/en/printf.html rename to 3rdparty/fatfs-0.10b/doc/en/printf.html diff --git a/src/gfile/fatfs/doc/en/putc.html b/3rdparty/fatfs-0.10b/doc/en/putc.html similarity index 97% rename from src/gfile/fatfs/doc/en/putc.html rename to 3rdparty/fatfs-0.10b/doc/en/putc.html index 52db016b..797c6a37 100644 --- a/src/gfile/fatfs/doc/en/putc.html +++ b/3rdparty/fatfs-0.10b/doc/en/putc.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_putc - - - - -
-

f_putc

-

The f_putc funciton puts a character to the file.

-
-int f_putc (
-  TCHAR chr,  /* [IN] A character to put */
-  FIL* fp     /* [IN] File object */
-);
-
-
- -
-

Parameters

-
-
chr
-
A character to be put.
-
fp
-
Pointer to the open file object structuer.
-
-
- - -
-

Return Values

-

When the character was written successfuly, it returns number of characters written. When the function failed due to disk full or any error, an EOF (-1) will be returned.

-

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the string fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

-
- - -
-

Description

-

The f_putc() function is a wrapper function of f_write() function.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, a '\n' is converted to '\r'+'\n'.

-
- - -
-

See Also

-

f_open, f_puts, f_printf, f_gets, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_putc + + + + +
+

f_putc

+

The f_putc funciton puts a character to the file.

+
+int f_putc (
+  TCHAR chr,  /* [IN] A character to put */
+  FIL* fp     /* [IN] File object */
+);
+
+
+ +
+

Parameters

+
+
chr
+
A character to be put.
+
fp
+
Pointer to the open file object structuer.
+
+
+ + +
+

Return Values

+

When the character was written successfuly, it returns number of characters written. When the function failed due to disk full or any error, an EOF (-1) will be returned.

+

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the string fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

+
+ + +
+

Description

+

The f_putc() function is a wrapper function of f_write() function.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, a '\n' is converted to '\r'+'\n'.

+
+ + +
+

See Also

+

f_open, f_puts, f_printf, f_gets, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/puts.html b/3rdparty/fatfs-0.10b/doc/en/puts.html similarity index 97% rename from src/gfile/fatfs/doc/en/puts.html rename to 3rdparty/fatfs-0.10b/doc/en/puts.html index 30b1dd35..6550b576 100644 --- a/src/gfile/fatfs/doc/en/puts.html +++ b/3rdparty/fatfs-0.10b/doc/en/puts.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_puts - - - - -
-

f_puts

-

The f_puts function writes a string to the file.

-
-int f_puts (
-  const TCHAR* str, /* [IN] String */
-  FIL* fp           /* [IN] File object */
-);
-
-
- -
-

Parameters

-
-
str
-
Pointer to the null terminated string to be written. The terminator character will not be written.
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Value

-

When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an EOF (-1) will be returned.

-

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

-
- - -
-

Description

-

The f_puts() function is a wrapper function of f_write() function.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the string are converted to '\r'+'\n'.

-
- - -
-

See Also

-

f_open, f_putc, f_printf, f_gets, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_puts + + + + +
+

f_puts

+

The f_puts function writes a string to the file.

+
+int f_puts (
+  const TCHAR* str, /* [IN] String */
+  FIL* fp           /* [IN] File object */
+);
+
+
+ +
+

Parameters

+
+
str
+
Pointer to the null terminated string to be written. The terminator character will not be written.
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Value

+

When the function succeeded, it returns number of characters written. When the write operation is aborted due to disk full or any error, an EOF (-1) will be returned.

+

When FatFs is configured to Unicode API (_LFN_UNICODE == 1), character encoding on the srting fuctions, f_putc(), f_puts(), f_printf() and f_gets(), is also switched to Unicode. The character encoding on the file to be read/written via those functions is selected by _STRF_ENCODE option.

+
+ + +
+

Description

+

The f_puts() function is a wrapper function of f_write() function.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the string are converted to '\r'+'\n'.

+
+ + +
+

See Also

+

f_open, f_putc, f_printf, f_gets, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/rc.html b/3rdparty/fatfs-0.10b/doc/en/rc.html similarity index 97% rename from src/gfile/fatfs/doc/en/rc.html rename to 3rdparty/fatfs-0.10b/doc/en/rc.html index 15f0229b..86c066eb 100644 --- a/src/gfile/fatfs/doc/en/rc.html +++ b/3rdparty/fatfs-0.10b/doc/en/rc.html @@ -1,87 +1,87 @@ - - - - - - - - -FatFs - Return Codes - - - -

Return Code of the File Functions

-

On the FatFs API, most of file functions return common result code as enum type FRESULT. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.

- -
-
FR_OK (0)
-
The function succeeded.
-
FR_DISK_ERR
-
An unrecoverable hard error occured in the lower layer, disk_read(), disk_write() or disk_ioctl() function.
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
-
FR_INT_ERR
-
Assertion failed. An insanity is detected in the internal process. One of the following possibilities are suspected. -
    -
  • There is any error of the FAT structure on the volume.
  • -
  • Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.
  • -
-Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected. -
-
FR_NOT_READY
-
The disk drive cannot work due to incorrect medium removal or disk_initialize() function failed.
-
FR_NO_FILE
-
Could not find the file.
-
FR_NO_PATH
-
Could not find the path.
-
FR_INVALID_NAME
-
The given string is invalid as the path name.
-
FR_DENIED
-
The required access was denied due to one of the following reasons: -
    -
  • Write mode open against the read-only file.
  • -
  • Deleting the read-only file or directory.
  • -
  • Deleting the non-empty directory or current directory.
  • -
  • Reading the file opened without FA_READ flag.
  • -
  • Any modification to the file opened without FA_WRITE flag.
  • -
  • Could not create the file or directory due to the directory table is full.
  • -
  • Could not create the directory due to the volume is full.
  • -
-
-
FR_EXIST
-
Name collision. Any object that has the same name is already existing.
-
FR_INVALID_OBJECT
-
The file/directory object structure is invalid or a null pointer is given. All open objects of the logical drive are invalidated by the voulme mount process.
-
FR_WRITE_PROTECTED
-
Any write mode action against the write-protected media.
-
FR_INVALID_DRIVE
-
Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: _VOLUMES)
-
FR_NOT_ENABLED
-
Work area for the logical drive has not been registered by f_mount() function.
-
FR_NO_FILESYSTEM
-
There is no valid FAT volume on the drive.
-
FR_MKFS_ABORTED
-
The f_mkfs() function aborted before start in format due to a reason as follows: -
    -
  • The disk/partition size is too small.
  • -
  • Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.
  • -
  • There is no partition related to the logical drive. (Related option: _MULTI_PARTITION)
  • -
-
-
FR_TIMEOUT
-
The function was canceled due to a timeout of thread-safe control. (Related option: _TIMEOUT)
-
FR_LOCKED
-
The operation to the object was rejected by file sharing control. (Related option: _FS_LOCK)
-
FR_NOT_ENOUGH_CORE
-
Not enough memory for the operation. There is one of the following reasons: -
    -
  • Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)
  • -
  • Size of the given CLMT buffer is insufficient for the file fragments.
  • -
-
-
FR_TOO_MANY_OPEN_FILES
-
Number of open objects has been reached maximum value and no more object can be opened. (Related option: _FS_LOCK)
-
FR_INVALID_PARAMETER
-
The given parameter is invalid or there is any inconsistent.
-
- - - + + + + + + + + +FatFs - Return Codes + + + +

Return Code of the File Functions

+

On the FatFs API, most of file functions return common result code as enum type FRESULT. When a function succeeded, it returns zero, otherwise returns non-zero value that indicates type of error.

+ +
+
FR_OK (0)
+
The function succeeded.
+
FR_DISK_ERR
+
An unrecoverable hard error occured in the lower layer, disk_read(), disk_write() or disk_ioctl() function.
Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected.
+
FR_INT_ERR
+
Assertion failed. An insanity is detected in the internal process. One of the following possibilities is suspected. +
    +
  • Work area (file system object, file object or etc...) is broken by stack overflow or any other application. This is the reason in most case.
  • +
  • There is any error of the FAT structure on the volume.
  • +
+Note that if once this error occured at any operation to an open file, the file object is aborted and all operations to the file except for close will be rejected. +
+
FR_NOT_READY
+
The disk drive cannot work due to incorrect medium removal or disk_initialize() function failed.
+
FR_NO_FILE
+
Could not find the file.
+
FR_NO_PATH
+
Could not find the path.
+
FR_INVALID_NAME
+
The given string is invalid as the path name.
+
FR_DENIED
+
The required access was denied due to one of the following reasons: +
    +
  • Write mode open against the read-only file.
  • +
  • Deleting the read-only file or directory.
  • +
  • Deleting the non-empty directory or current directory.
  • +
  • Reading the file opened without FA_READ flag.
  • +
  • Any modification to the file opened without FA_WRITE flag.
  • +
  • Could not create the file or directory due to the directory table is full.
  • +
  • Could not create the directory due to the volume is full.
  • +
+
+
FR_EXIST
+
Name collision. Any object that has the same name is already existing.
+
FR_INVALID_OBJECT
+
The file/directory object structure is invalid or a null pointer is given. All open objects of the logical drive are invalidated by the voulme mount process.
+
FR_WRITE_PROTECTED
+
Any write mode action against the write-protected media.
+
FR_INVALID_DRIVE
+
Invalid drive number is specified in the path name. A null pointer is given as the path name. (Related option: _VOLUMES)
+
FR_NOT_ENABLED
+
Work area for the logical drive has not been registered by f_mount() function.
+
FR_NO_FILESYSTEM
+
There is no valid FAT volume on the drive.
+
FR_MKFS_ABORTED
+
The f_mkfs() function aborted before start in format due to a reason as follows: +
    +
  • The disk/partition size is too small.
  • +
  • Not allowable cluster size for this disk. This can occure when number of clusters gets near the boundaries of FAT sub-types.
  • +
  • There is no partition related to the logical drive. (Related option: _MULTI_PARTITION)
  • +
+
+
FR_TIMEOUT
+
The function was canceled due to a timeout of thread-safe control. (Related option: _TIMEOUT)
+
FR_LOCKED
+
The operation to the object was rejected by file sharing control. (Related option: _FS_LOCK)
+
FR_NOT_ENOUGH_CORE
+
Not enough memory for the operation. There is one of the following reasons: +
    +
  • Could not allocate a memory for LFN working buffer. (Related option: _USE_LFN)
  • +
  • Size of the given CLMT buffer is insufficient for the file fragments.
  • +
+
+
FR_TOO_MANY_OPEN_FILES
+
Number of open objects has been reached maximum value and no more object can be opened. (Related option: _FS_LOCK)
+
FR_INVALID_PARAMETER
+
The given parameter is invalid or there is any inconsistent.
+
+ + + diff --git a/src/gfile/fatfs/doc/en/read.html b/3rdparty/fatfs-0.10b/doc/en/read.html similarity index 94% rename from src/gfile/fatfs/doc/en/read.html rename to 3rdparty/fatfs-0.10b/doc/en/read.html index 834ef957..348bada6 100644 --- a/src/gfile/fatfs/doc/en/read.html +++ b/3rdparty/fatfs-0.10b/doc/en/read.html @@ -1,74 +1,74 @@ - - - - - - - - -FatFs - f_read - - - - -
-

f_read

-

The f_read function reads data from a file.

-
-FRESULT f_read (
-  FIL* fp,     /* [IN] File object */
-  void* buff,  /* [OUT] Buffer to store read data */
-  UINT btr,    /* [IN] Number of bytes to read */
-  UINT* br     /* [OUT] Number of bytes read */
-);
-
-
- -
-

Parameters

-
-
fp
-
Pointer to the open file object.
-
buff
-
Pointer to the buffer to store read data.
-
btr
-
Number of bytes to read in range of UINT type.
-
br
-
Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The file read/write pointer of the file object advances number of bytes read. After the function succeeded, *br should be checked to detect the end of file. In case of *br is less than btr, it means the read/write pointer reached end of the file during read operation.

-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, fgets, f_write, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_read + + + + +
+

f_read

+

The f_read function reads data from a file.

+
+FRESULT f_read (
+  FIL* fp,     /* [IN] File object */
+  void* buff,  /* [OUT] Buffer to store read data */
+  UINT btr,    /* [IN] Number of bytes to read */
+  UINT* br     /* [OUT] Number of bytes read */
+);
+
+
+ +
+

Parameters

+
+
fp
+
Pointer to the open file object.
+
buff
+
Pointer to the buffer to store read data.
+
btr
+
Number of bytes to read in range of UINT type.
+
br
+
Pointer to the UINT variable to return number of bytes read. The value is always valid after the function call regardless of the result.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The file read/write pointer of the file object advances number of bytes read. After the function succeeded, *br should be checked to detect end of the file. In case of *br is less than btr, it means the read/write pointer reached end of the file during read operation.

+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, fgets, f_write, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/readdir.html b/3rdparty/fatfs-0.10b/doc/en/readdir.html similarity index 97% rename from src/gfile/fatfs/doc/en/readdir.html rename to 3rdparty/fatfs-0.10b/doc/en/readdir.html index 9808435e..32c221ba 100644 --- a/src/gfile/fatfs/doc/en/readdir.html +++ b/3rdparty/fatfs-0.10b/doc/en/readdir.html @@ -1,125 +1,125 @@ - - - - - - - - -FatFs - f_readdir - - - - -
-

f_readdir

-

The f_readdir function reads directory entries.

-
-FRESULT f_readdir (
-  DIR* dp,      /* [IN] Directory object */
-  FILINFO* fno  /* [OUT] File information structure */
-);
-
-
- -
-

Parameters

-
-
dp
-
Pointer to the open directory object.
-
fno
-
Pointer to the file information structure to store the read item.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_readdir() function reads directory items, file and directory, in sequence. All items in the directory can be read by calling f_readdir() function repeatedly. When relative path feature is enabled (_FS_RPATH >= 1), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the fname[] without any error. When a null pointer is given to the fno, the read index of the directory object is rewinded.

-

When LFN feature is enabled, lfname and lfsize in the file information structure must be initialized with valid value prior to use it. The lfname is a pointer to the LFN read buffer. The lfsize is size of the LFN read buffer in unit of TCHAR. If the LFN is not needed, set a null pointer to the lfname and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.

- -

When the directory item has no LFN information, lower case characters can be contained in the fname[].

-
- - -
-

QuickInfo

-

Available when _FS_MINIMIZE <= 1.

-
- - -
-

Sample Code

-
-FRESULT scan_files (
-    char* path        /* Start node to be scanned (also used as work area) */
-)
-{
-    FRESULT res;
-    FILINFO fno;
-    DIR dir;
-    int i;
-    char *fn;   /* This function is assuming non-Unicode cfg. */
-#if _USE_LFN
-    static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
-    fno.lfname = lfn;
-    fno.lfsize = sizeof lfn;
-#endif
-
-
-    res = f_opendir(&dir, path);                       /* Open the directory */
-    if (res == FR_OK) {
-        i = strlen(path);
-        for (;;) {
-            res = f_readdir(&dir, &fno);                   /* Read a directory item */
-            if (res != FR_OK || fno.fname[0] == 0) break;  /* Break on error or end of dir */
-            if (fno.fname[0] == '.') continue;             /* Ignore dot entry */
-#if _USE_LFN
-            fn = *fno.lfname ? fno.lfname : fno.fname;
-#else
-            fn = fno.fname;
-#endif
-            if (fno.fattrib & AM_DIR) {                    /* It is a directory */
-                sprintf(&path[i], "/%s", fn);
-                res = scan_files(path);
-                if (res != FR_OK) break;
-                path[i] = 0;
-            } else {                                       /* It is a file. */
-                printf("%s/%s\n", path, fn);
-            }
-        }
-        f_closedir(&dir)
-    }
-
-    return res;
-}
-
-
- - -
-

See Also

-

f_opendir, f_closedir, f_stat, FILINFO, DIR

-
- -

Return

- - + + + + + + + + +FatFs - f_readdir + + + + +
+

f_readdir

+

The f_readdir function reads directory entries.

+
+FRESULT f_readdir (
+  DIR* dp,      /* [IN] Directory object */
+  FILINFO* fno  /* [OUT] File information structure */
+);
+
+
+ +
+

Parameters

+
+
dp
+
Pointer to the open directory object.
+
fno
+
Pointer to the file information structure to store the read item.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_readdir() function reads directory items, file and directory, in sequence. All items in the directory can be read by calling f_readdir() function repeatedly. When relative path feature is enabled (_FS_RPATH >= 1), dot entries ("." and "..") are not filtered out and they will appear in the read items. When all directory items have been read and no item to read, a null string is returned into the fname[] without any error. When a null pointer is given to the fno, the read index of the directory object is rewinded.

+

When LFN feature is enabled, lfname and lfsize in the file information structure must be initialized with valid value prior to use it. The lfname is a pointer to the LFN read buffer. The lfsize is size of the LFN read buffer in unit of TCHAR. If the LFN is not needed, set a null pointer to the lfname and the LFN is not returned. A null string will be returned into the LFN read buffer in case of following conditions.

+ +

When the directory item has no LFN information, lower case characters can be contained in the fname[].

+
+ + +
+

QuickInfo

+

Available when _FS_MINIMIZE <= 1.

+
+ + +
+

Sample Code

+
+FRESULT scan_files (
+    char* path        /* Start node to be scanned (also used as work area) */
+)
+{
+    FRESULT res;
+    FILINFO fno;
+    DIR dir;
+    int i;
+    char *fn;   /* This function is assuming non-Unicode cfg. */
+#if _USE_LFN
+    static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
+    fno.lfname = lfn;
+    fno.lfsize = sizeof lfn;
+#endif
+
+
+    res = f_opendir(&dir, path);                       /* Open the directory */
+    if (res == FR_OK) {
+        i = strlen(path);
+        for (;;) {
+            res = f_readdir(&dir, &fno);                   /* Read a directory item */
+            if (res != FR_OK || fno.fname[0] == 0) break;  /* Break on error or end of dir */
+            if (fno.fname[0] == '.') continue;             /* Ignore dot entry */
+#if _USE_LFN
+            fn = *fno.lfname ? fno.lfname : fno.fname;
+#else
+            fn = fno.fname;
+#endif
+            if (fno.fattrib & AM_DIR) {                    /* It is a directory */
+                sprintf(&path[i], "/%s", fn);
+                res = scan_files(path);
+                if (res != FR_OK) break;
+                path[i] = 0;
+            } else {                                       /* It is a file. */
+                printf("%s/%s\n", path, fn);
+            }
+        }
+        f_closedir(&dir)
+    }
+
+    return res;
+}
+
+
+ + +
+

See Also

+

f_opendir, f_closedir, f_stat, FILINFO, DIR

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/rename.html b/3rdparty/fatfs-0.10b/doc/en/rename.html similarity index 96% rename from src/gfile/fatfs/doc/en/rename.html rename to 3rdparty/fatfs-0.10b/doc/en/rename.html index 2593e890..e6f05232 100644 --- a/src/gfile/fatfs/doc/en/rename.html +++ b/3rdparty/fatfs-0.10b/doc/en/rename.html @@ -1,85 +1,85 @@ - - - - - - - - -FatFs - f_rename - - - - -
-

f_rename

-

Renames a file or sub-directory.

-
-FRESULT f_rename (
-  const TCHAR* old_name, /* [IN] Old object name */
-  const TCHAR* new_name  /* [IN] New object name */
-);
-
-
- -
-

Parameters

-
-
old_name
-
Pointer to a null-terminated string that specifies an existing file or sub-directory to be renamed.
-
new_name
-
Pointer to a null-terminated string that specifies the new object name. The drive number specified in this string is ignored and one determined by old_name is used instead.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_DENIED, -FR_EXIST, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_LOCKED, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

Renames a file or sub-directory and can also move it to other directory within the same logical drive. Do not rename open objects or directry table can be broken.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

Example

-
-    /* Rename an object */
-    f_rename("oldname.txt", "newname.txt");
-
-    /* Rename and move an object to other directory */
-    f_rename("oldname.txt", "dir1/newname.txt");
-
-
- - -

Return

- - + + + + + + + + +FatFs - f_rename + + + + +
+

f_rename

+

Renames a file or sub-directory.

+
+FRESULT f_rename (
+  const TCHAR* old_name, /* [IN] Old object name */
+  const TCHAR* new_name  /* [IN] New object name */
+);
+
+
+ +
+

Parameters

+
+
old_name
+
Pointer to a null-terminated string that specifies an existing file or sub-directory to be renamed.
+
new_name
+
Pointer to a null-terminated string that specifies the new object name. The drive number specified in this string is ignored and one determined by old_name is used instead.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_DENIED, +FR_EXIST, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_LOCKED, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

Renames a file or sub-directory and can also move it to other directory within the same logical drive. Do not rename open objects or directry table can be broken.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

Example

+
+    /* Rename an object */
+    f_rename("oldname.txt", "newname.txt");
+
+    /* Rename and move an object to other directory */
+    f_rename("oldname.txt", "dir1/newname.txt");
+
+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/sdir.html b/3rdparty/fatfs-0.10b/doc/en/sdir.html similarity index 98% rename from src/gfile/fatfs/doc/en/sdir.html rename to 3rdparty/fatfs-0.10b/doc/en/sdir.html index 7eba5551..785d0982 100644 --- a/src/gfile/fatfs/doc/en/sdir.html +++ b/3rdparty/fatfs-0.10b/doc/en/sdir.html @@ -1,40 +1,40 @@ - - - - - - - - -FatFs - DIR - - - - -
-

DIR

-

The DIR structure is used for the work area to read a directory by f_oepndir()/f_readdir() function. Application program must not modify any member in this structure.

-
-typedef struct {
-    FATFS*  fs;         /* Pointer to the owner file system object */
-    WORD    id;         /* Owner file system mount ID */
-    WORD    index;      /* Index of directory entry to start to search next */
-    DWORD   sclust;     /* Table start cluster (0:Root directory) */
-    DWORD   clust;      /* Current cluster */
-    DWORD   sect;       /* Current sector */
-    BYTE*   dir;        /* Pointer to the current SFN entry in the win[] */
-    BYTE*   fn;         /* Pointer to the SFN buffer (in/out) {file[8],ext[3],status[1]} */
-#if _FS_LOCK
-    UINT    lockid;     /* Sub-directory lock ID (0:Root directory) */
-#endif
-#if _USE_LFN
-    WCHAR*  lfn;        /* Pointer to the LFN buffer (in/out) */
-    WORD    lfn_idx;    /* Index of the LFN entris (0xFFFF:No LFN) */
-#endif
-} DIR;
-
-
- -

Return

- - + + + + + + + + +FatFs - DIR + + + + +
+

DIR

+

The DIR structure is used for the work area to read a directory by f_oepndir()/f_readdir() function. Application program must not modify any member in this structure.

+
+typedef struct {
+    FATFS*  fs;         /* Pointer to the owner file system object */
+    WORD    id;         /* Owner file system mount ID */
+    WORD    index;      /* Index of directory entry to start to search next */
+    DWORD   sclust;     /* Table start cluster (0:Root directory) */
+    DWORD   clust;      /* Current cluster */
+    DWORD   sect;       /* Current sector */
+    BYTE*   dir;        /* Pointer to the current SFN entry in the win[] */
+    BYTE*   fn;         /* Pointer to the SFN buffer (in/out) {file[8],ext[3],status[1]} */
+#if _FS_LOCK
+    UINT    lockid;     /* Sub-directory lock ID (0:Root directory) */
+#endif
+#if _USE_LFN
+    WCHAR*  lfn;        /* Pointer to the LFN buffer (in/out) */
+    WORD    lfn_idx;    /* Index of the LFN entris (0xFFFF:No LFN) */
+#endif
+} DIR;
+
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/setlabel.html b/3rdparty/fatfs-0.10b/doc/en/setlabel.html similarity index 96% rename from src/gfile/fatfs/doc/en/setlabel.html rename to 3rdparty/fatfs-0.10b/doc/en/setlabel.html index 91179fc2..a8ac977a 100644 --- a/src/gfile/fatfs/doc/en/setlabel.html +++ b/3rdparty/fatfs-0.10b/doc/en/setlabel.html @@ -1,89 +1,89 @@ - - - - - - - - -FatFs - f_setlabel - - - - -
-

f_setlabel

-

The f_setlabel function sets/removes the label of a volume.

-
-FRESULT f_setlabel (
-  const TCHAR* label  /* [IN] Volume label to be set */
-);
-
-
- -
-

Parameters

-
-
label
-
Pointer to the null-terminated string that specifies the volume label to be set.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_NAME, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT -

-
- - -
-

Description

-

When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the label will be set to the default drive. If the given string is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the short file name but there are some differences shown below:

- -
- -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _USE_LABEL == 1.

-
- - -
-

Example

-
-    /* Set volume label to the default drive */
-    f_setlabel("DATA DISK");
-
-    /* Set volume label to the drive 2 */
-    f_setlabel("2:DISK 3 OF 4");
-
-    /* Remove volume label of the drive 2 */
-    f_setlabel("2:");
-
-
- - -
-

See Also

-f_getlabel -
- - -

Return

- - + + + + + + + + +FatFs - f_setlabel + + + + +
+

f_setlabel

+

The f_setlabel function sets/removes the label of a volume.

+
+FRESULT f_setlabel (
+  const TCHAR* label  /* [IN] Volume label to be set */
+);
+
+
+ +
+

Parameters

+
+
label
+
Pointer to the null-terminated string that specifies the volume label to be set.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_NAME, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT +

+
+ + +
+

Description

+

When the string has a drive number, the volume label will be set to the volume specified by the drive number. If not, the label will be set to the default drive. If the given string is a null-string, the volume label on the volume will be removed. The format of the volume label is similar to the short file name but there are some differences shown below:

+ +
+ +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _USE_LABEL == 1.

+
+ + +
+

Example

+
+    /* Set volume label to the default drive */
+    f_setlabel("DATA DISK");
+
+    /* Set volume label to the drive 2 */
+    f_setlabel("2:DISK 3 OF 4");
+
+    /* Remove volume label of the drive 2 */
+    f_setlabel("2:");
+
+
+ + +
+

See Also

+f_getlabel +
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/sfatfs.html b/3rdparty/fatfs-0.10b/doc/en/sfatfs.html similarity index 98% rename from src/gfile/fatfs/doc/en/sfatfs.html rename to 3rdparty/fatfs-0.10b/doc/en/sfatfs.html index b420850e..d81e84b2 100644 --- a/src/gfile/fatfs/doc/en/sfatfs.html +++ b/3rdparty/fatfs-0.10b/doc/en/sfatfs.html @@ -1,54 +1,54 @@ - - - - - - - - -FatFs - FATFS - - - - -
-

FATFS

-

The FATFS structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount() function. Initialization is done on first API call after f_mount() function or media change. Application program must not modify any member in this structure.

-
-typedef struct {
-    BYTE    fs_type;      /* FAT sub-type (0:Not mounted) */
-    BYTE    drv;          /* Physical drive number */
-    BYTE    csize;        /* Sectors per cluster (1,2,4,...,128) */
-    BYTE    n_fats;       /* Number of FAT copies (1,2) */
-    BYTE    wflag;        /* win[] flag (b0:win[] is dirty) */
-    BYTE    fsi_flag;     /* FSINFO flags (b7:Disabled, b0:Dirty) */
-    WORD    id;           /* File system mount ID */
-    WORD    n_rootdir;    /* Number of root directory entries (FAT12/16) */
-#if _MAX_SS != _MIN_SS
-    WORD    ssize;        /* Sector size (512,1024,2048 or 4096) */
-#endif
-#if _FS_REENTRANT
-    _SYNC_t sobj;         /* Identifier of sync object */
-#endif
-#if !_FS_READONLY
-    DWORD   last_clust;   /* FSINFO: Last allocated cluster */
-    DWORD   free_clust;   /* FSINFO: Number of free clusters */
-#endif
-#if _FS_RPATH
-    DWORD   cdir;         /* Current directory start cluster (0:root) */
-#endif
-    DWORD   n_fatent;     /* Number of FAT entries (== Number of clusters + 2) */
-    DWORD   fsize;        /* Sectors per FAT */
-    DWORD   volbase;      /* Volume start sector */
-    DWORD   fatbase;      /* FAT area start sector */
-    DWORD   dirbase;      /* Root directory area start sector (FAT32: Cluster#) */
-    DWORD   database;     /* Data area start sector */
-    DWORD   winsect;      /* Current sector appearing in the win[] */
-    BYTE    win[_MAX_SS]; /* Disk access window for directory, FAT (and file data at tiny cfg) */
-} FATFS;
-
-
- -

Return

- - + + + + + + + + +FatFs - FATFS + + + + +
+

FATFS

+

The FATFS structure (file system object) holds dynamic work area of individual logical drives. It is given by application program and registerd/unregisterd to the FatFs module with f_mount() function. Initialization is done on first API call after f_mount() function or media change. Application program must not modify any member in this structure.

+
+typedef struct {
+    BYTE    fs_type;      /* FAT sub-type (0:Not mounted) */
+    BYTE    drv;          /* Physical drive number */
+    BYTE    csize;        /* Sectors per cluster (1,2,4,...,128) */
+    BYTE    n_fats;       /* Number of FAT copies (1,2) */
+    BYTE    wflag;        /* win[] flag (b0:win[] is dirty) */
+    BYTE    fsi_flag;     /* FSINFO flags (b7:Disabled, b0:Dirty) */
+    WORD    id;           /* File system mount ID */
+    WORD    n_rootdir;    /* Number of root directory entries (FAT12/16) */
+#if _MAX_SS != _MIN_SS
+    WORD    ssize;        /* Sector size (512,1024,2048 or 4096) */
+#endif
+#if _FS_REENTRANT
+    _SYNC_t sobj;         /* Identifier of sync object */
+#endif
+#if !_FS_READONLY
+    DWORD   last_clust;   /* FSINFO: Last allocated cluster */
+    DWORD   free_clust;   /* FSINFO: Number of free clusters */
+#endif
+#if _FS_RPATH
+    DWORD   cdir;         /* Current directory start cluster (0:root) */
+#endif
+    DWORD   n_fatent;     /* Number of FAT entries (== Number of clusters + 2) */
+    DWORD   fsize;        /* Sectors per FAT */
+    DWORD   volbase;      /* Volume start sector */
+    DWORD   fatbase;      /* FAT area start sector */
+    DWORD   dirbase;      /* Root directory area start sector (FAT32: Cluster#) */
+    DWORD   database;     /* Data area start sector */
+    DWORD   winsect;      /* Current sector appearing in the win[] */
+    BYTE    win[_MAX_SS]; /* Disk access window for directory, FAT (and file data at tiny cfg) */
+} FATFS;
+
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/sfile.html b/3rdparty/fatfs-0.10b/doc/en/sfile.html similarity index 98% rename from src/gfile/fatfs/doc/en/sfile.html rename to 3rdparty/fatfs-0.10b/doc/en/sfile.html index e6edf702..930573e8 100644 --- a/src/gfile/fatfs/doc/en/sfile.html +++ b/3rdparty/fatfs-0.10b/doc/en/sfile.html @@ -1,49 +1,49 @@ - - - - - - - - -FatFs - FIL - - - - -
-

FIL

-

The FIL structure (file object) holds state of an open file. It is created by f_open() function and discarded by f_close() function. Application program must not modify any member in this structure except for cltbl. Note that a sector buffer is defined in this structure at non-tiny configuration, so that the FIL structures should not be defined as auto variable.

- -
-typedef struct {
-    FATFS*  fs;           /* Pointer to the owner file system object */
-    WORD    id;           /* Owner file system mount ID */
-    BYTE    flag;         /* File object status flags */
-    BYTE    err;          /* Abort flag (error code) */
-    DWORD   fptr;         /* File read/write pointer (Byte offset origin from top of the file) */
-    DWORD   fsize;        /* File size in unit of byte */
-    DWORD   sclust;       /* File start cluster */
-    DWORD   clust;        /* Current cluster */
-    DWORD   dsect;        /* Current data sector */
-#if !_FS_READONLY
-    DWORD   dir_sect;     /* Sector containing the directory entry */
-    BYTE*   dir_ptr;      /* Ponter to the directory entry in the window */
-#endif
-#if _USE_FASTSEEK
-    DWORD*  cltbl;        /* Pointer to the cluster link map table (Nulled on file open) */
-#endif
-#if _FS_LOCK
-    UINT    lockid;       /* Fle lock ID */
-#endif
-#if !_FS_TINY
-    BYTE    buf[_MAX_SS]; /* File private data transfer buffer */
-#endif
-} FIL;
-
- -
- -

Return

- - + + + + + + + + +FatFs - FIL + + + + +
+

FIL

+

The FIL structure (file object) holds state of an open file. It is created by f_open() function and discarded by f_close() function. Application program must not modify any member in this structure except for cltbl. Note that a sector buffer is defined in this structure at non-tiny configuration, so that the FIL structures should not be defined as auto variable.

+ +
+typedef struct {
+    FATFS*  fs;           /* Pointer to the owner file system object */
+    WORD    id;           /* Owner file system mount ID */
+    BYTE    flag;         /* File object status flags */
+    BYTE    err;          /* Abort flag (error code) */
+    DWORD   fptr;         /* File read/write pointer (Byte offset origin from top of the file) */
+    DWORD   fsize;        /* File size in unit of byte */
+    DWORD   sclust;       /* File start cluster */
+    DWORD   clust;        /* Current cluster */
+    DWORD   dsect;        /* Current data sector */
+#if !_FS_READONLY
+    DWORD   dir_sect;     /* Sector containing the directory entry */
+    BYTE*   dir_ptr;      /* Ponter to the directory entry in the window */
+#endif
+#if _USE_FASTSEEK
+    DWORD*  cltbl;        /* Pointer to the cluster link map table (Nulled on file open) */
+#endif
+#if _FS_LOCK
+    UINT    lockid;       /* Fle lock ID */
+#endif
+#if !_FS_TINY
+    BYTE    buf[_MAX_SS]; /* File private data transfer buffer */
+#endif
+} FIL;
+
+ +
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/sfileinfo.html b/3rdparty/fatfs-0.10b/doc/en/sfileinfo.html similarity index 97% rename from src/gfile/fatfs/doc/en/sfileinfo.html rename to 3rdparty/fatfs-0.10b/doc/en/sfileinfo.html index 5674086f..a862a813 100644 --- a/src/gfile/fatfs/doc/en/sfileinfo.html +++ b/3rdparty/fatfs-0.10b/doc/en/sfileinfo.html @@ -1,70 +1,70 @@ - - - - - - - - -FatFs - FILINFO - - - - -
-

FILINFO

-

The FILINFO structure holds a file information returned by f_readdir() and f_stat() function.

-
-typedef struct {
-    DWORD fsize;      /* File size */
-    WORD  fdate;      /* Last modified date */
-    WORD  ftime;      /* Last modified time */
-    BYTE  fattrib;    /* Attribute */
-    TCHAR fname[13];  /* Short file name (8.3 format) */
-#if _USE_LFN
-    TCHAR* lfname;    /* Pointer to the LFN buffer */
-    int   lfsize;     /* Size of the LFN buffer in unit of TCHAR */
-#endif
-} FILINFO;
-
-
- -

Members

-
-
fsize
-
Indicates size of the file in unit of byte. Always zero for directories.
-
fdate
-
Indicates the date that the file was modified or the directory was created.
-
-
bit15:9
-
Year origin from 1980 (0..127)
-
bit8:5
-
Month (1..12)
-
bit4:0
-
Day (1..31)
-
-
-
ftime
-
Indicates the time that the file was modified or the directory was created.
-
-
bit15:11
-
Hour (0..23)
-
bit10:5
-
Minute (0..59)
-
bit4:0
-
Second / 2 (0..29)
-
-
-
fattrib
-
Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
-
fname[]
-
Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case in non-LFN configuration but it can be returned with lower case in LFN configuration.
-
lfname
-
Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Set null pointer if LFN is not needed. Not available in non-LFN configuration.
-
lfsize
-
Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.
-
- -

Return

- - + + + + + + + + +FatFs - FILINFO + + + + +
+

FILINFO

+

The FILINFO structure holds a file information returned by f_readdir() and f_stat() function.

+
+typedef struct {
+    DWORD fsize;      /* File size */
+    WORD  fdate;      /* Last modified date */
+    WORD  ftime;      /* Last modified time */
+    BYTE  fattrib;    /* Attribute */
+    TCHAR fname[13];  /* Short file name (8.3 format) */
+#if _USE_LFN
+    TCHAR* lfname;    /* Pointer to the LFN buffer */
+    int   lfsize;     /* Size of the LFN buffer in unit of TCHAR */
+#endif
+} FILINFO;
+
+
+ +

Members

+
+
fsize
+
Indicates size of the file in unit of byte. Always zero for directories.
+
fdate
+
Indicates the date that the file was modified or the directory was created.
+
+
bit15:9
+
Year origin from 1980 (0..127)
+
bit8:5
+
Month (1..12)
+
bit4:0
+
Day (1..31)
+
+
+
ftime
+
Indicates the time that the file was modified or the directory was created.
+
+
bit15:11
+
Hour (0..23)
+
bit10:5
+
Minute (0..59)
+
bit4:0
+
Second / 2 (0..29)
+
+
+
fattrib
+
Indicates the file/directory attribute in combination of AM_DIR, AM_RDO, AM_HID, AM_SYS and AM_ARC.
+
fname[]
+
Indicates the file/directory name in 8.3 format null-terminated string. It is always returnd with upper case in non-LFN configuration but it can be returned with lower case in LFN configuration.
+
lfname
+
Pointer to the LFN buffer to store the read LFN. This member must be initialized by application prior to use this structure. Set null pointer if LFN is not needed. Not available in non-LFN configuration.
+
lfsize
+
Size of the LFN buffer in unit of TCHAR. This member must be initialized by application prior to use this structure. Not available in non-LFN configuration.
+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/size.html b/3rdparty/fatfs-0.10b/doc/en/size.html similarity index 96% rename from src/gfile/fatfs/doc/en/size.html rename to 3rdparty/fatfs-0.10b/doc/en/size.html index bb786c61..f297d20c 100644 --- a/src/gfile/fatfs/doc/en/size.html +++ b/3rdparty/fatfs-0.10b/doc/en/size.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_size - - - - -
-

f_size

-

The f_size function gets the size of a file.

-
-DWORD f_size (
-  FIL* fp   /* [IN] File object */
-);
-
-
- - -
-

Parameters

-
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Values

-

Returns the size of the file in unit of byte.

-
- - -
-

Description

-

In this revision, the f_size() function is implemented as a macro.

-
-#define f_size(fp) ((fp)->fsize)
-
-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, f_lseek, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_size + + + + +
+

f_size

+

The f_size function gets the size of a file.

+
+DWORD f_size (
+  FIL* fp   /* [IN] File object */
+);
+
+
+ + +
+

Parameters

+
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Values

+

Returns the size of the file in unit of byte.

+
+ + +
+

Description

+

In this revision, the f_size() function is implemented as a macro.

+
+#define f_size(fp) ((fp)->fsize)
+
+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, f_lseek, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/stat.html b/3rdparty/fatfs-0.10b/doc/en/stat.html similarity index 97% rename from src/gfile/fatfs/doc/en/stat.html rename to 3rdparty/fatfs-0.10b/doc/en/stat.html index 8ea343b8..fb0d94a1 100644 --- a/src/gfile/fatfs/doc/en/stat.html +++ b/3rdparty/fatfs-0.10b/doc/en/stat.html @@ -1,74 +1,74 @@ - - - - - - - - -FatFs - f_stat - - - - -
-

f_stat

-

The f_stat function checks the existence of a file or sub-directory.

-
-FRESULT f_stat (
-  const TCHAR* path,  /* [IN] Object name */
-  FILINFO* fno        /* [OUT] FILINFO structure */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to the null-terminated string that specifies the object to get its information.
-
fno
-
Pointer to the blank FILINFO structure to store the information of the object. Set null pointer if it is not needed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_stat() function checks the existence of a file or sub-directory. If not exist, the function returns with FR_NO_FILE. If exist, the function returns with FR_OK and the informations of the object, file size, timestamp, attribute and SFN, are stored to the file information structure. For details of the file information, refer to the FILINFO structure and f_readdir() function.

-
- - -
-

QuickInfo

-

Available when _FS_MINIMIZE == 0.

-
- - -
-

References

-

f_opendir, f_readdir, FILINFO

-
- -

Return

- - + + + + + + + + +FatFs - f_stat + + + + +
+

f_stat

+

The f_stat function checks the existence of a file or sub-directory.

+
+FRESULT f_stat (
+  const TCHAR* path,  /* [IN] Object name */
+  FILINFO* fno        /* [OUT] FILINFO structure */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to the null-terminated string that specifies the object to get its information.
+
fno
+
Pointer to the blank FILINFO structure to store the information of the object. Set null pointer if it is not needed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_stat() function checks the existence of a file or sub-directory. If not exist, the function returns with FR_NO_FILE. If exist, the function returns with FR_OK and the informations of the object, file size, timestamp, attribute and SFN, are stored to the file information structure. For details of the file information, refer to the FILINFO structure and f_readdir() function.

+
+ + +
+

QuickInfo

+

Available when _FS_MINIMIZE == 0.

+
+ + +
+

References

+

f_opendir, f_readdir, FILINFO

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/sync.html b/3rdparty/fatfs-0.10b/doc/en/sync.html similarity index 97% rename from src/gfile/fatfs/doc/en/sync.html rename to 3rdparty/fatfs-0.10b/doc/en/sync.html index 3e86b7ff..09bab3d9 100644 --- a/src/gfile/fatfs/doc/en/sync.html +++ b/3rdparty/fatfs-0.10b/doc/en/sync.html @@ -1,66 +1,66 @@ - - - - - - - - -FatFs - f_sync - - - - -
-

f_sync

-

The f_sync function flushes the cached information of a writing file.

-
-FRESULT f_sync (
-  FIL* fp     /* [IN] File object */
-);
-
-
- -
-

Parameter

-
-
fp
-
Pointer to the open file object to be flushed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_sync() function performs the same process as f_close() function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync() function of periodic or immediataly after f_write() function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to application note.

-

However there is no sense in f_sync() function immediataly before f_close() function because it performs f_sync() function in it. In other words, the differnce between those functions is that the file object is invalidated or not.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0.

-
- - -
-

See Also

-

f_close

-
- -

Return

- - + + + + + + + + +FatFs - f_sync + + + + +
+

f_sync

+

The f_sync function flushes the cached information of a writing file.

+
+FRESULT f_sync (
+  FIL* fp     /* [IN] File object */
+);
+
+
+ +
+

Parameter

+
+
fp
+
Pointer to the open file object to be flushed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_sync() function performs the same process as f_close() function but the file is left opened and can continue read/write/seek operations to the file. This is suitable for the applications that open files for a long time in write mode, such as data logger. Performing f_sync() function of periodic or immediataly after f_write() function can minimize the risk of data loss due to a sudden blackout or an unintentional media removal. For more information, refer to application note.

+

However there is no sense in f_sync() function immediataly before f_close() function because it performs f_sync() function in it. In other words, the differnce between those functions is that the file object is invalidated or not.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0.

+
+ + +
+

See Also

+

f_close

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/tell.html b/3rdparty/fatfs-0.10b/doc/en/tell.html similarity index 96% rename from src/gfile/fatfs/doc/en/tell.html rename to 3rdparty/fatfs-0.10b/doc/en/tell.html index 93d03c91..2ad86ae9 100644 --- a/src/gfile/fatfs/doc/en/tell.html +++ b/3rdparty/fatfs-0.10b/doc/en/tell.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_tell - - - - -
-

f_tell

-

The f_tell function gets the current read/write pointer of a file.

-
-DWORD f_tell (
-  FIL* fp   /* [IN] File object */
-);
-
-
- - -
-

Parameters

-
-
fp
-
Pointer to the open file object structure.
-
-
- - -
-

Return Values

-

Returns current read/write pointer of the file.

-
- - -
-

Description

-

In this revision, the f_tell() function is implemented as a macro.

-
-#define f_tell(fp) ((fp)->fptr)
-
-
- - -
-

QuickInfo

-

Always available.

-
- - -
-

See Also

-

f_open, f_lseek, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_tell + + + + +
+

f_tell

+

The f_tell function gets the current read/write pointer of a file.

+
+DWORD f_tell (
+  FIL* fp   /* [IN] File object */
+);
+
+
+ + +
+

Parameters

+
+
fp
+
Pointer to the open file object structure.
+
+
+ + +
+

Return Values

+

Returns current read/write pointer of the file.

+
+ + +
+

Description

+

In this revision, the f_tell() function is implemented as a macro.

+
+#define f_tell(fp) ((fp)->fptr)
+
+
+ + +
+

QuickInfo

+

Always available.

+
+ + +
+

See Also

+

f_open, f_lseek, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/truncate.html b/3rdparty/fatfs-0.10b/doc/en/truncate.html similarity index 96% rename from src/gfile/fatfs/doc/en/truncate.html rename to 3rdparty/fatfs-0.10b/doc/en/truncate.html index 7dc980d4..eb0989ec 100644 --- a/src/gfile/fatfs/doc/en/truncate.html +++ b/3rdparty/fatfs-0.10b/doc/en/truncate.html @@ -1,66 +1,66 @@ - - - - - - - - -FatFs - f_truncate - - - - -
-

f_truncate

-

The f_truncate function truncates the file size.

-
-FRESULT f_truncate (
-  FIL* fp     /* [IN] File object */
-);
-
-
- -
-

Parameter

-
-
fp
-
Pointer to the open file object to be truncated.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The f_truncate() function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

See Also

-

f_open, f_lseek, FIL

-
- - -

Return

- - + + + + + + + + +FatFs - f_truncate + + + + +
+

f_truncate

+

The f_truncate function truncates the file size.

+
+FRESULT f_truncate (
+  FIL* fp     /* [IN] File object */
+);
+
+
+ +
+

Parameter

+
+
fp
+
Pointer to the open file object to be truncated.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The f_truncate() function truncates the file size to the current file read/write pointer. This function has no effect if the file read/write pointer is already pointing end of the file.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

See Also

+

f_open, f_lseek, FIL

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/unlink.html b/3rdparty/fatfs-0.10b/doc/en/unlink.html similarity index 97% rename from src/gfile/fatfs/doc/en/unlink.html rename to 3rdparty/fatfs-0.10b/doc/en/unlink.html index fc884c3c..deb96b98 100644 --- a/src/gfile/fatfs/doc/en/unlink.html +++ b/3rdparty/fatfs-0.10b/doc/en/unlink.html @@ -1,75 +1,75 @@ - - - - - - - - -FatFs - f_unlink - - - - -
-

f_unlink

-

The f_unlink function removes a file or sub-directory.

-
-FRESULT f_unlink (
-  const TCHAR* path  /* [IN] Object name */
-);
-
-
- -
-

Parameter

-
-
path
-
Pointer to the null-terminated string that specifies an object to be removed.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_DENIED, -FR_EXIST, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_LOCKED, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

-If condition of the object to be removed is applicable to the following terms, the function will be rejected.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -

Return

- - + + + + + + + + +FatFs - f_unlink + + + + +
+

f_unlink

+

The f_unlink function removes a file or sub-directory.

+
+FRESULT f_unlink (
+  const TCHAR* path  /* [IN] Object name */
+);
+
+
+ +
+

Parameter

+
+
path
+
Pointer to the null-terminated string that specifies an object to be removed.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_DENIED, +FR_EXIST, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_LOCKED, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

+If condition of the object to be removed is applicable to the following terms, the function will be rejected.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/utime.html b/3rdparty/fatfs-0.10b/doc/en/utime.html similarity index 96% rename from src/gfile/fatfs/doc/en/utime.html rename to 3rdparty/fatfs-0.10b/doc/en/utime.html index 7466c19f..2174a05d 100644 --- a/src/gfile/fatfs/doc/en/utime.html +++ b/3rdparty/fatfs-0.10b/doc/en/utime.html @@ -1,99 +1,99 @@ - - - - - - - - -FatFs - f_utime - - - - -
-

f_utime

-

The f_utime function changes the timestamp of a file or sub-directory.

-
-FRESULT f_utime (
-  const TCHAR* path,  /* [IN] Object name */
-  const FILINFO* fno  /* [IN] Time and data to be set */
-);
-
-
- -
-

Parameters

-
-
path
-
Pointer to the null-terminated string that specifies an object to be changed.
-
fno
-
Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_NO_FILE, -FR_NO_PATH, -FR_INVALID_NAME, -FR_WRITE_PROTECTED, -FR_INVALID_DRIVE, -FR_NOT_ENABLED, -FR_NO_FILESYSTEM, -FR_TIMEOUT, -FR_NOT_ENOUGH_CORE -

-
- - -
-

Description

-

The f_utime() function changes the timestamp of a file or sub-directory

-
- - -
-

Example

-
-FRESULT set_timestamp (
-    char *obj,     /* Pointer to the file name */
-    int year,
-    int month,
-    int mday,
-    int hour,
-    int min,
-    int sec
-)
-{
-    FILINFO fno;
-
-    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
-    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
-
-    return f_utime(obj, &fno);
-}
-
-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

-
- - -
-

See Also

-

f_stat, FILINFO

-
- -

Return

- - + + + + + + + + +FatFs - f_utime + + + + +
+

f_utime

+

The f_utime function changes the timestamp of a file or sub-directory.

+
+FRESULT f_utime (
+  const TCHAR* path,  /* [IN] Object name */
+  const FILINFO* fno  /* [IN] Time and data to be set */
+);
+
+
+ +
+

Parameters

+
+
path
+
Pointer to the null-terminated string that specifies an object to be changed.
+
fno
+
Pointer to the file information structure that has a timestamp to be set in member fdate and ftime. Do not care any other members.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_NO_FILE, +FR_NO_PATH, +FR_INVALID_NAME, +FR_WRITE_PROTECTED, +FR_INVALID_DRIVE, +FR_NOT_ENABLED, +FR_NO_FILESYSTEM, +FR_TIMEOUT, +FR_NOT_ENOUGH_CORE +

+
+ + +
+

Description

+

The f_utime() function changes the timestamp of a file or sub-directory

+
+ + +
+

Example

+
+FRESULT set_timestamp (
+    char *obj,     /* Pointer to the file name */
+    int year,
+    int month,
+    int mday,
+    int hour,
+    int min,
+    int sec
+)
+{
+    FILINFO fno;
+
+    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
+    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
+
+    return f_utime(obj, &fno);
+}
+
+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0 and _FS_MINIMIZE == 0.

+
+ + +
+

See Also

+

f_stat, FILINFO

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/en/write.html b/3rdparty/fatfs-0.10b/doc/en/write.html similarity index 97% rename from src/gfile/fatfs/doc/en/write.html rename to 3rdparty/fatfs-0.10b/doc/en/write.html index 925fd564..a12af694 100644 --- a/src/gfile/fatfs/doc/en/write.html +++ b/3rdparty/fatfs-0.10b/doc/en/write.html @@ -1,74 +1,74 @@ - - - - - - - - -FatFs - f_write - - - - -
-

f_write

-

The f_write writes data to a file.

-
-FRESULT f_write (
-  FIL* fp,          /* [IN] Pointer to the file object structure */
-  const void* buff, /* [IN] Pointer to the data to be written */
-  UINT btw,         /* [IN] Number of bytes to write */
-  UINT* bw          /* [OUT] Pointer to the variable to return number of bytes written */
-);
-
-
- -
-

Parameters

-
-
fp
-
Pointer to the open file object structure.
-
buff
-
Pointer to the data to be written.
-
btw
-
Specifies number of bytes to write in range of UINT type.
-
bw
-
Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.
-
-
- - -
-

Return Values

-

-FR_OK, -FR_DISK_ERR, -FR_INT_ERR, -FR_NOT_READY, -FR_INVALID_OBJECT, -FR_TIMEOUT -

-
- - -
-

Description

-

The read/write pointer of the file object advances number of bytes written. After the function succeeded, *bw should be checked to detect the disk full. In case of *bw is less than btw, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.

-
- - -
-

QuickInfo

-

Available when _FS_READONLY == 0.

-
- - -
-

See Also

-

f_open, f_read, fputc, fputs, fprintf, f_close, FIL

-
- -

Return

- - + + + + + + + + +FatFs - f_write + + + + +
+

f_write

+

The f_write writes data to a file.

+
+FRESULT f_write (
+  FIL* fp,          /* [IN] Pointer to the file object structure */
+  const void* buff, /* [IN] Pointer to the data to be written */
+  UINT btw,         /* [IN] Number of bytes to write */
+  UINT* bw          /* [OUT] Pointer to the variable to return number of bytes written */
+);
+
+
+ +
+

Parameters

+
+
fp
+
Pointer to the open file object structure.
+
buff
+
Pointer to the data to be written.
+
btw
+
Specifies number of bytes to write in range of UINT type.
+
bw
+
Pointer to the UINT variable to return the number of bytes written. The value is always valid after the function call regardless of the result.
+
+
+ + +
+

Return Values

+

+FR_OK, +FR_DISK_ERR, +FR_INT_ERR, +FR_NOT_READY, +FR_INVALID_OBJECT, +FR_TIMEOUT +

+
+ + +
+

Description

+

The read/write pointer of the file object advances number of bytes written. After the function succeeded, *bw should be checked to detect the disk full. In case of *bw is less than btw, it means the volume got full during the write operation. The function can take a time when the volume is full or close to full.

+
+ + +
+

QuickInfo

+

Available when _FS_READONLY == 0.

+
+ + +
+

See Also

+

f_open, f_read, fputc, fputs, fprintf, f_close, FIL

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/img/app1.c b/3rdparty/fatfs-0.10b/doc/img/app1.c similarity index 95% rename from src/gfile/fatfs/doc/img/app1.c rename to 3rdparty/fatfs-0.10b/doc/img/app1.c index c7e690be..b3ff7fd7 100644 --- a/src/gfile/fatfs/doc/img/app1.c +++ b/3rdparty/fatfs-0.10b/doc/img/app1.c @@ -1,43 +1,43 @@ -/*------------------------------------------------------------/ -/ Open or create a file in append mode -/------------------------------------------------------------*/ - -FRESULT open_append ( - FIL* fp, /* [OUT] File object to create */ - const char* path /* [IN] File name to be opened */ -) -{ - FRESULT fr; - - /* Opens an existing file. If not exist, creates a new file. */ - fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS); - if (fr == FR_OK) { - /* Seek to end of the file to append data */ - fr = f_lseek(fp, f_size(fp)); - if (fr != FR_OK) - f_close(fp); - } - return fr; -} - - -int main (void) -{ - FRESULT fr; - FATFS fs; - FIL fil; - - /* Open or create a log file and ready to append */ - f_mount(&fs, "", 0); - fr = open_append(&fil, "logfile.txt"); - if (fr != FR_OK) return 1; - - /* Append a line */ - f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min); - - /* Close the file */ - f_close(&fil); - - return 0; -} - +/*------------------------------------------------------------/ +/ Open or create a file in append mode +/------------------------------------------------------------*/ + +FRESULT open_append ( + FIL* fp, /* [OUT] File object to create */ + const char* path /* [IN] File name to be opened */ +) +{ + FRESULT fr; + + /* Opens an existing file. If not exist, creates a new file. */ + fr = f_open(fp, path, FA_WRITE | FA_OPEN_ALWAYS); + if (fr == FR_OK) { + /* Seek to end of the file to append data */ + fr = f_lseek(fp, f_size(fp)); + if (fr != FR_OK) + f_close(fp); + } + return fr; +} + + +int main (void) +{ + FRESULT fr; + FATFS fs; + FIL fil; + + /* Open or create a log file and ready to append */ + f_mount(&fs, "", 0); + fr = open_append(&fil, "logfile.txt"); + if (fr != FR_OK) return 1; + + /* Append a line */ + f_printf(&fil, "%02u/%02u/%u, %2u:%02u\n", Mday, Mon, Year, Hour, Min); + + /* Close the file */ + f_close(&fil); + + return 0; +} + diff --git a/src/gfile/fatfs/doc/img/app2.c b/3rdparty/fatfs-0.10b/doc/img/app2.c similarity index 95% rename from src/gfile/fatfs/doc/img/app2.c rename to 3rdparty/fatfs-0.10b/doc/img/app2.c index 51085433..b1ecd785 100644 --- a/src/gfile/fatfs/doc/img/app2.c +++ b/3rdparty/fatfs-0.10b/doc/img/app2.c @@ -1,70 +1,70 @@ -/*------------------------------------------------------------/ -/ Remove all contents of a directory -/ This function works regardless of _FS_RPATH. -/------------------------------------------------------------*/ - - -FRESULT empty_directory ( - char* path /* Working buffer filled with start directory */ -) -{ - UINT i, j; - FRESULT fr; - DIR dir; - FILINFO fno; - -#if _USE_LFN - fno.lfname = 0; /* Disable LFN output */ -#endif - fr = f_opendir(&dir, path); - if (fr == FR_OK) { - for (i = 0; path[i]; i++) ; - path[i++] = '/'; - for (;;) { - fr = f_readdir(&dir, &fno); - if (fr != FR_OK || !fno.fname[0]) break; - if (_FS_RPATH && fno.fname[0] == '.') continue; - j = 0; - do - path[i+j] = fno.fname[j]; - while (fno.fname[j++]); - if (fno.fattrib & AM_DIR) { - fr = empty_directory(path); - if (fr != FR_OK) break; - } - fr = f_unlink(path); - if (fr != FR_OK) break; - } - path[--i] = '\0'; - closedir(&dir); - } - - return fr; -} - - - -int main (void) -{ - FRESULT fr; - FATFS fs; - char buff[64]; /* Working buffer */ - - - - f_mount(&fs, "", 0); - - strcpy(buff, "/"); /* Directory to be emptied */ - fr = empty_directory(buff); - - if (fr) { - printf("Function failed. (%u)\n", fr); - return fr; - } else { - printf("All contents in the %s are successfully removed.\n", buff); - return 0; - } -} - - - +/*------------------------------------------------------------/ +/ Remove all contents of a directory +/ This function works regardless of _FS_RPATH. +/------------------------------------------------------------*/ + + +FRESULT empty_directory ( + char* path /* Working buffer filled with start directory */ +) +{ + UINT i, j; + FRESULT fr; + DIR dir; + FILINFO fno; + +#if _USE_LFN + fno.lfname = 0; /* Disable LFN output */ +#endif + fr = f_opendir(&dir, path); + if (fr == FR_OK) { + for (i = 0; path[i]; i++) ; + path[i++] = '/'; + for (;;) { + fr = f_readdir(&dir, &fno); + if (fr != FR_OK || !fno.fname[0]) break; + if (_FS_RPATH && fno.fname[0] == '.') continue; + j = 0; + do + path[i+j] = fno.fname[j]; + while (fno.fname[j++]); + if (fno.fattrib & AM_DIR) { + fr = empty_directory(path); + if (fr != FR_OK) break; + } + fr = f_unlink(path); + if (fr != FR_OK) break; + } + path[--i] = '\0'; + closedir(&dir); + } + + return fr; +} + + + +int main (void) +{ + FRESULT fr; + FATFS fs; + char buff[64]; /* Working buffer */ + + + + f_mount(&fs, "", 0); + + strcpy(buff, "/"); /* Directory to be emptied */ + fr = empty_directory(buff); + + if (fr) { + printf("Function failed. (%u)\n", fr); + return fr; + } else { + printf("All contents in the %s are successfully removed.\n", buff); + return 0; + } +} + + + diff --git a/src/gfile/fatfs/doc/img/app3.c b/3rdparty/fatfs-0.10b/doc/img/app3.c similarity index 97% rename from src/gfile/fatfs/doc/img/app3.c rename to 3rdparty/fatfs-0.10b/doc/img/app3.c index 736c15aa..32b14237 100644 --- a/src/gfile/fatfs/doc/img/app3.c +++ b/3rdparty/fatfs-0.10b/doc/img/app3.c @@ -1,106 +1,106 @@ -/*----------------------------------------------------------------------/ -/ Allocate a contiguous area to the file -/-----------------------------------------------------------------------/ -/ This function checks if the file is contiguous with desired size. -/ If not, a block of contiguous sectors is allocated to the file. -/ If the file has been opened without FA_WRITE flag, it only checks if -/ the file is contiguous and returns the resulut. */ - -#if _FATFS != 8051 /* Check if R0.10b */ -#error This function may not be compatible with this revision of FatFs module. -#endif - -/* Declarations of FatFs internal functions accessible from applications. -/ This is intended to be used for disk checking/fixing or dirty hacks :-) */ -DWORD clust2sect (FATFS* fs, DWORD clst); -DWORD get_fat (FATFS* fs, DWORD clst); -FRESULT put_fat (FATFS* fs, DWORD clst, DWORD val); - - -DWORD allocate_contiguous_clusters ( /* Returns the first sector in LBA (0:error or not contiguous) */ - FIL* fp, /* Pointer to the open file object */ - DWORD len /* Number of bytes to allocate */ -) -{ - DWORD csz, tcl, ncl, ccl, cl; - - - if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */ - return 0; - csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */ - tcl = (len + csz - 1) / csz; /* Total number of clusters required */ - len = tcl * csz; /* Round-up file size to the cluster boundary */ - - /* Check if the existing cluster chain is contiguous */ - if (len == fp->fsize) { - ncl = 0; ccl = fp->sclust; - do { - cl = get_fat(fp->fs, ccl); /* Get the cluster status */ - if (cl + 1 < 3) return 0; /* Hard error? */ - if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */ - ccl = cl; - } while (++ncl < tcl); - if (ncl == tcl) /* Is the file contiguous? */ - return clust2sect(fp->fs, fp->sclust); /* Return file start sector */ - } -#if _FS_READONLY - return 0; -#else - if (f_truncate(fp)) return 0; /* Remove the existing chain */ - - /* Find a free contiguous area */ - ccl = cl = 2; ncl = 0; - do { - if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */ - if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */ - do { /* Skip the block of used clusters */ - cl++; - if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */ - } while (get_fat(fp->fs, cl)); - ccl = cl; ncl = 0; - } - cl++; ncl++; - } while (ncl < tcl); - - /* Create a contiguous cluster chain */ - fp->fs->last_clust = ccl - 1; - if (f_lseek(fp, len)) return 0; - - return clust2sect(fp->fs, fp->sclust); /* Return file start sector */ -#endif -} - - -int main (void) -{ - FRESULT fr; - DRESULT dr; - FATFS fs; - FIL fil; - DWORD org; - - - /* Open or create a file */ - f_mount(&fs, "", 0); - fr = f_open(&fil, "swapfile.sys", FA_READ | FA_WRITE | FA_OPEN_ALWAYS); - if (fr) return 1; - - /* Check if the file is 64MB in size and occupies a contiguous area. - / If not, a contiguous area will be re-allocated to the file. */ - org = allocate_contiguous_clusters(&fil, 0x4000000); - if (!org) { - printf("Function failed due to any error or insufficient contiguous area.\n"); - f_close(&fil); - return 1; - } - - /* Now you can read/write the file with disk functions bypassing the file system layer. */ - - dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512KiB from top of the file */ - - ... - - f_close(&fil); - return 0; -} - +/*----------------------------------------------------------------------/ +/ Allocate a contiguous area to the file +/-----------------------------------------------------------------------/ +/ This function checks if the file is contiguous with desired size. +/ If not, a block of contiguous sectors is allocated to the file. +/ If the file has been opened without FA_WRITE flag, it only checks if +/ the file is contiguous and returns the resulut. */ + +#if _FATFS != 8051 /* Check if R0.10b */ +#error This function may not be compatible with this revision of FatFs module. +#endif + +/* Declarations of FatFs internal functions accessible from applications. +/ This is intended to be used for disk checking/fixing or dirty hacks :-) */ +DWORD clust2sect (FATFS* fs, DWORD clst); +DWORD get_fat (FATFS* fs, DWORD clst); +FRESULT put_fat (FATFS* fs, DWORD clst, DWORD val); + + +DWORD allocate_contiguous_clusters ( /* Returns the first sector in LBA (0:error or not contiguous) */ + FIL* fp, /* Pointer to the open file object */ + DWORD len /* Number of bytes to allocate */ +) +{ + DWORD csz, tcl, ncl, ccl, cl; + + + if (f_lseek(fp, 0) || !len) /* Check if the given parameters are valid */ + return 0; + csz = 512UL * fp->fs->csize; /* Cluster size in unit of byte (assuming 512 bytes/sector) */ + tcl = (len + csz - 1) / csz; /* Total number of clusters required */ + len = tcl * csz; /* Round-up file size to the cluster boundary */ + + /* Check if the existing cluster chain is contiguous */ + if (len == fp->fsize) { + ncl = 0; ccl = fp->sclust; + do { + cl = get_fat(fp->fs, ccl); /* Get the cluster status */ + if (cl + 1 < 3) return 0; /* Hard error? */ + if (cl != ccl + 1 &&; cl < fp->fs->n_fatent) break; /* Not contiguous? */ + ccl = cl; + } while (++ncl < tcl); + if (ncl == tcl) /* Is the file contiguous? */ + return clust2sect(fp->fs, fp->sclust); /* Return file start sector */ + } +#if _FS_READONLY + return 0; +#else + if (f_truncate(fp)) return 0; /* Remove the existing chain */ + + /* Find a free contiguous area */ + ccl = cl = 2; ncl = 0; + do { + if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */ + if (get_fat(fp->fs, cl)) { /* Encounterd a cluster in use */ + do { /* Skip the block of used clusters */ + cl++; + if (cl >= fp->fs->n_fatent) return 0; /* No contiguous area is found. */ + } while (get_fat(fp->fs, cl)); + ccl = cl; ncl = 0; + } + cl++; ncl++; + } while (ncl < tcl); + + /* Create a contiguous cluster chain */ + fp->fs->last_clust = ccl - 1; + if (f_lseek(fp, len)) return 0; + + return clust2sect(fp->fs, fp->sclust); /* Return file start sector */ +#endif +} + + +int main (void) +{ + FRESULT fr; + DRESULT dr; + FATFS fs; + FIL fil; + DWORD org; + + + /* Open or create a file */ + f_mount(&fs, "", 0); + fr = f_open(&fil, "swapfile.sys", FA_READ | FA_WRITE | FA_OPEN_ALWAYS); + if (fr) return 1; + + /* Check if the file is 64MB in size and occupies a contiguous area. + / If not, a contiguous area will be re-allocated to the file. */ + org = allocate_contiguous_clusters(&fil, 0x4000000); + if (!org) { + printf("Function failed due to any error or insufficient contiguous area.\n"); + f_close(&fil); + return 1; + } + + /* Now you can read/write the file with disk functions bypassing the file system layer. */ + + dr = disk_write(fil.fs->drv, Buff, org, 1024); /* Write 512KiB from top of the file */ + + ... + + f_close(&fil); + return 0; +} + diff --git a/src/gfile/fatfs/doc/img/app4.c b/3rdparty/fatfs-0.10b/doc/img/app4.c similarity index 96% rename from src/gfile/fatfs/doc/img/app4.c rename to 3rdparty/fatfs-0.10b/doc/img/app4.c index 993eb4f4..6ddebd90 100644 --- a/src/gfile/fatfs/doc/img/app4.c +++ b/3rdparty/fatfs-0.10b/doc/img/app4.c @@ -1,318 +1,318 @@ -/*----------------------------------------------------------------------/ -/ Low level disk I/O module function checker -/-----------------------------------------------------------------------/ -/ WARNING: The data on the target drive will be lost! -*/ - -#include -#include -#include "ff.h" -#include "diskio.h" - - -static -DWORD pn ( - DWORD pns -) -{ - static DWORD lfsr; - UINT n; - - - if (pns) { - lfsr = pns; - for (n = 0; n < 32; n++) pn(0); - } - if (lfsr & 1) { - lfsr >>= 1; - lfsr ^= 0x80200003; - } else { - lfsr >>= 1; - } - return lfsr; -} - - -int test_diskio ( - BYTE pdrv, /* Physical drive number to be checked (all data on the drive will be lost) */ - UINT ncyc, /* Number of test cycles */ - DWORD* buff, /* Pointer to the working buffer */ - UINT sz_buff /* Size of the working buffer in unit of byte */ -) -{ - UINT n, cc, ns; - DWORD sz_drv, lba, lba2, pns = 1; - WORD sz_sect, sz_eblk; - BYTE *pbuff = (BYTE*)buff; - DSTATUS ds; - DRESULT dr; - - - - printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff); - - if (sz_buff < _MAX_SS + 4) { - printf("Insufficient work area to test.\n"); - return 1; - } - - for (cc = 1; cc <= ncyc; cc++) { - printf("**** Test cycle %u of %u start ****\n", cc, ncyc); - - /* Initialization */ - printf(" disk_initalize(%u)", pdrv); - ds = disk_initialize(pdrv); - if (ds & STA_NOINIT) { - printf(" - failed.\n"); - return 2; - } else { - printf(" - ok.\n"); - } - - /* Get drive size */ - printf("**** Get drive size ****\n"); - printf(" disk_ioctl(%u, GET_SECTOR_COUNT, 0x%08X)", pdrv, (UINT)&sz_drv); - sz_drv = 0; - dr = disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_drv); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 3; - } - if (sz_drv < 128) { - printf("Failed: Insufficient drive size to test.\n"); - return 4; - } - printf(" Number of sectors on the drive %u is %lu.\n", pdrv, sz_drv); - -#if _MAX_SS != _MIN_SS - /* Get sector size */ - printf("**** Get sector size ****\n"); - printf(" disk_ioctl(%u, GET_SECTOR_SIZE, 0x%X)", pdrv, (UINT)&sz_sect); - sz_sect = 0; - dr = disk_ioctl(pdrv, GET_SECTOR_SIZE, &sz_sect); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 5; - } - printf(" Size of sector is %u bytes.\n", sz_sect); -#else - sz_sect = _MAX_SS; -#endif - - /* Get erase block size */ - printf("**** Get block size ****\n"); - printf(" disk_ioctl(%u, GET_BLOCK_SIZE, 0x%X)", pdrv, (UINT)&sz_eblk); - sz_eblk = 0; - dr = disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_eblk); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - } - if (dr == RES_OK || sz_eblk >= 2) { - printf(" Size of the erase block is %u sectors.\n", sz_eblk); - } else { - printf(" Size of the erase block is unknown.\n"); - } - - /* Single sector write test */ - printf("**** Single sector write test 1 ****\n"); - lba = 0; - for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n] = (BYTE)pn(0); - printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); - dr = disk_write(pdrv, pbuff, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 6; - } - printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); - dr = disk_ioctl(pdrv, CTRL_SYNC, 0); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 7; - } - memset(pbuff, 0, sz_sect); - printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); - dr = disk_read(pdrv, pbuff, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 8; - } - for (n = 0, pn(pns); n < sz_sect && pbuff[n] == (BYTE)pn(0); n++) ; - if (n == sz_sect) { - printf(" Data matched.\n"); - } else { - printf("Failed: Read data differs from the data written.\n"); - return 10; - } - pns++; - - /* Multiple sector write test */ - printf("**** Multiple sector write test ****\n"); - lba = 1; ns = sz_buff / sz_sect; - if (ns > 4) ns = 4; - for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0); - printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns); - dr = disk_write(pdrv, pbuff, lba, ns); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 11; - } - printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); - dr = disk_ioctl(pdrv, CTRL_SYNC, 0); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 12; - } - memset(pbuff, 0, sz_sect * ns); - printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns); - dr = disk_read(pdrv, pbuff, lba, ns); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 13; - } - for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ; - if (n == (UINT)(sz_sect * ns)) { - printf(" Data matched.\n"); - } else { - printf("Failed: Read data differs from the data written.\n"); - return 14; - } - pns++; - - /* Single sector write test (misaligned memory address) */ - printf("**** Single sector write test 2 ****\n"); - lba = 5; - for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n+3] = (BYTE)pn(0); - printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+3), lba); - dr = disk_write(pdrv, pbuff+3, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 15; - } - printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); - dr = disk_ioctl(pdrv, CTRL_SYNC, 0); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 16; - } - memset(pbuff+5, 0, sz_sect); - printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+5), lba); - dr = disk_read(pdrv, pbuff+5, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 17; - } - for (n = 0, pn(pns); n < sz_sect && pbuff[n+5] == (BYTE)pn(0); n++) ; - if (n == sz_sect) { - printf(" Data matched.\n"); - } else { - printf("Failed: Read data differs from the data written.\n"); - return 18; - } - pns++; - - /* 4GB barrier test */ - printf("**** 4GB barrier test ****\n"); - if (sz_drv >= 128 + 0x80000000 / (sz_sect / 2)) { - lba = 6; lba2 = lba + 0x80000000 / (sz_sect / 2); - for (n = 0, pn(pns); n < (UINT)(sz_sect * 2); n++) pbuff[n] = (BYTE)pn(0); - printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); - dr = disk_write(pdrv, pbuff, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 19; - } - printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2); - dr = disk_write(pdrv, pbuff+sz_sect, lba2, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 20; - } - printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); - dr = disk_ioctl(pdrv, CTRL_SYNC, 0); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 21; - } - memset(pbuff, 0, sz_sect * 2); - printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); - dr = disk_read(pdrv, pbuff, lba, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 22; - } - printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2); - dr = disk_read(pdrv, pbuff+sz_sect, lba2, 1); - if (dr == RES_OK) { - printf(" - ok.\n"); - } else { - printf(" - failed.\n"); - return 23; - } - for (n = 0, pn(pns); pbuff[n] == (BYTE)pn(0) && n < (UINT)(sz_sect * 2); n++) ; - if (n == (UINT)(sz_sect * 2)) { - printf(" Data matched.\n"); - } else { - printf("Failed: Read data differs from the data written.\n"); - return 24; - } - } else { - printf(" Test skipped.\n"); - } - pns++; - - printf("**** Test cycle %u of %u completed ****\n\n", cc, ncyc); - } - - return 0; -} - - - -int main (int argc, char* argv[]) -{ - int rc; - DWORD buff[512]; /* 2048 byte working buffer */ - - /* Check function/compatibility of the physical drive #0 */ - rc = test_diskio(0, 1, buff, sizeof buff); - if (res) { - printf("Sorry the function/compatibility test failed.\nFatFs will not work on this disk driver.\n"); - } else { - printf("Congratulations! The disk I/O layer works well.\n"); - } - - return rc; -} - +/*----------------------------------------------------------------------/ +/ Low level disk I/O module function checker +/-----------------------------------------------------------------------/ +/ WARNING: The data on the target drive will be lost! +*/ + +#include +#include +#include "ff.h" +#include "diskio.h" + + +static +DWORD pn ( + DWORD pns +) +{ + static DWORD lfsr; + UINT n; + + + if (pns) { + lfsr = pns; + for (n = 0; n < 32; n++) pn(0); + } + if (lfsr & 1) { + lfsr >>= 1; + lfsr ^= 0x80200003; + } else { + lfsr >>= 1; + } + return lfsr; +} + + +int test_diskio ( + BYTE pdrv, /* Physical drive number to be checked (all data on the drive will be lost) */ + UINT ncyc, /* Number of test cycles */ + DWORD* buff, /* Pointer to the working buffer */ + UINT sz_buff /* Size of the working buffer in unit of byte */ +) +{ + UINT n, cc, ns; + DWORD sz_drv, lba, lba2, pns = 1; + WORD sz_sect, sz_eblk; + BYTE *pbuff = (BYTE*)buff; + DSTATUS ds; + DRESULT dr; + + + + printf("test_diskio(%u, %u, 0x%08X, 0x%08X)\n", pdrv, ncyc, (UINT)buff, sz_buff); + + if (sz_buff < _MAX_SS + 4) { + printf("Insufficient work area to test.\n"); + return 1; + } + + for (cc = 1; cc <= ncyc; cc++) { + printf("**** Test cycle %u of %u start ****\n", cc, ncyc); + + /* Initialization */ + printf(" disk_initalize(%u)", pdrv); + ds = disk_initialize(pdrv); + if (ds & STA_NOINIT) { + printf(" - failed.\n"); + return 2; + } else { + printf(" - ok.\n"); + } + + /* Get drive size */ + printf("**** Get drive size ****\n"); + printf(" disk_ioctl(%u, GET_SECTOR_COUNT, 0x%08X)", pdrv, (UINT)&sz_drv); + sz_drv = 0; + dr = disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_drv); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 3; + } + if (sz_drv < 128) { + printf("Failed: Insufficient drive size to test.\n"); + return 4; + } + printf(" Number of sectors on the drive %u is %lu.\n", pdrv, sz_drv); + +#if _MAX_SS != _MIN_SS + /* Get sector size */ + printf("**** Get sector size ****\n"); + printf(" disk_ioctl(%u, GET_SECTOR_SIZE, 0x%X)", pdrv, (UINT)&sz_sect); + sz_sect = 0; + dr = disk_ioctl(pdrv, GET_SECTOR_SIZE, &sz_sect); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 5; + } + printf(" Size of sector is %u bytes.\n", sz_sect); +#else + sz_sect = _MAX_SS; +#endif + + /* Get erase block size */ + printf("**** Get block size ****\n"); + printf(" disk_ioctl(%u, GET_BLOCK_SIZE, 0x%X)", pdrv, (UINT)&sz_eblk); + sz_eblk = 0; + dr = disk_ioctl(pdrv, GET_BLOCK_SIZE, &sz_eblk); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + } + if (dr == RES_OK || sz_eblk >= 2) { + printf(" Size of the erase block is %u sectors.\n", sz_eblk); + } else { + printf(" Size of the erase block is unknown.\n"); + } + + /* Single sector write test */ + printf("**** Single sector write test 1 ****\n"); + lba = 0; + for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n] = (BYTE)pn(0); + printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); + dr = disk_write(pdrv, pbuff, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 6; + } + printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); + dr = disk_ioctl(pdrv, CTRL_SYNC, 0); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 7; + } + memset(pbuff, 0, sz_sect); + printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); + dr = disk_read(pdrv, pbuff, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 8; + } + for (n = 0, pn(pns); n < sz_sect && pbuff[n] == (BYTE)pn(0); n++) ; + if (n == sz_sect) { + printf(" Data matched.\n"); + } else { + printf("Failed: Read data differs from the data written.\n"); + return 10; + } + pns++; + + /* Multiple sector write test */ + printf("**** Multiple sector write test ****\n"); + lba = 1; ns = sz_buff / sz_sect; + if (ns > 4) ns = 4; + for (n = 0, pn(pns); n < (UINT)(sz_sect * ns); n++) pbuff[n] = (BYTE)pn(0); + printf(" disk_write(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns); + dr = disk_write(pdrv, pbuff, lba, ns); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 11; + } + printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); + dr = disk_ioctl(pdrv, CTRL_SYNC, 0); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 12; + } + memset(pbuff, 0, sz_sect * ns); + printf(" disk_read(%u, 0x%X, %lu, %u)", pdrv, (UINT)pbuff, lba, ns); + dr = disk_read(pdrv, pbuff, lba, ns); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 13; + } + for (n = 0, pn(pns); n < (UINT)(sz_sect * ns) && pbuff[n] == (BYTE)pn(0); n++) ; + if (n == (UINT)(sz_sect * ns)) { + printf(" Data matched.\n"); + } else { + printf("Failed: Read data differs from the data written.\n"); + return 14; + } + pns++; + + /* Single sector write test (misaligned memory address) */ + printf("**** Single sector write test 2 ****\n"); + lba = 5; + for (n = 0, pn(pns); n < sz_sect; n++) pbuff[n+3] = (BYTE)pn(0); + printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+3), lba); + dr = disk_write(pdrv, pbuff+3, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 15; + } + printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); + dr = disk_ioctl(pdrv, CTRL_SYNC, 0); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 16; + } + memset(pbuff+5, 0, sz_sect); + printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+5), lba); + dr = disk_read(pdrv, pbuff+5, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 17; + } + for (n = 0, pn(pns); n < sz_sect && pbuff[n+5] == (BYTE)pn(0); n++) ; + if (n == sz_sect) { + printf(" Data matched.\n"); + } else { + printf("Failed: Read data differs from the data written.\n"); + return 18; + } + pns++; + + /* 4GB barrier test */ + printf("**** 4GB barrier test ****\n"); + if (sz_drv >= 128 + 0x80000000 / (sz_sect / 2)) { + lba = 6; lba2 = lba + 0x80000000 / (sz_sect / 2); + for (n = 0, pn(pns); n < (UINT)(sz_sect * 2); n++) pbuff[n] = (BYTE)pn(0); + printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); + dr = disk_write(pdrv, pbuff, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 19; + } + printf(" disk_write(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2); + dr = disk_write(pdrv, pbuff+sz_sect, lba2, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 20; + } + printf(" disk_ioctl(%u, CTRL_SYNC, NULL)", pdrv); + dr = disk_ioctl(pdrv, CTRL_SYNC, 0); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 21; + } + memset(pbuff, 0, sz_sect * 2); + printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)pbuff, lba); + dr = disk_read(pdrv, pbuff, lba, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 22; + } + printf(" disk_read(%u, 0x%X, %lu, 1)", pdrv, (UINT)(pbuff+sz_sect), lba2); + dr = disk_read(pdrv, pbuff+sz_sect, lba2, 1); + if (dr == RES_OK) { + printf(" - ok.\n"); + } else { + printf(" - failed.\n"); + return 23; + } + for (n = 0, pn(pns); pbuff[n] == (BYTE)pn(0) && n < (UINT)(sz_sect * 2); n++) ; + if (n == (UINT)(sz_sect * 2)) { + printf(" Data matched.\n"); + } else { + printf("Failed: Read data differs from the data written.\n"); + return 24; + } + } else { + printf(" Test skipped.\n"); + } + pns++; + + printf("**** Test cycle %u of %u completed ****\n\n", cc, ncyc); + } + + return 0; +} + + + +int main (int argc, char* argv[]) +{ + int rc; + DWORD buff[512]; /* 2048 byte working buffer */ + + /* Check function/compatibility of the physical drive #0 */ + rc = test_diskio(0, 1, buff, sizeof buff); + if (res) { + printf("Sorry the function/compatibility test failed.\nFatFs will not work on this disk driver.\n"); + } else { + printf("Congratulations! The disk I/O layer works well.\n"); + } + + return rc; +} + diff --git a/src/gfile/fatfs/doc/img/f1.png b/3rdparty/fatfs-0.10b/doc/img/f1.png similarity index 100% rename from src/gfile/fatfs/doc/img/f1.png rename to 3rdparty/fatfs-0.10b/doc/img/f1.png diff --git a/src/gfile/fatfs/doc/img/f2.png b/3rdparty/fatfs-0.10b/doc/img/f2.png similarity index 100% rename from src/gfile/fatfs/doc/img/f2.png rename to 3rdparty/fatfs-0.10b/doc/img/f2.png diff --git a/src/gfile/fatfs/doc/img/f3.png b/3rdparty/fatfs-0.10b/doc/img/f3.png similarity index 100% rename from src/gfile/fatfs/doc/img/f3.png rename to 3rdparty/fatfs-0.10b/doc/img/f3.png diff --git a/src/gfile/fatfs/doc/img/f4.png b/3rdparty/fatfs-0.10b/doc/img/f4.png similarity index 100% rename from src/gfile/fatfs/doc/img/f4.png rename to 3rdparty/fatfs-0.10b/doc/img/f4.png diff --git a/src/gfile/fatfs/doc/img/f5.png b/3rdparty/fatfs-0.10b/doc/img/f5.png similarity index 100% rename from src/gfile/fatfs/doc/img/f5.png rename to 3rdparty/fatfs-0.10b/doc/img/f5.png diff --git a/src/gfile/fatfs/doc/img/f6.png b/3rdparty/fatfs-0.10b/doc/img/f6.png similarity index 100% rename from src/gfile/fatfs/doc/img/f6.png rename to 3rdparty/fatfs-0.10b/doc/img/f6.png diff --git a/src/gfile/fatfs/doc/img/f7.png b/3rdparty/fatfs-0.10b/doc/img/f7.png similarity index 100% rename from src/gfile/fatfs/doc/img/f7.png rename to 3rdparty/fatfs-0.10b/doc/img/f7.png diff --git a/src/gfile/fatfs/doc/img/funcs.png b/3rdparty/fatfs-0.10b/doc/img/funcs.png similarity index 100% rename from src/gfile/fatfs/doc/img/funcs.png rename to 3rdparty/fatfs-0.10b/doc/img/funcs.png diff --git a/src/gfile/fatfs/doc/img/layers.png b/3rdparty/fatfs-0.10b/doc/img/layers.png similarity index 100% rename from src/gfile/fatfs/doc/img/layers.png rename to 3rdparty/fatfs-0.10b/doc/img/layers.png diff --git a/src/gfile/fatfs/doc/img/layers3.png b/3rdparty/fatfs-0.10b/doc/img/layers3.png similarity index 100% rename from src/gfile/fatfs/doc/img/layers3.png rename to 3rdparty/fatfs-0.10b/doc/img/layers3.png diff --git a/src/gfile/fatfs/doc/img/modules.png b/3rdparty/fatfs-0.10b/doc/img/modules.png similarity index 100% rename from src/gfile/fatfs/doc/img/modules.png rename to 3rdparty/fatfs-0.10b/doc/img/modules.png diff --git a/src/gfile/fatfs/doc/img/rwtest.png b/3rdparty/fatfs-0.10b/doc/img/rwtest.png similarity index 100% rename from src/gfile/fatfs/doc/img/rwtest.png rename to 3rdparty/fatfs-0.10b/doc/img/rwtest.png diff --git a/src/gfile/fatfs/doc/img/rwtest2.png b/3rdparty/fatfs-0.10b/doc/img/rwtest2.png similarity index 100% rename from src/gfile/fatfs/doc/img/rwtest2.png rename to 3rdparty/fatfs-0.10b/doc/img/rwtest2.png diff --git a/src/gfile/fatfs/doc/img/rwtest3.png b/3rdparty/fatfs-0.10b/doc/img/rwtest3.png similarity index 100% rename from src/gfile/fatfs/doc/img/rwtest3.png rename to 3rdparty/fatfs-0.10b/doc/img/rwtest3.png diff --git a/src/gfile/fatfs/doc/ja/appnote.html b/3rdparty/fatfs-0.10b/doc/ja/appnote.html similarity index 96% rename from src/gfile/fatfs/doc/ja/appnote.html rename to 3rdparty/fatfs-0.10b/doc/ja/appnote.html index 891c8827..b30c713f 100644 --- a/src/gfile/fatfs/doc/ja/appnote.html +++ b/3rdparty/fatfs-0.10b/doc/ja/appnote.html @@ -1,281 +1,282 @@ - - - - - - - - -FatFsモジュール アプリケーション・ノート - - - -

FatFsモジュール アプリケーション・ノート

-
    -
  1. ポーティングの際に配慮すべきこと
  2. -
  3. 限界値
  4. -
  5. メモリ使用量
  6. -
  7. モジュール・サイズの縮小
  8. -
  9. 長いファイル名
  10. -
  11. 日本語ファイル名の大文字変換
  12. -
  13. Unicode入出力への対応
  14. -
  15. リエントランシー
  16. -
  17. 多重ファイル・アクセス
  18. -
  19. 効率的なファイル・アクセス
  20. -
  21. フラッシュ・メモリの特性への配慮
  22. -
  23. クリチカル・セクション
  24. -
  25. APIの拡張的使用例
  26. -
  27. FatFsのライセンスについて
  28. -
-
- -
-

ポーティングの際に配慮すべきこと

- -

移植の際の前提条件

-

FatFsモジュールは移植性に関して次の点を前提としています。

-
    -
  • 処理系はANSI C準拠であること。
    -FatFsモジュールはANSI C(C89)準拠で記述されているので、普通のCコンパイラなら特に処理系依存になる点はありません。
  • -
  • char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。
    -これについても、まっとうな処理系なら問題ないはずです。FatFsモジュールで使用されるサイズを明示する整数型が integer.h 内で定義されていますが、既存の定義と衝突した場合はユーザによって解決されなければなりません。
  • -
- -

システム構成

-

下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。

-

システム構成図

-

(a) FatFs用に書かれたディスク・モジュールがある場合は、そのまま追加するだけです。 (b) しかし、多くの既存のディスク・モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。

-

functional diagram

- -

ユーザの作成する関数

-

必要なのはFatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク・モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。

- - - - - - - - - - -
必要な関数必要となる条件備考
disk_status
disk_initialize
disk_read
常時ffsample.zip (サンプル)
その他web上に多数
disk_write
get_fattime
disk_ioctl (CTRL_SYNC)
_FS_READONLY == 0
disk_ioctl (GET_SECTOR_COUNT)
disk_ioctl (GET_BLOCK_SIZE)
_USE_MKFS == 1
disk_ioctl (GET_SECTOR_SIZE)_MAX_SS != _MIN_SS
disk_ioctl (CTRL_ERASE_SECTOR)_USE_ERASE == 1
ff_convert
ff_wtoupper
_USE_LFN >= 1option/unicode.c
ff_cre_syncobj
ff_rel_grant
ff_req_grant
ff_del_syncobj
_FS_REENTRANT == 1option/syscall.c (サンプル)
ff_mem_alloc
ff_mem_free
_USE_LFN == 3
-
- -
-

限界値

-
    -
  • FATタイプ: FAT12, FAT16, FAT32。
  • -
  • 同時オープン・ファイル数: 無制限。(利用可能メモリによる)
  • -
  • ボリューム数: 最大 10。
  • -
  • ファイル・サイズ: FAT規格に依存。(最大 4G-1バイト)
  • -
  • ボリューム・サイズ: FAT規格に依存。(最大 2Tバイト(512バイト/セクタ時))
  • -
  • クラスタ・サイズ: FAT規格に依存。(最大 64Kバイト(512バイト/セクタ時))
  • -
  • セクタ・サイズ: FAT規格に依存。(512~4096バイト)
  • -
-
- -
-

メモリ使用量

-

次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、Vはボリューム数、Fは同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。

- - - - - - - - - - - - -
ARM7
32bit
ARM7
Thumb
CM3
Thumb-2
AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
_WORD_ACCESS00010001011
text (Full, R/W)1067571716617133551094011722132628113904860327952
text (Min, R/W) 672746314331 8569 7262 7720 90885287580039485183
text (Full, R/O) 473131472889 6235 5170 5497 64823833397228623719
text (Min, R/O) 355924852295 4575 4064 4240 50192993310422142889
bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*4 + 2
Work area
(_FS_TINY == 0)
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
V*560
+ F*544
V*560
+ F*550
V*560
+ F*544
V*560
+ F*544
V*560
+ F*544
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
Work area
(_FS_TINY == 1)
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*32
V*560
+ F*36
V*560
+ F*32
V*560
+ F*32
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
-
-FatFs R0.10a options:
-_FS_READONLY     0 (R/W) or 1 (R/O)
-_FS_MINIMIZE     0 (Full function) or 3 (Minimized function)
-_USE_STRFUNC     0 (Disable string functions)
-_USE_MKFS        0 (Disable f_mkfs function)
-_USE_FORWARD     0 (Disable f_forward function)
-_USE_FASTSEEK    0 (Disable fast seek feature)
-_CODE_PAGE       932 (Japanese Shift-JIS)
-_USE_LFN         0 (Disable LFN feature)
-_MAX_SS          512 (Fixed sector size)
-_FS_RPATH        0 (Disable relative path feature)
-_FS_LABEL        0 (Disable volume label functions)
-_VOLUMES         V (Number of logical drives to be used)
-_MULTI_PARTITION 0 (Single partition per drive)
-_FS_REENTRANT    0 (Disable thread safe)
-_FS_LOCK         0 (Disable file lock control)
-
-
- -
-

モジュール・サイズの縮小

-

次の表は構成オプションの設定値によりどの機能が削除されるかを示します。

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_FS_LABEL_USE_MKFS_USE_FORWARD_MULTI_PARTITION
0123010  1/20120101010/12
f_mount
f_open
f_close
f_read
f_writex
f_syncx
f_lseekx
f_opendirxx
f_closedirxx
f_readdirxx
f_statxxx
f_getfreexxxx
f_truncatexxxx
f_unlinkxxxx
f_mkdirxxxx
f_chmodxxxx
f_utimexxxx
f_renamexxxx
f_chdirx
f_chdrivex
f_getcwdxx
f_getlabelx
f_setlabelxx
f_forwardx
f_mkfsxx
f_fdiskxxx
f_putcxx
f_putsxx
f_printfxx
f_getsx
-
- -
-

長いファイル名

-

FatFsモジュールは、長いファイル名(LFN)をサポートします。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir()を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、_USE_LFNを1,2または3に設定し、option/unicode.cをプロジェクトに追加します。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて_MAX_LFNオプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには_MAX_LFNは255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数はFR_INVALID_NAMEで失敗します。

-

ファイル関数に再入を行う条件の下でLFN機能を使用する場合は、_USE_LFNは2または3に設定されなければなりません。この場合、ファイル関数はワーク・エリアを動的に確保(スタックまたはヒープ)します。バッファ・サイズは、(_MAX_LFN + 1) * 2バイトになるので、スタック等のサイズはそれを考慮した十分なサイズでなければなりません。

- - - - - - - - -
LFN cfg on ARM7
コードページコードサイズ[bytes]
SBCS+3721
932(Shift-JIS)+62609
936(GBK)+177797
949(Korean)+139857
950(Big5)+111497
-

LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、それらのコード・ページにおいてLFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。

-

LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用するときは、最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能を構成オプションで任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。

-
- -
-

日本語ファイル名の大文字変換

-

CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます(日本語MSDOS仕様)。このため、非LFN構成で全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。

-
- -
-

Unicode入出力への対応

-

FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(_LFN_UNICODEオプションで設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、ファイル名を参照してください。

-
- -
-

リエントランシー

-

互いに異なるボリュームに対するファイル操作はリエントラントで、常に同時平行に動作できます。同じボリュームに対してはデフォルトではリエントラントではありませんが、_FS_REENTRANTオプションでリエントラント(スレッド・セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant(), ff_rel_grant()もまたプロジェクトに追加されなければなりません。サンプル・コードと解説はoption/syncobj.cにあります。

-

この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が_TIMEOUTで指定された期間を越すと、その関数はFR_TIMEOUTでアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。

-

ひとつの例外がf_mount(), f_mkfs(), f_fdisk()にあります。これらの関数は同じボリューム(または関連する物理ドライブ)に対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。

-

注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。その下位のディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。

-
- -
-

多重ファイル・アクセス

-

FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。

-

_FS_LOCKに1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位のアクセス制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数はFR_LOCKEDで失敗します。また、_FS_LOCKを越える数のファイルやサブ・ディレクトリを同時にオープンしようとすると、FR_TOO_MANY_OPEN_FILESで失敗します。

-
- -
-

効率的なファイル・アクセス

-

小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータはf_read()により次のシーケンスで転送されます。

-

図1. セクタ・ミスアラインド・リード (ショート)
-fig.1 -

-

図2. セクタ・ミスアラインド・リード (ロング)
-fig.2 -

-

図3. セクタ・アラインド・リード
-fig.3 -

-

ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ・バッファを意味します。セクタ・バッファは、それぞれのファイル・オブジェクト内のプライベート・セクタ・バッファまたはファイル・システム・オブジェクト内の共有セクタ・バッファのどちらかです。バッファ構成オプションの_FS_TINYは、データ転送にどちらを使うかを決定します。タイニー・バッファ(1)が選択されるとデータ・メモリの消費はそれぞれのファイル・オブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイル・データの転送とFAT/ディレクトリ・アクセスにファイル・システム・オブジェクト内のセクタ・バッファだけを使用します。タイニー・バッファの欠点は、セクタ・バッファにキャッシュされたFATデータがファイル・データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。

-

図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタがdisk_read()で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。

-

このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル・データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ・フットプリントで達成できます。

-
- -
-

フラッシュ・メモリの特性への配慮

-

HDDなどのディスク・メディアとは異なり、SDCやCFCなどのフラッシュ・メモリ・メディアの性能を引き出すには、その特性を意識した制御が必要になります。

-

マルチ・セクタ書き込み

-
-図6. マルチ/シングル・セクタ・ライトの比較
-fig.6 -
-

フラッシュ・メモリ・メディアの書き込み速度はシングル・セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。テスト結果は、マルチ・セクタ書き込み(W:16K, 32 sectors)がシングル・セクタ書き込み(W:100, 1 sector)がどの程度速いかを明確に示しています。大容量メディアほどシングル・セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびサンプル・ドライバはマルチ・セクタ転送に対応しています。

-

明示的なメモリ消去

-

通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュ・メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ・セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの_USE_ERASEに1を設定します。これはフラッシュ・メモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。

-
- -
-

クリチカル・セクション

-

ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。

-
-図4. 長いクリチカル・セクション
-fig.4 -
-
-図5. 最小化したクリチカル・セクション
-fig.5 -
-
-

赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。

-
    -
  • 書き換え中のファイルのデータが破壊される。
  • -
  • 追記中のファイルがオープン前の状態に戻る。
  • -
  • 新規に作成されたファイルが消える。
  • -
  • 新規または上書きで作成されたファイルの長さがゼロになって残る。
  • -
  • ロストチェーンの発生によりボリュームの利用効率が悪化する。
  • -
-

いずれも書き込み中や操作の対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。

-
- -
-

APIの拡張的使用例

-

FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。

-
    -
  1. 追記モードでのオープン/新規作成
  2. -
  3. ディレクトリを空にする
  4. -
  5. ファイルに連続領域を割り当てる
  6. -
  7. ディスクI/Oモジュールの機能/互換性チェッカー
  8. -
-
- -
-

FatFsのライセンスについて

-

ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。

-
/*----------------------------------------------------------------------------/
-/  FatFs - FAT file system module  R0.10b                   (C)ChaN, 2014
-/-----------------------------------------------------------------------------/
-/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
-/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
-/ 以下のライセンス・ポリシーの下で公開されています。
-/
-/  Copyright (C) 2014, ChaN, all right reserved.
-/
-/ * FatFsモジュールはフリー・ソフトウェアであり、また無保証です。
-/ * 用途に制限はありません。あなたの責任の下において、個人的・非営利的な
-/   ものから商用製品の開発に及ぶ目的に使用・改変・再配布することができます。
-/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
-/
-/-----------------------------------------------------------------------------/
-

要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、矛盾しない他のライセンス(GNU GPLや修正BSDライセンスなど)に変更することも可能です。

-
- -

戻る

- - + + + + + + + + +FatFsモジュール アプリケーション・ノート + + + +

FatFsモジュール アプリケーション・ノート

+
    +
  1. ポーティングの際に配慮すべきこと
  2. +
  3. 限界値
  4. +
  5. メモリ使用量
  6. +
  7. モジュール・サイズの縮小
  8. +
  9. 長いファイル名
  10. +
  11. 日本語ファイル名の大文字変換
  12. +
  13. Unicode入出力への対応
  14. +
  15. リエントランシー
  16. +
  17. 多重ファイル・アクセス
  18. +
  19. 効率的なファイル・アクセス
  20. +
  21. フラッシュ・メモリの特性への配慮
  22. +
  23. クリチカル・セクション
  24. +
  25. APIの拡張的使用例
  26. +
  27. FatFsのライセンスについて
  28. +
+
+ +
+

ポーティングの際に配慮すべきこと

+ +

移植の際の前提条件

+

FatFsモジュールは移植性に関して次の点を前提としています。

+
    +
  • 処理系はANSI C準拠であること。
    +FatFsモジュールはANSI C(C89)準拠で記述されているので、普通のCコンパイラなら特に処理系依存になる点はありません。
  • +
  • char/short/longのサイズは、それぞれ8/16/32ビットで、intは16または32ビットであること。
    +これについても、まっとうな処理系なら問題ないはずです。FatFsモジュールで使用されるサイズを明示する整数型が integer.h 内で定義されていますが、既存の定義と衝突した場合はユーザによって解決されなければなりません。
  • +
+ +

システム構成

+

下に示す依存関係図は、FatFsモジュール利用の組み込みシステムにおける代表的な構成を示します。

+

システム構成図

+

(a) FatFs用に書かれたディスク・モジュールがある場合は、そのまま追加するだけです。 (b) しかし、多くの既存のディスク・モジュールはそのAPIをFatFsに合わせるため、グルー関数が必要になるでしょう。

+

functional diagram

+ +

ユーザの作成する関数

+

必要なのはFatFsモジュールの要求するディスク関数を用意することだけで、それ以外にすることはありません。既に動作しているディスク・モジュールがあるなら、そのAPIをFatFsに合わせるかグルー関数を介してつなぐだけで済みますが、無い場合はほかから移植するか最初から書くかする必要があります。定義されている全ての関数が常に必要なわけではありません。例えば、リード・オンリー構成では書き込み系関数は必要ありません。次の表に構成オプションと要求される関数の対応を示します。

+ + + + + + + + + + +
必要な関数必要となる条件備考
disk_status
disk_initialize
disk_read
常時ffsample.zip (サンプル)
その他web上に多数
disk_write
get_fattime
disk_ioctl (CTRL_SYNC)
_FS_READONLY == 0
disk_ioctl (GET_SECTOR_COUNT)
disk_ioctl (GET_BLOCK_SIZE)
_USE_MKFS == 1
disk_ioctl (GET_SECTOR_SIZE)_MAX_SS != _MIN_SS
disk_ioctl (CTRL_ERASE_SECTOR)_USE_ERASE == 1
ff_convert
ff_wtoupper
_USE_LFN >= 1option/unicode.c
ff_cre_syncobj
ff_rel_grant
ff_req_grant
ff_del_syncobj
_FS_REENTRANT == 1option/syscall.c (サンプル)
ff_mem_alloc
ff_mem_free
_USE_LFN == 3
+
+ +
+

限界値

+
    +
  • FATタイプ: FAT12, FAT16, FAT32。
  • +
  • 同時オープン・ファイル数: 無制限。(利用可能メモリによる)
  • +
  • ボリューム数: 最大 10。
  • +
  • ファイル・サイズ: FAT規格に依存。(最大 4G-1バイト)
  • +
  • ボリューム・サイズ: FAT規格に依存。(最大 2Tバイト(512バイト/セクタ時))
  • +
  • クラスタ・サイズ: FAT規格に依存。(最大 64Kバイト(512バイト/セクタ時))
  • +
  • セクタ・サイズ: FAT規格に依存。(512~4096バイト)
  • +
+
+ +
+

メモリ使用量

+

次の表にいくつかのターゲットにおけるメモリ使用量の例を示します。テスト時の構成オプションはその下の通りです。数値の単位はバイトで、Vはボリューム数、Fは同時オープン・ファイル数を示します。コンパイラの最適化オプションはコード・サイズとしています。

+ + + + + + + + + + + + +
ARM7
32bit
ARM7
Thumb
CM3
Thumb-2
AVRH8/300HPIC24RL78V850ESSH-2ARX600IA-32
CompilerGCCGCCGCCGCCCH38C30CC78K0RCA850SHCRXCVC6
_WORD_ACCESS00010001011
text (Full, R/W)1067571716617133551094011722132628113904860327952
text (Min, R/W) 672746314331 8569 7262 7720 90885287580039485183
text (Full, R/O) 473131472889 6235 5170 5497 64823833397228623719
text (Min, R/O) 355924852295 4575 4064 4240 50192993310422142889
bssV*4 + 2V*4 + 2V*4 + 2V*2 + 2V*4 + 2V*2 + 2V*2 + 2V*4 + 2V*4 + 2V*4 + 2V*4 + 2
Work area
(_FS_TINY == 0)
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
V*560
+ F*544
V*560
+ F*550
V*560
+ F*544
V*560
+ F*544
V*560
+ F*544
V*560
+ F*550
V*560
+ F*550
V*560
+ F*550
Work area
(_FS_TINY == 1)
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*32
V*560
+ F*36
V*560
+ F*32
V*560
+ F*32
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
V*560
+ F*36
+
+FatFs R0.10a options:
+_FS_READONLY     0 (R/W) or 1 (R/O)
+_FS_MINIMIZE     0 (Full function) or 3 (Minimized function)
+_USE_STRFUNC     0 (Disable string functions)
+_USE_MKFS        0 (Disable f_mkfs function)
+_USE_FORWARD     0 (Disable f_forward function)
+_USE_FASTSEEK    0 (Disable fast seek feature)
+_CODE_PAGE       932 (Japanese Shift-JIS)
+_USE_LFN         0 (Disable LFN feature)
+_MAX_SS          512 (Fixed sector size)
+_FS_RPATH        0 (Disable relative path feature)
+_FS_LABEL        0 (Disable volume label functions)
+_VOLUMES         V (Number of logical drives to be used)
+_MULTI_PARTITION 0 (Single partition per drive)
+_FS_REENTRANT    0 (Disable thread safe)
+_FS_LOCK         0 (Disable file lock control)
+
+
+ +
+

モジュール・サイズの縮小

+

次の表は構成オプションの設定値によりどの機能が削除されるかを示します。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Function_FS_MINIMIZE_FS_READONLY_USE_STRFUNC_FS_RPATH_FS_LABEL_USE_MKFS_USE_FORWARD_MULTI_PARTITION
0123010  1/20120101010/12
f_mount
f_open
f_close
f_read
f_writex
f_syncx
f_lseekx
f_opendirxx
f_closedirxx
f_readdirxx
f_statxxx
f_getfreexxxx
f_truncatexxxx
f_unlinkxxxx
f_mkdirxxxx
f_chmodxxxx
f_utimexxxx
f_renamexxxx
f_chdirx
f_chdrivex
f_getcwdxx
f_getlabelx
f_setlabelxx
f_forwardx
f_mkfsxx
f_fdiskxxx
f_putcxx
f_putsxx
f_printfxx
f_getsx
+
+ +
+

長いファイル名

+

FatFsモジュールは、長いファイル名(LFN)をサポートします。ファイルに付けられた2つの異なる名前(短いファル名と長いファイル名)は、f_readdir()を除くファイル操作関数において透過です。デフォルト構成では、LFN機能はOFFになっています。LFN機能を有効にするには、_USE_LFNを1,2または3に設定し、option/unicode.cをプロジェクトに追加します。LFN機能は、加えてある程度のワーク・エリア(LFN操作バッファ)を必要とします。バッファ長は使用できるメモリに応じて_MAX_LFNオプションで構成されることができます。LFNの長さは最大255文字に達するので、LFN完全対応のためには_MAX_LFNは255に設定されるべきです。与えられたファイル名に対してバッファ長が不足した場合、ファイル関数はFR_INVALID_NAMEで失敗します。

+

ファイル関数に再入を行う条件の下でLFN機能を使用する場合は、_USE_LFNは2または3に設定されなければなりません。この場合、ファイル関数はワーク・エリアを動的に確保(スタックまたはヒープ)します。バッファ・サイズは、(_MAX_LFN + 1) * 2バイトになるので、スタック等のサイズはそれを考慮した十分なサイズでなければなりません。

+ + + + + + + + +
LFN cfg on ARM7
コードページコードサイズ[bytes]
SBCS+3721
932(Shift-JIS)+62609
936(GBK)+177797
949(Korean)+139857
950(Big5)+111497
+

LFN機能の上手な使い方は、それを使わないということです。実際、組み込み用途ではLFN機能がどうしても必要になるということはほとんど無いはずです。LFNを有効にすると、選択されたコード・ページに応じてモジュール・サイズが増大されます。右の表に各コード・ページにおけるLFNを有効にしたときのモジュール・サイズの違いを示します。特に、CJK地域では数万の文字が使われていますが、不幸なことにそれは巨大なOEM-Unicode相互変換テーブルを要求し、モジュール・サイズは劇的に増大されます。その結果、それらのコード・ページにおいてLFNを有効にしたFatFsモジュールは、AVRを含む殆どの8ビット・マイコンにインプリメントされることができません。

+

LFN機能のハードルはそれだけではありません。マイクロソフト社はFATファイル・システムについていくつかの特許を保有しています。いずれもLFN機能の実装に関するもので、その利用に対して$0.25/unitのライセンス料を要求しています。このため、商用製品でLFN機能を利用するときは、最終仕向地によってはライセンスが必要になります。最近のFAT32ドライバの多くはLFN機能を含んでいるため、それらの使用に当たってライセンスが必要になりますが、FatFsではLFN機能を構成オプションで任意にON/OFFできるため、無効にしてライセンス問題を回避することもできます。

+
+ +
+

日本語ファイル名の大文字変換

+

CP932(Shift_JIS)でかつ非LFN構成のときは、拡張文字の小文字(2バイト英字・キリル文字・ギリシャ文字)に対して大文字変換を行わず、小文字のままSFNエントリに記録・検索されます(日本語MSDOS仕様)。このため、非LFN構成で全角小文字を含むファイルを作成すると、NT系Windowsでそのファイルを開けなくなります。LFN構成では大文字変換を行います(NT系Windows仕様)。

+
+ +
+

Unicode入出力への対応

+

FatFs API上におけるファイル名等の文字列データの入出力は、デフォルトではANSI/OEMコードで行われますが、これをUnicode(UTF-16)に切り替えることもできます(_LFN_UNICODEオプションで設定)。つまり、これはFatFsがLFN機能に完全対応していることを意味します。Unicodeのファイル名に関する詳細は、ファイル名を参照してください。

+
+ +
+

リエントランシー

+

互いに異なるボリュームに対するファイル操作はリエントラントで、常に同時平行に動作できます。同じボリュームに対してはデフォルトではリエントラントではありませんが、_FS_REENTRANTオプションでリエントラント(スレッド・セーフ)にすることはできます。この場合、OS依存の同期オブジェクト操作関数ff_cre_syncobj(), ff_del_syncobj(), ff_req_grant(), ff_rel_grant()もまたプロジェクトに追加されなければなりません。サンプル・コードと解説はoption/syncobj.cにあります。

+

この場合、あるタスクがボリュームを使用中に他のタスクからそのボリュームに対するファイル関数が呼び出されると、そのアクセスは先のタスクがファイル関数を抜けるまでブロックされます。もし、待ち時間が_TIMEOUTで指定された期間を越すと、その関数はFR_TIMEOUTでアボートします。いくつかのRTOSではタイムアウト機能はサポートされないかも知れません。

+

ひとつの例外がf_mount(), f_mkfs(), f_fdisk()にあります。これらの関数は同じボリューム(または関連する物理ドライブ)に対してリエントラントではありません。これらの関数を使用するときは、アプリケーション・レベルで排他制御しなければなりません。

+

注: このセクションはFatFsモジュールそれ自体のリエントランシーについて説明しています。その下位のディスクI/Oモジュールのリエントランシーに関しては何の前提もありません。

+
+ +
+

多重ファイル・アクセス

+

FatFsモジュールではデフォルトでは多重アクセス制御機能をサポートしていません。ファイルに対する多重アクセスは、そのアクセス・モードによって制限されます。一つのファイルに対する多重オープンは、それらが全てリード・モードのときに限って許可されます。書き込みモードを含む多重オープン、また開かれているファイルに対するリネームや削除を行ってはなりません。さもないと、そのボリュームのFAT構造が破壊される可能性があります。

+

_FS_LOCKに1以上の値(値は同時に管理できるファイル数)をセットすることで多重アクセス制御機能が有効になり、ファイル単位のアクセス制御を自動で行うこともできます。この場合、上記のルールを破ったオープン・リネーム・削除を試みると、その関数はFR_LOCKEDで失敗します。また、_FS_LOCKを越える数のファイルやサブ・ディレクトリを同時にオープンしようとすると、FR_TOO_MANY_OPEN_FILESで失敗します。

+
+ +
+

効率的なファイル・アクセス

+

小規模な組込システムでのファイルの読み書きにおける効率の良いアクセスのため、アプリケーション・プログラマはFatFsモジュールの中でどのような処理が行われているか考慮すべきです。ストレージ上のデータはf_read()により次のシーケンスで転送されます。

+

図1. セクタ・ミスアラインド・リード (ショート)
+fig.1 +

+

図2. セクタ・ミスアラインド・リード (ロング)
+fig.2 +

+

図3. セクタ・アラインド・リード
+fig.3 +

+

ファイルI/Oバッファはセクタの一部のデータを読み書きするためのセクタ・バッファを意味します。セクタ・バッファは、それぞれのファイル・オブジェクト内のプライベート・セクタ・バッファまたはファイル・システム・オブジェクト内の共有セクタ・バッファのどちらかです。バッファ構成オプションの_FS_TINYは、データ転送にどちらを使うかを決定します。タイニー・バッファ(1)が選択されるとデータ・メモリの消費はそれぞれのファイル・オブジェクトで512バイト減少されます。この場合、FatFsモジュールはファイル・データの転送とFAT/ディレクトリ・アクセスにファイル・システム・オブジェクト内のセクタ・バッファだけを使用します。タイニー・バッファの欠点は、セクタ・バッファにキャッシュされたFATデータがファイル・データの転送により失われ、クラスタ境界の毎にリロードされなければならないことです。でも、悪くない性能と少ないメモリ消費の視点から多くのアプリケーションに適するでしょう。

+

図1はセクタの一部のデータがファイルI/Oバッファを経由で転送されることを示します。図2に示される長いデータの転送では、転送データの中間の1セクタまたはそれ以上のセクタにまたがる転送データがアプリケーション・バッファに直接転送されています。図3は転送データ全体がセクタ境界にアライメントされている場合を示しています。この場合、ファイルI/Oバッファは使用されません。直接転送においては最大の範囲のセクタがdisk_read()で一度に読み込まれますが、クラスタ境界を越えるマルチ・セクタ転送はそれが隣接であっても行われません。

+

このように、セクタにアライメントしたファイルの読み書きへの配慮はバッファ経由のデータ転送を避け、読み書き性能は改善されるでしょう。その効果に加え、タイニー構成でキャッシュされたFATデータがファイル・データの転送によりフラッシュされず、非タイニー構成と同じ性能を小さなメモリ・フットプリントで達成できます。

+
+ +
+

フラッシュ・メモリの特性への配慮

+

HDDなどのディスク・メディアとは異なり、SDCやCFCなどのフラッシュ・メモリ・メディアの性能を引き出すには、その特性を意識した制御が必要になります。

+

マルチ・セクタ書き込み

+
+図6. マルチ/シングル・セクタ・ライトの比較
+fig.6 +
+

フラッシュ・メモリ・メディアの書き込み速度はシングル・セクタ書き込みの時に最も低いものになり、一回のトランザクションで転送されるセクタ数が大きくなるほど書き込み速度は向上します。この効果はバス速度が高速になるほど顕著で、10倍以上の差が現れることも珍しくありません。テスト結果は、マルチ・セクタ書き込み(W:16K, 32 sectors)がシングル・セクタ書き込み(W:100, 1 sector)よりどの程度速いかを明確に示しています。大容量メディアほどシングル・セクタ書き込みが遅くなる点もまた重要です。書き込みトランザクションの回数はまた、メディアの寿命にも影響してきます。このため、アプリケーションはなるべく大きなブロック(クラスタ・サイズまたは2の累乗セクタ境界にアライメントした)で読み書きを行う必要があります。もちろん、アプリケーションからメディアに至る全てのレイヤがマルチ・セクタ転送に対応していないと意味がありません。残念ながら、既存のオープン・ソースのドライバの多くはマルチ・セクタ転送に未対応です。なお、FatFsモジュールおよびサンプル・ドライバはマルチ・セクタ転送に対応しています。

+

明示的なメモリ消去

+

通常のファイル消去では、記録されたデータに対して何らかの制御が行われるわけではなく、単にFAT上に未使用クラスタとして記録されているだけです。このため、ファイルが消去されたあともそれらは有効なメモリ・ブロックとしてフラッシュ・メモリ上に残ります。そこで、ファイルを消去するとき、占有していたデータ・セクタを明示的に消去(つまり未使用ブロックにする)することにより、メディア内の空きブロックを増やすことができます。これにより、次にそのブロックに書き込むときの消去動作が無くなり、書き込み性能が向上する可能性があります。また、ウェアレベリングに使えるブロックが増え、メディアの耐久性も向上するかも知れません。この機能を有効にするには、構成オプションの_USE_ERASEに1を設定します。これはフラッシュ・メモリ・メディアの内部動作に期待した制御なので、効果があるとは限りません。また、ファイル消去の時間が延びることも考慮に入れるべきです。

+
+ +
+

クリチカル・セクション

+

ストレージ上のFAT構造を操作している途中で、停電、不正なメディアの取り外し、回復不能なデータ・エラー等の障害が発生すると、処理が中途半端な状態で中断され、その結果としてFATボリュームの構造が破壊される可能性があります。次にFatFsモジュールにおけるクリチカル・セクションと、その間の障害により起きうるエラーの状態を示します。

+
+図4. 長いクリチカル・セクション
+fig.4 +
+
+図5. 最小化したクリチカル・セクション
+fig.5 +
+
+

赤で示したセクションを実行中に障害が発生した場合、クロス・リンクが発生して操作対象のファイル・ディレクトリが失われる可能性があります。黄色で示したセクションを実行中に障害が発生した場合、つぎのうちいずれかまたは複数の結果が生じる可能性があります。

+
    +
  • 書き換え中のファイルのデータが破壊される。
  • +
  • 追記中のファイルがオープン前の状態に戻る。
  • +
  • 新規に作成されたファイルが消える。
  • +
  • 新規または上書きで作成されたファイルの長さがゼロになって残る。
  • +
  • ロストチェーンの発生によりボリュームの利用効率が悪化する。
  • +
+

いずれも書き込み中や操作の対象でないファイルには影響はありません。これらのクリチカル・セクションは、ファイルを書き込みモードで開いている時間を最小限にするか、f_sync()を適宜使用することで図5のようにリスクを最小化することができます。

+
+ +
+

APIの拡張的使用例

+

FatFs APIの拡張的使用例です。有用なコードがあった場合は、随時追加していきます。。

+
    +
  1. 追記モードでのオープン/新規作成
  2. +
  3. ディレクトリを空にする
  4. +
  5. ファイルに連続領域を割り当てる
  6. +
  7. ディスクI/Oモジュールの機能/互換性チェッカー
  8. +
  9. FATイメージ作成ツール
  10. +
+
+ +
+

FatFsのライセンスについて

+

ソース・ファイルのヘッダにライセンス条件が記述されているので、利用の際はそれに従うこと。英語を読めない方のために以下に日本語訳を示しておきます。

+
/*----------------------------------------------------------------------------/
+/  FatFs - FAT file system module  R0.10b                   (C)ChaN, 2014
+/-----------------------------------------------------------------------------/
+/ FatFsモジュールは、小規模な組み込みシステム向けの汎用FATファイルシステム・
+/ モジュールです。これはフリー・ソフトウェアとして、教育・研究・開発のために
+/ 以下のライセンス・ポリシーの下で公開されています。
+/
+/  Copyright (C) 2014, ChaN, all right reserved.
+/
+/ * FatFsモジュールはフリー・ソフトウェアであり、また無保証です。
+/ * 用途に制限はありません。あなたの責任の下において、個人的・非営利的な
+/   ものから商用製品の開発に及ぶ目的に使用・改変・再配布することができます。
+/ * ソース・コードを再配布するときは、上記の著作権表示を保持しなければなりません。
+/
+/-----------------------------------------------------------------------------/
+

要するにFatFsはタダで自由に使えるということです。ソース・コードを再配布するときは、このブロックをそのまま保持しておくこと。このようにFatFsはBSDライクなライセンスとしていますが、一つ大きな違いがあります。特に組み込み用途での利用価値を高めるため、バイナリ形式(ソース・コードを含まない形式全て)での再配布については、条件は設けていません。その場合は、FatFsおよびそのライセンス文書についてはドキュメントに明記してもしなくてもかまいません。これは、一条項BSDライセンスと等価ということです。もちろんGNU GPLプロジェクトとも共存可能です。何らかの変更を加えて再配布する際は、矛盾しない他のライセンス(GNU GPLや修正BSDライセンスなど)に変更することも可能です。

+
+ +

戻る

+ + diff --git a/src/gfile/fatfs/doc/ja/chdir.html b/3rdparty/fatfs-0.10b/doc/ja/chdir.html similarity index 96% rename from src/gfile/fatfs/doc/ja/chdir.html rename to 3rdparty/fatfs-0.10b/doc/ja/chdir.html index 4a68fe2a..f12f0c53 100644 --- a/src/gfile/fatfs/doc/ja/chdir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/chdir.html @@ -1,81 +1,81 @@ - - - - - - - - -FatFs - f_chdir - - - - -
-

f_chdir

-

JgEfBNgύX܂B

-
-FRESULT f_chdir (
-  const TCHAR* path /* [IN] fBNgւ̃|C^ */
-);
-
-
- -
-

-
-
path
-
ړΏۂ̃fBNgpXk'\0'I[̕w肵܂B
-
-
- - - - - -
-

-

e{[̃JgEfBNgύX܂BJgEfBNǵÃ{[̃}Eg삪sꂽƂA[gEfBNgɏݒ肳܂BJgEfBNǵAt@CEVXeEIuWFNgɕێ邽߁Ã{[gpSẴ^XNɑ΂ĉe^܂B

-
- - -
-

Ή

-

_FS_RPATH == 1̂ƂɎgp”\ƂȂ܂B

-
- - -
-

gp

-
-    /* JgEhCũJgEfBNgύX ([gdir1) */
-    f_chdir("/dir1");
-
-    /* hCu2̃JgEfBNgύX (efBNg) */
-    f_chdir("2:..");
-
-
- -
-

Q

-

f_chdrive

-
- -

߂

- - + + + + + + + + +FatFs - f_chdir + + + + +
+

f_chdir

+

JgEfBNgύX܂B

+
+FRESULT f_chdir (
+  const TCHAR* path /* [IN] fBNgւ̃|C^ */
+);
+
+
+ +
+

+
+
path
+
ړΏۂ̃fBNgpXk'\0'I[̕w肵܂B
+
+
+ + + + + +
+

+

e{[̃JgEfBNgύX܂BJgEfBNǵÃ{[̃}Eg삪sꂽƂA[gEfBNgɏݒ肳܂BJgEfBNǵAt@CEVXeEIuWFNgɕێ邽߁Ã{[gpSẴ^XNɑ΂ĉe^܂B

+
+ + +
+

Ή

+

_FS_RPATH == 1̂ƂɎgp”\ƂȂ܂B

+
+ + +
+

gp

+
+    /* JgEhCũJgEfBNgύX ([gdir1) */
+    f_chdir("/dir1");
+
+    /* hCu2̃JgEfBNgύX (efBNg) */
+    f_chdir("2:..");
+
+
+ +
+

Q

+

f_chdrive

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/chdrive.html b/3rdparty/fatfs-0.10b/doc/ja/chdrive.html similarity index 96% rename from src/gfile/fatfs/doc/ja/chdrive.html rename to 3rdparty/fatfs-0.10b/doc/ja/chdrive.html index 305b0a71..32caf34b 100644 --- a/src/gfile/fatfs/doc/ja/chdrive.html +++ b/3rdparty/fatfs-0.10b/doc/ja/chdrive.html @@ -1,61 +1,61 @@ - - - - - - - - -FatFs - f_chdrive - - - - -
-

f_chdrive

-

JgEhCuύX܂B

-
-FRESULT f_chdrive (
-  const TCHAR* path  /* [IN] ΏۃhCuw肵܂ */
-);
-
-
- -
-

-
-
path
-
JgEhCuɐݒ肷_hCuԍw肷pXw肵܂B
-
-
- - -
-

߂l

-

-FR_OK, -FR_INVALID_DRIVE -

-
- - -
-

-

JgEhCuύX܂BVXeN̏l̓hCu0łB̐ݒFatFsW[̐ÓIϐɋL^邽߁ASẴ^XNɑ΂ĉe^܂B

-
- - -
-

Ή

-

_FS_RPATH == 1ŁA_VOLUMES > 1̂ƂɎgp”\ƂȂ܂B

-
- - -
-

Q

-

f_chdir

-
- -

Return

- - + + + + + + + + +FatFs - f_chdrive + + + + +
+

f_chdrive

+

JgEhCuύX܂B

+
+FRESULT f_chdrive (
+  const TCHAR* path  /* [IN] ΏۃhCuw肵܂ */
+);
+
+
+ +
+

+
+
path
+
JgEhCuɐݒ肷_hCuԍw肷pXw肵܂B
+
+
+ + +
+

߂l

+

+FR_OK, +FR_INVALID_DRIVE +

+
+ + +
+

+

JgEhCuύX܂BVXeN̏l̓hCu0łB̐ݒFatFsW[̐ÓIϐɋL^邽߁ASẴ^XNɑ΂ĉe^܂B

+
+ + +
+

Ή

+

_FS_RPATH == 1ŁA_VOLUMES > 1̂ƂɎgp”\ƂȂ܂B

+
+ + +
+

Q

+

f_chdir

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/ja/chmod.html b/3rdparty/fatfs-0.10b/doc/ja/chmod.html similarity index 97% rename from src/gfile/fatfs/doc/ja/chmod.html rename to 3rdparty/fatfs-0.10b/doc/ja/chmod.html index e0d113ef..ee7b012d 100644 --- a/src/gfile/fatfs/doc/ja/chmod.html +++ b/3rdparty/fatfs-0.10b/doc/ja/chmod.html @@ -1,83 +1,83 @@ - - - - - - - - -FatFs - f_chmod - - - - -
-

f_chmod

-

t@C܂̓TuEfBNg̑ύX܂B

-
-FRESULT f_chmod (
-  const TCHAR* path, /* [IN] IuWFNgւ̃|C^ */
-  BYTE attr,         /* [IN] ݒl */
-  BYTE mask          /* [IN] ύX}XN */
-);
-
-
- -
-

-
-
path
-
ύXΏۂ̃IuWFNgpXk'\0'I[̕w肵܂B
-
attr
-
ݒ肷鑮Bw”\ȑ͎̒ʂŁȂgݍ킹Ŏw肵܂Bw肳Ȃ͉܂B
- - - - - - -
lӖ
AM_RDO[hEI[
AM_ARCA[JCu
AM_SYSVXe
AM_HIDqhD
-
-
mask
-
ύX鑮̃}XNBw肵ݒ܂͉Aw肳Ȃ͏Ԃێ܂BattrƓlg܂B
-
-
- - - - - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

-
- - -
-

gp

-
-    /* [hI[ZbgAA[JCuNAȂ͕ύXȂ */
-    f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
-
-
- -

߂

- - + + + + + + + + +FatFs - f_chmod + + + + +
+

f_chmod

+

t@C܂̓TuEfBNg̑ύX܂B

+
+FRESULT f_chmod (
+  const TCHAR* path, /* [IN] IuWFNgւ̃|C^ */
+  BYTE attr,         /* [IN] ݒl */
+  BYTE mask          /* [IN] ύX}XN */
+);
+
+
+ +
+

+
+
path
+
ύXΏۂ̃IuWFNgpXk'\0'I[̕w肵܂B
+
attr
+
ݒ肷鑮Bw”\ȑ͎̒ʂŁȂgݍ킹Ŏw肵܂Bw肳Ȃ͉܂B
+ + + + + + +
lӖ
AM_RDO[hEI[
AM_ARCA[JCu
AM_SYSVXe
AM_HIDqhD
+
+
mask
+
ύX鑮̃}XNBw肵ݒ܂͉Aw肳Ȃ͏Ԃێ܂BattrƓlg܂B
+
+
+ + + + + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

+
+ + +
+

gp

+
+    /* [hI[ZbgAA[JCuNAȂ͕ύXȂ */
+    f_chmod("file.txt", AM_RDO, AM_RDO | AM_ARC);
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/close.html b/3rdparty/fatfs-0.10b/doc/ja/close.html similarity index 97% rename from src/gfile/fatfs/doc/ja/close.html rename to 3rdparty/fatfs-0.10b/doc/ja/close.html index cefd795a..968dd53b 100644 --- a/src/gfile/fatfs/doc/ja/close.html +++ b/3rdparty/fatfs-0.10b/doc/ja/close.html @@ -1,66 +1,66 @@ - - - - - - - - -FatFs - f_close - - - - -
-

f_close

-

t@C‚܂B

-
-FRESULT f_close (
-  FIL* fp     /* [IN] t@CEIuWFNgւ̃|C^ */
-);
-
-
- -
-

-
-
fp
-
‚悤Ƃt@C̃t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

t@C‚܂B炩݂̏̍sꂽt@C̏ꍇALbVꂽ([h/CgEobt@̃f[^AύXꂽFATfBNg)̓fBXNɏ߂܂B֐IƁÃt@CEIuWFNg͖ɂȂÃł܂B

-

t@CEIuWFNgǂݏop[hŁA_FS_LOCKIvVIĂȂꍇ́At@C‚Ƀt@CEIuWFNgj邱Ƃł܂BA͏̌݊̓_Ő͂܂B

-
- - -
-

Ή

-

SĂ̍\Ŏgp”\łB

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_close + + + + +
+

f_close

+

t@C‚܂B

+
+FRESULT f_close (
+  FIL* fp     /* [IN] t@CEIuWFNgւ̃|C^ */
+);
+
+
+ +
+

+
+
fp
+
‚悤Ƃt@C̃t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

t@C‚܂B炩݂̏̍sꂽt@C̏ꍇALbVꂽ([h/CgEobt@̃f[^AύXꂽFATfBNg)̓fBXNɏ߂܂B֐IƁÃt@CEIuWFNg͖ɂȂÃł܂B

+

t@CEIuWFNgǂݏop[hŁA_FS_LOCKIvVIĂȂꍇ́At@C‚Ƀt@CEIuWFNgj邱Ƃł܂BA͏̌݊̓_Ő͂܂B

+
+ + +
+

Ή

+

SĂ̍\Ŏgp”\łB

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/closedir.html b/3rdparty/fatfs-0.10b/doc/ja/closedir.html similarity index 96% rename from src/gfile/fatfs/doc/ja/closedir.html rename to 3rdparty/fatfs-0.10b/doc/ja/closedir.html index 021e8c87..7ab96072 100644 --- a/src/gfile/fatfs/doc/ja/closedir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/closedir.html @@ -1,64 +1,64 @@ - - - - - - - - -FatFs - f_closedir - - - - -
-

f_closedir

-

fBNg‚܂B

-
-FRESULT f_closedir (
-  DIR* dp     /* [IN] fBNgEIuWFNgւ̃|C^ */
-);
-
-
- -
-

-
-
dp
-
‚悤ƂfBNg̃fBNgEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

fBNg‚܂B֐IƁÃfBNgEIuWFNg͖ɂȂÃł܂B

-

_FS_LOCKIvVIĂȂꍇ́Ȁs킸ɃfBNgEIuWFNgj邱Ƃł܂BA͏̌݊̓_Ő͂܂B

-
- - -
-

Ή

-

_FS_MINIMIZE <= 1̂Ƃgp”\ɂȂ܂B

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_closedir + + + + +
+

f_closedir

+

fBNg‚܂B

+
+FRESULT f_closedir (
+  DIR* dp     /* [IN] fBNgEIuWFNgւ̃|C^ */
+);
+
+
+ +
+

+
+
dp
+
‚悤ƂfBNg̃fBNgEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

fBNg‚܂B֐IƁÃfBNgEIuWFNg͖ɂȂÃł܂B

+

_FS_LOCKIvVIĂȂꍇ́Ȁs킸ɃfBNgEIuWFNgj邱Ƃł܂BA͏̌݊̓_Ő͂܂B

+
+ + +
+

Ή

+

_FS_MINIMIZE <= 1̂Ƃgp”\ɂȂ܂B

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/dinit.html b/3rdparty/fatfs-0.10b/doc/ja/dinit.html similarity index 97% rename from src/gfile/fatfs/doc/ja/dinit.html rename to 3rdparty/fatfs-0.10b/doc/ja/dinit.html index 9168c0b1..fd247a07 100644 --- a/src/gfile/fatfs/doc/ja/dinit.html +++ b/3rdparty/fatfs-0.10b/doc/ja/dinit.html @@ -1,46 +1,46 @@ - - - - - - - - -FatFs - disk_initialize - - - - -
-

disk_initialize

-

Xg[WEfoCX܂B

-
-DSTATUS disk_initialize (
-  BYTE pdrv      /* [IN] hCuԍ */
-);
-
-
- -
-

-
-
pdrv
-
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
-
-
- - -
-

߂l

-

̊֐͖߂lƂăfBXNEXe[^XԂ܂BfBXNEXe[^X̏ڍׂɊւĂdisk_status()QƂĂB

-
- -
-

-

Xg[WEfoCXAf[^̓ǂݏȂǑSĂ̓삪”\ȏԂɂ܂B֐ƁA߂lSTA_NOINITtONA܂B

-

AvP[V͂̊֐ĂяoĂ͂Ȃ܂BȂƁAFAT{[j󂳂”\܂BG[ɂďKvȂƂ́Af_mount()gpĂBFatFsW[́A}EgɂAKvɉĂ̊֐Ăяo܂B

-
- -

߂

- - + + + + + + + + +FatFs - disk_initialize + + + + +
+

disk_initialize

+

Xg[WEfoCX܂B

+
+DSTATUS disk_initialize (
+  BYTE pdrv      /* [IN] hCuԍ */
+);
+
+
+ +
+

+
+
pdrv
+
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
+
+
+ + +
+

߂l

+

̊֐͖߂lƂăfBXNEXe[^XԂ܂BfBXNEXe[^X̏ڍׂɊւĂdisk_status()QƂĂB

+
+ +
+

+

Xg[WEfoCXAf[^̓ǂݏȂǑSĂ̓삪”\ȏԂɂ܂B֐ƁA߂lSTA_NOINITtONA܂B

+

AvP[V͂̊֐ĂяoĂ͂Ȃ܂BȂƁAFAT{[j󂳂”\܂BG[ɂďKvȂƂ́Af_mount()gpĂBFatFsW[́A}EgɂAKvɉĂ̊֐Ăяo܂B

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/dioctl.html b/3rdparty/fatfs-0.10b/doc/ja/dioctl.html similarity index 97% rename from src/gfile/fatfs/doc/ja/dioctl.html rename to 3rdparty/fatfs-0.10b/doc/ja/dioctl.html index 1f525553..d1d3eef4 100644 --- a/src/gfile/fatfs/doc/ja/dioctl.html +++ b/3rdparty/fatfs-0.10b/doc/ja/dioctl.html @@ -1,95 +1,95 @@ - - - - - - - - -FatFs - disk_ioctl - - - - -
-

disk_ioctl

-

ʓIȃZN^ǂݏȊÕXg[WEfoCX̂ɑ΂lXȐs܂B

-
-DRESULT disk_ioctl (
-  BYTE pdrv,    /* [IN] hCuԍ */
-  BYTE cmd,     /* [IN] R}h */
-  void* buff    /* [I/O] f[^󂯓nobt@ */
-);
-
-
- -
-

-
-
pdrv
-
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
-
cmd
-
R}hER[hw肳܂B
-
buff
-
R}hɈˑp[^󂷂obt@w|C^w肳܂Bp[^̎̂ȂR}h̏ꍇ́AlɈӖ͂܂B
-
-
- -
-

߂l

-
-
RES_OK (0)
-
IB
-
RES_ERROR
-
炩̃G[B
-
RES_PARERR
-
R}hsB
-
RES_NOTRDY
-
hCu”\Ԃł͂ȂA܂͏ĂȂB
-
-
- -
-

-

Xg[WEfoCX̎ނɂT|[gR}h͈قȂ܂AFatFsW[̂́A̔ėpR}ĥݎgpÃfoCXɈˑ͍s܂B

- - - - - - - - -
WioctlR}h
R}h
CTRL_SYNCXg[WEfoCX̃f[^ݏ܂BCgEobNELbVȂǂ݂ꍇ́A܂ĂȂf[^𑦎݂܂BfBAւ݂̏ꂼdisk_write()̓Ŋꍇ́ÃR}hɑ΂Ă邱Ƃ͂܂B
GET_SECTOR_COUNTbuff̎wDWORD^ϐɃhCȗZN^Ԃ܂Bf_mkfs()f_fdisk()ĂяoA쐬{[̃TCY肷邽߂Ɏgp܂B
GET_SECTOR_SIZEbuff̎wWORD^ϐɃhCũZN^ETCYԂ܂BLl512A1024A2048܂4096łBZN^ETCYŒ\(_MAX_SS ==_MIN_SS)̂Ƃ͂̃R}h͎g邱Ƃ͂ȂAɂ̃ZN^ETCYœ삵Ȃ΂Ȃ܂B
GET_BLOCK_SIZEbuff̎wDWORD^ϐɃtbVȄubNETCY(ZN^P)Ԃ܂B132768͈̔͂2̗ݏ̒lłȂ΂Ȃ܂Bsȏꍇ܂̓tbVEȊÕfBAł1Ԃ܂Bf_mkfs()ł̂ݎgpA{[̃f[^̈͂̋EɃACg܂B
CTRL_ERASE_SECTORtbVË̗̖IBbuff̎wDWORD^zɂ͏̈ {JnZN^,IZN^} w肵ČĂяo܂B_USE_ERASE1̂ƂANX^ƂɌĂяo܂B́AATAR}hEZbgTrimR}hƓŁA̋@\T|[gȂꍇ͉Kv͂܂B܂A߂l̓`FbNꂸASɍsȂƂĂFatFs̓ɂ͉e܂B
- -

FatFŝ̓foCXˑR}h⃆[U`R}h͈؎gp܂񂪁AAvP[V牽炩̃foCX䂪sƕ֗ȂƂ܂BAvP[VŕWȊO̐䂪KvȂƂ́AKvɉă[U`R}hljėpƂ悢ł傤BɃR}h̗܂B

- - - - - - - - - - - - - - - - - -
[U`ioctlR}h̗
R}h
CTRL_FORMATfBA̕tH[}bgs܂BbuffNULLłȂƂAis\̂߂̃R[obN֐̃AhX܂B
CTRL_POWER_IDLEfoCXAChԂɂ܂Bʏ̓ǂݏvŃANeBuԂɖ߂ȂASTA_NOINITtOZbgKv͂܂B
CTRL_POWER_OFFfoCXVbg_EԂɂ܂BSTA_NOINIT̓Zbg܂BfoCXdisk_initialize()ŃANeBuԂɖ߂܂B
CTRL_LOCK[Uɂ郁fBA̎o֎~܂B
CTRL_UNLOCK[Uɂ郁fBA̎o‚܂B
CTRL_EJECTfBAro܂BASTA_NOINITSTA_NODISKtO̓Zbg܂B
MMC_GET_TYPEJ[hE^CvtO(b0:MMCv3, b1:SDv1, b2:SDv2+, b3:LBA)buff̎BYTEϐɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_CSDCSDWX^̓ebuff̎16oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_CIDCIDWX^̓ebuff̎16oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_OCROCRWX^̓ebuff̎4oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_SDSTATSD STATUSWX^̓ebuff̎64oCg̃obt@ɓǂݏo܂B(SDJ[hp)
ATA_GET_REVrWER[hbuff̎16oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
ATA_GET_MODELfER[hbuff̎40oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
ATA_GET_SNVAԍbuff̎20oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
-
- - -
-

Ή

-

[hEI[\ŁAƒZN^ETCYŒ\̂Ƃ́Å֐͕KvƂ܂B

-
- - -

߂

- - + + + + + + + + +FatFs - disk_ioctl + + + + +
+

disk_ioctl

+

ʓIȃf[^ǂݏȊÕXg[WEfoCX̂ɑ΂lXȐs܂B

+
+DRESULT disk_ioctl (
+  BYTE pdrv,    /* [IN] hCuԍ */
+  BYTE cmd,     /* [IN] R}h */
+  void* buff    /* [I/O] f[^󂯓nobt@ */
+);
+
+
+ +
+

+
+
pdrv
+
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
+
cmd
+
R}hER[hw肳܂B
+
buff
+
R}hɈˑp[^󂷂obt@w|C^w肳܂Bp[^̎̂ȂR}h̏ꍇ́AlɈӖ͂܂B
+
+
+ +
+

߂l

+
+
RES_OK (0)
+
IB
+
RES_ERROR
+
炩̃G[B
+
RES_PARERR
+
R}hsB
+
RES_NOTRDY
+
hCu”\Ԃł͂ȂA܂͏ĂȂB
+
+
+ +
+

+

Xg[WEfoCX̎ނɂT|[gR}h͈قȂ܂AFatFsW[̂́A̔ėpR}ĥݎgpÃfoCXɈˑ͍s܂B

+ + + + + + + + +
WioctlR}h
R}h
CTRL_SYNCXg[WEfoCX̃f[^ݏ܂BCgEobNELbVȂǂ݂ꍇ́A܂ĂȂf[^𑦎݂܂BfBAւ݂̏ꂼdisk_write()̓Ŋꍇ́ÃR}hɑ΂Ă邱Ƃ͂܂B
GET_SECTOR_COUNTbuff̎wDWORD^ϐɃhCȗZN^Ԃ܂Bf_mkfs()f_fdisk()ĂяoA쐬{[̃TCY肷邽߂Ɏgp܂B
GET_SECTOR_SIZEbuff̎wWORD^ϐɃhCũZN^ETCYԂ܂BLl512A1024A2048܂4096łBZN^ETCYŒ\(_MAX_SS ==_MIN_SS)̂Ƃ͂̃R}h͎g邱Ƃ͂ȂAɂ̃ZN^ETCYœ삵Ȃ΂Ȃ܂B
GET_BLOCK_SIZEbuff̎wDWORD^ϐɃtbVȄubNETCY(ZN^P)Ԃ܂B132768͈̔͂2̗ݏ̒lłȂ΂Ȃ܂Bsȏꍇ܂̓tbVEȊÕfBAł1Ԃ܂Bf_mkfs()ł̂ݎgpA{[̃f[^̈͂̋EɃACg܂B
CTRL_ERASE_SECTORtbVË̗̖IBbuff̎wDWORD^zɂ͏̈ {JnZN^,IZN^} w肵ČĂяo܂B_USE_ERASE1̂ƂANX^ƂɌĂяo܂B́AATAR}hEZbgTrimR}hƓŁA̋@\T|[gȂꍇ͉Kv͂܂B܂A߂l̓`FbNꂸASɍsȂƂĂFatFs̓ɂ͉e܂B
+ +

FatFŝ̓foCXˑR}h⃆[U`R}h͈؎gp܂񂪁AAvP[V牽炩̃foCX䂪sƕ֗ȂƂ܂BAvP[VŕWȊO̐䂪KvȂƂ́AKvɉă[U`R}hljėpƂ悢ł傤BɃR}h̗܂B

+ + + + + + + + + + + + + + + + + +
[U`ioctlR}h̗
R}h
CTRL_FORMATfBA̕tH[}bgs܂BbuffNULLłȂƂAis\̂߂̃R[obN֐̃AhX܂B
CTRL_POWER_IDLEfoCXAChԂɂ܂Bʏ̓ǂݏvŃANeBuԂɖ߂ȂASTA_NOINITtOZbgKv͂܂B
CTRL_POWER_OFFfoCXVbg_EԂɂ܂BSTA_NOINIT̓Zbg܂BfoCXdisk_initialize()ŃANeBuԂɖ߂܂B
CTRL_LOCK[Uɂ郁fBA̎o֎~܂B
CTRL_UNLOCK[Uɂ郁fBA̎o‚܂B
CTRL_EJECTfBAro܂BASTA_NOINITSTA_NODISKtO̓Zbg܂B
MMC_GET_TYPEJ[hE^CvtO(b0:MMCv3, b1:SDv1, b2:SDv2+, b3:LBA)buff̎BYTEϐɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_CSDCSDWX^̓ebuff̎16oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_CIDCIDWX^̓ebuff̎16oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_OCROCRWX^̓ebuff̎4oCg̃obt@ɓǂݏo܂B(MMC/SDJ[hp)
MMC_GET_SDSTATSD STATUSWX^̓ebuff̎64oCg̃obt@ɓǂݏo܂B(SDJ[hp)
ATA_GET_REVrWER[hbuff̎16oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
ATA_GET_MODELfER[hbuff̎40oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
ATA_GET_SNVAԍbuff̎20oCg̃obt@ɓǂݏo܂B(ATA/CFJ[hp)
+
+ + +
+

Ή

+

[hEI[\ŁAƒZN^ETCYŒ\̂Ƃ́Å֐͕KvƂ܂B

+
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/dread.html b/3rdparty/fatfs-0.10b/doc/ja/dread.html similarity index 95% rename from src/gfile/fatfs/doc/ja/dread.html rename to 3rdparty/fatfs-0.10b/doc/ja/dread.html index 31cd49f4..89ffab47 100644 --- a/src/gfile/fatfs/doc/ja/dread.html +++ b/3rdparty/fatfs-0.10b/doc/ja/dread.html @@ -1,71 +1,71 @@ - - - - - - - - -FatFs - disk_read - - - - -
-

disk_read

-

Xg[WEfoCXZN^ǂݏo܂B

-
-DRESULT disk_read (
-  BYTE pdrv,     /* [IN] hCuԍ */
-  BYTE* buff,    /* [OUT] ǂݏoobt@ւ̃|C^ */
-  DWORD sector,  /* [IN] ǂݏoJnZN^ԍ */
-  UINT count     /* [IN] ǂݏoZN^ */
-);
-
-
- -
-

-
-
pdrv
-
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
-
buff
-
Xg[WEfoCXǂݏof[^i[oCgzw肳܂B
-
sector
-
ǂݏoJnZN^ԍBLBAŎw肳܂B
-
count
-
ǂݏoZN^BFatFšĂяoł1`128͈̔͂Ɍ܂B
-
-
- - -
-

߂l

-
-
RES_OK (0)
-
IB
-
RES_ERROR
-
ǂݍݒɃG[Ả񕜂ɂsB
-
RES_PARERR
-
p[^sB
-
RES_NOTRDY
-
hCu”\Ԃł͂ȂiĂȂjB
-
-
- - -
-

-

buffBYTE^Ȃ̂ŁAw肳AhXɃ[hEACgĂƂ͌܂BACgEAhXւ̓]́Aړ]ɂĔ邱Ƃ܂BAn[hEFA̐ł̂悤ȓ]s”\ȂƂ́Å֐œi]Ȃǂĉ邩A܂͕ʂ̕@őΉȂ΂Ȃ܂Bɂ‚̑Ή@܂(ꂩ‚OK)B

-
    -
  • ̊֐ʼn -
  • -
  • f_read()ɂāAZN^Ŝ܂ޓ] - ړ]Ȃ
  • -
  • f_read(fp, buff, btr, &br)ɂāA(((UINT)buff & 3) == (f_tell(fp) & 3))𖞑 - buff̃[hEACgۏ؂
  • -
-

ʓIɁAZN^̓]v́AXg[WEfoCXɑ΂ĉ”\Ȍ}`EZN^]Ȃ΂Ȃ܂B̃VOEZN^ǂݏoɕꂽꍇAX[vbgቺ邱Ƃ܂B

-
- - -

߂

- - + + + + + + + + +FatFs - disk_read + + + + +
+

disk_read

+

Xg[WEfoCXf[^ǂݏo܂B

+
+DRESULT disk_read (
+  BYTE pdrv,     /* [IN] hCuԍ */
+  BYTE* buff,    /* [OUT] ǂݏoobt@ւ̃|C^ */
+  DWORD sector,  /* [IN] ǂݏoJnZN^ԍ */
+  UINT count     /* [IN] ǂݏoZN^ */
+);
+
+
+ +
+

+
+
pdrv
+
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
+
buff
+
Xg[WEfoCXǂݏof[^i[oCgzw肳܂B
+
sector
+
ǂݏoJnZN^ԍBLBAŎw肳܂B
+
count
+
ǂݏoZN^BFatFšĂяoł1`128͈̔͂Ɍ܂B
+
+
+ + +
+

߂l

+
+
RES_OK (0)
+
IB
+
RES_ERROR
+
ǂݍݒɃG[Ả񕜂ɂsB
+
RES_PARERR
+
p[^sB
+
RES_NOTRDY
+
hCu”\Ԃł͂ȂiĂȂjB
+
+
+ + +
+

+

buffBYTE^Ȃ̂ŁAw肳AhXɃ[hEACgĂƂ͌܂BACgEAhXւ̓]́Aړ]ɂĔ邱Ƃ܂BAn[hEFA̐ł̂悤ȓ]s”\ȂƂ́Å֐œi]Ȃǂĉ邩A܂͕ʂ̕@őΉȂ΂Ȃ܂Bɂ‚̑Ή@܂(ꂩ‚OK)B

+
    +
  • ̊֐ʼn -
  • +
  • f_read()ɂāAZN^Ŝ܂ޓ] - ړ]Ȃ
  • +
  • f_read(fp, buff, btr, &br)ɂāA(((UINT)buff & 3) == (f_tell(fp) & 3))𖞑 - buff̃[hEACgۏ؂
  • +
+

ʓIɁAZN^̓]v́AXg[WEfoCXɑ΂ĉ”\Ȍ}`EZN^]Ȃ΂Ȃ܂B̃VOEZN^ǂݏoɕꂽꍇAX[vbgቺ邱Ƃ܂B

+
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/dstat.html b/3rdparty/fatfs-0.10b/doc/ja/dstat.html similarity index 97% rename from src/gfile/fatfs/doc/ja/dstat.html rename to 3rdparty/fatfs-0.10b/doc/ja/dstat.html index a74fc30b..7e338599 100644 --- a/src/gfile/fatfs/doc/ja/dstat.html +++ b/3rdparty/fatfs-0.10b/doc/ja/dstat.html @@ -1,48 +1,48 @@ - - - - - - - - -FatFs - disk_status - - - - -
-

disk_status

-

Xg[WEfoCX̏Ԃ擾܂B

-
-DSTATUS disk_status (
-  BYTE pdrv           /* [IN] hCuԍ */
-);
-
-
- -
-

-
-
pdrv
-
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
-
-
- - -
-

߂l

-

Xg[WEfoCX̏Ԃ̃tȎgݍ킹lŕԂ܂B

-
-
STA_NOINIT
-
foCXĂȂƂtOBVXeEZbg⃁fBA̎OŃZbgAdisk_initialize()̐IŃNAAsŃZbg܂BfBA͔񓯊ɔCxgȂ̂ŁAߋɃfBAꍇ̃tOɔfKv܂BFatFsW[́ÃtOQƂĎ}Egsǂ𔻒f܂B
-
STA_NODISK
-
fBA݂ȂƂtOBfBAOĂԂ̓ZbgAZbgĂԂ̓NA܂BŒfBXNł͏ɃNA܂BȂÃtOFatFsW[ł͎QƂ܂B
-
STA_PROTECT
-
fBACgEveNgĂ邱ƂtOBCgEveNg@\T|[gȂƂ́AɃNA܂B[hEI\ł͎QƂ܂B
-
-
- -

߂

- - + + + + + + + + +FatFs - disk_status + + + + +
+

disk_status

+

Xg[WEfoCX̏Ԃ擾܂B

+
+DSTATUS disk_status (
+  BYTE pdrv           /* [IN] hCuԍ */
+);
+
+
+ +
+

+
+
pdrv
+
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
+
+
+ + +
+

߂l

+

Xg[WEfoCX̏Ԃ̃tȎgݍ킹lŕԂ܂B

+
+
STA_NOINIT
+
foCXĂȂƂtOBVXeEZbg⃁fBA̎OŃZbgAdisk_initialize()̐IŃNAAsŃZbg܂BfBA͔񓯊ɔCxgȂ̂ŁAߋɃfBAꍇ̃tOɔfKv܂BFatFsW[́ÃtOQƂĎ}Egsǂ𔻒f܂B
+
STA_NODISK
+
fBA݂ȂƂtOBfBAOĂԂ̓ZbgAZbgĂԂ̓NA܂BŒfBXNł͏ɃNA܂BȂÃtOFatFsW[ł͎QƂ܂B
+
STA_PROTECT
+
fBACgEveNgĂ邱ƂtOBCgEveNg@\T|[gȂƂ́AɃNA܂B[hEI\ł͎QƂ܂B
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/dwrite.html b/3rdparty/fatfs-0.10b/doc/ja/dwrite.html similarity index 96% rename from src/gfile/fatfs/doc/ja/dwrite.html rename to 3rdparty/fatfs-0.10b/doc/ja/dwrite.html index 046e0671..dae5091f 100644 --- a/src/gfile/fatfs/doc/ja/dwrite.html +++ b/3rdparty/fatfs-0.10b/doc/ja/dwrite.html @@ -1,76 +1,76 @@ - - - - - - - - -FatFs - disk_write - - - - -
-

disk_write

-

Xg[WEfoCX̃ZN^ɏ݂܂B

-
-DRESULT disk_write (
-  BYTE pdrv,        /* [IN] hCuԍ */
-  const BYTE* buff, /* [IN] ރf[^ւ̃|C^ */
-  DWORD sector,     /* [IN] ݊JnZN^ԍ */
-  UINT count        /* [IN] ރZN^ */
-);
-
-
- -
-

-
-
pdrv
-
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
-
buff
-
Xg[WEfoCXɏރZN^Ef[^i[ꂽoCgzw肳܂BoCǵAZN^ETCY*countƂȂ܂B
-
sector
-
݂JnZN^ԍBLBAŎw肳܂B
-
count
-
ރZN^BFatFšĂяoł1`128͈̔͂Ɍ܂B
-
-
- - -
-

߂l

-
-
RES_OK (0)
-
IB
-
RES_ERROR
-
ݒɃG[Ả񕜂ɂsB
-
RES_WRPRT
-
fBA݋֎~ԁB
-
RES_PARERR
-
p[^sB
-
RES_NOTRDY
-
foCX”\Ԃł͂ȂiĂȂjB
-
-
- - -
-

-

buffɎw肳AhXɃ[hEACgĂƂ͌܂Bڍׂ́Adisk_read()̉QƂĂB

-

ʓIɁAZN^̓]v́AfoCXɑ΂ĉ”\Ȍ}`EZN^]Ȃ΂Ȃ܂B̃VOEZN^݂ɕꂽꍇAX[vbgቺ邱Ƃ܂B

-

FatFs̓fBXN֐x݋@\‚Ƃz肵Ă܂B̊֐߂ƂAfoCXݒƂLbVɏ܂ꂽȂǁAKf[^݂̏ĂKv͂܂BAbuff̃f[^́Å֐߂ƖƂȂ܂B̗݊v́Adisk_ioctl()CTRL_SYNCR}hɂčs܂B̂悤Ȓx݋@\ꂽꍇAX[vbgɌコ邱Ƃł܂B

-

AvP[V͂̊֐ĂяoĂ͂Ȃ܂BȂƁAFAT{[j󂳂”\܂B

-
- - -
-

Ή

-

[hEI[\(_FS_READONLY == 1)ł͂̊֐͕KvƂ܂B

-
- - -

߂

- - + + + + + + + + +FatFs - disk_write + + + + +
+

disk_write

+

Xg[WEfoCXɃf[^݂܂B

+
+DRESULT disk_write (
+  BYTE pdrv,        /* [IN] hCuԍ */
+  const BYTE* buff, /* [IN] ރf[^ւ̃|C^ */
+  DWORD sector,     /* [IN] ݊JnZN^ԍ */
+  UINT count        /* [IN] ރZN^ */
+);
+
+
+ +
+

+
+
pdrv
+
Ώۂ̃foCXhCuԍ(0-9)w肳܂B
+
buff
+
Xg[WEfoCXɏރZN^Ef[^i[ꂽoCgzw肳܂BoCǵAZN^ETCY*countƂȂ܂B
+
sector
+
݂JnZN^ԍBLBAŎw肳܂B
+
count
+
ރZN^BFatFšĂяoł1`128͈̔͂Ɍ܂B
+
+
+ + +
+

߂l

+
+
RES_OK (0)
+
IB
+
RES_ERROR
+
ݒɃG[Ả񕜂ɂsB
+
RES_WRPRT
+
fBA݋֎~ԁB
+
RES_PARERR
+
p[^sB
+
RES_NOTRDY
+
foCX”\Ԃł͂ȂiĂȂjB
+
+
+ + +
+

+

buffɎw肳AhXɃ[hEACgĂƂ͌܂Bڍׂ́Adisk_read()̉QƂĂB

+

ʓIɁAZN^̓]v́AfoCXɑ΂ĉ”\Ȍ}`EZN^]Ȃ΂Ȃ܂B̃VOEZN^݂ɕꂽꍇAX[vbgቺ邱Ƃ܂B

+

FatFs̓fBXN֐x݋@\‚Ƃz肵Ă܂B̊֐߂ƂAfoCXݒƂLbVɏ܂ꂽȂǁAKf[^݂̏ĂKv͂܂BAbuff̃f[^́Å֐߂ƖƂȂ܂B̗݊v́Adisk_ioctl()CTRL_SYNCR}hɂčs܂B̂悤Ȓx݋@\ꂽꍇAX[vbgɌコ邱Ƃł܂B

+

AvP[V͂̊֐ĂяoĂ͂Ȃ܂BȂƁAFAT{[j󂳂”\܂B

+
+ + +
+

Ή

+

[hEI[\(_FS_READONLY == 1)ł͂̊֐͕KvƂ܂B

+
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/eof.html b/3rdparty/fatfs-0.10b/doc/ja/eof.html similarity index 96% rename from src/gfile/fatfs/doc/ja/eof.html rename to 3rdparty/fatfs-0.10b/doc/ja/eof.html index b1f0e1ac..3a840545 100644 --- a/src/gfile/fatfs/doc/ja/eof.html +++ b/3rdparty/fatfs-0.10b/doc/ja/eof.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_eof - - - - -
-

f_eof

-

[h/CgE|C^t@CI[ɒBĂ邩ǂׂ܂B.

-
-int f_eof (
-  FIL* fp   /* [IN] t@CEIuWFNg */
-);
-
-
- - -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

[h/CgE|C^t@CI[ɂǂݏof[^Ȃꍇ́A0ȊO̒lԂ܂BȊO̎0Ԃ܂B

-
- - -
-

-

f_eof֐́ArWł̓}NƂĎĂ܂B

-
-#define f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
-
-
- - -
-

Ή

-

Ɏgp”\B

-
- - -
-

Q

-

f_open, f_lseek, FIL

-
- -

߂

- - + + + + + + + + +FatFs - f_eof + + + + +
+

f_eof

+

[h/CgE|C^t@CI[ɒBĂ邩ǂׂ܂B.

+
+int f_eof (
+  FIL* fp   /* [IN] t@CEIuWFNg */
+);
+
+
+ + +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

[h/CgE|C^t@CI[ɂǂݏof[^Ȃꍇ́A0ȊO̒lԂ܂BȊO̎0Ԃ܂B

+
+ + +
+

+

f_eof֐́ArWł̓}NƂĎĂ܂B

+
+#define f_eof(fp) (((fp)->fptr) == ((fp)->fsize) ? 1 : 0)
+
+
+ + +
+

Ή

+

Ɏgp”\B

+
+ + +
+

Q

+

f_open, f_lseek, FIL

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/error.html b/3rdparty/fatfs-0.10b/doc/ja/error.html similarity index 96% rename from src/gfile/fatfs/doc/ja/error.html rename to 3rdparty/fatfs-0.10b/doc/ja/error.html index ccd2f071..227a7000 100644 --- a/src/gfile/fatfs/doc/ja/error.html +++ b/3rdparty/fatfs-0.10b/doc/ja/error.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_error - - - - -
-

f_error

-

G[̗L𒲂ׂ܂B

-
-int f_error (
-  FIL* fp   /* [IN] t@CEIuWFNg */
-);
-
-
- - -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

t@C쒆̃G[ɂďfĂꍇ́A0ȊO̒lԂ܂BȊO̎0Ԃ܂B

-
- - -
-

-

f_error֐́ArWł̓}NƂĎĂ܂B

-
-#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
-
-
- - -
-

Ή

-

Ɏgp”\B

-
- - -
-

Q

-

f_open, FIL

-
- -

߂

- - + + + + + + + + +FatFs - f_error + + + + +
+

f_error

+

G[̗L𒲂ׂ܂B

+
+int f_error (
+  FIL* fp   /* [IN] t@CEIuWFNg */
+);
+
+
+ + +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

t@C쒆̃G[ɂďfĂꍇ́A0ȊO̒lԂ܂BȊO̎0Ԃ܂B

+
+ + +
+

+

f_error֐́ArWł̓}NƂĎĂ܂B

+
+#define f_error(fp) (((fp)->flag & FA__ERROR) ? 1 : 0)
+
+
+ + +
+

Ή

+

Ɏgp”\B

+
+ + +
+

Q

+

f_open, FIL

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/fattime.html b/3rdparty/fatfs-0.10b/doc/ja/fattime.html similarity index 89% rename from src/gfile/fatfs/doc/ja/fattime.html rename to 3rdparty/fatfs-0.10b/doc/ja/fattime.html index 8e8a76f5..d9fa28c6 100644 --- a/src/gfile/fatfs/doc/ja/fattime.html +++ b/3rdparty/fatfs-0.10b/doc/ja/fattime.html @@ -1,57 +1,57 @@ - - - - - - - - -FatFs - get_fattime - - - - -
-

get_fattime

-

ݎ擾܂B

-
-DWORD get_fattime (void);
-
-
- - -
-

߂l

-

݂̃[JE^CDWORDlɃpbNĕԂBrbgEtB[h͎Ɏ悤ɂȂ܂B

-
-
bit31:25
-
1980NN_ƂN 0..127 ŃZbgB
-
bit24:21
-
1..12 ̒lŃZbgB
-
bit20:16
-
1..31 ̒lŃZbgB
-
bit15:11
-
0..23 ̒lŃZbgB
-
bit10:5
-
0..59 ̒lŃZbgB
-
bit4:0
-
b/2 0..29 ̒lŃZbg
-
-
- - -
-

-

RTCT|[gȂVXełA_~[Ƃĉ炩̓tƂėLȒlԂׂłB0ȂǂԂꍇÃt@C̃^CX^v͖ɂȂ܂B

-
- - -
-

Ή

-

[hEI[\(_FS_READONLY == 1)ł͂̊֐͕KvƂ܂B

-
- - -

߂

- - + + + + + + + + +FatFs - get_fattime + + + + +
+

get_fattime

+

ݎ擾܂B

+
+DWORD get_fattime (void);
+
+
+ + +
+

߂l

+

݂̃[JE^CDWORDlɃpbNĕԂ܂BrbgEtB[h͎Ɏ悤ɂȂ܂B

+
+
bit31:25
+
1980NN_ƂN 0..127 ŃZbgB
+
bit24:21
+
1..12 ̒lŃZbgB
+
bit20:16
+
1..31 ̒lŃZbgB
+
bit15:11
+
0..23 ̒lŃZbgB
+
bit10:5
+
0..59 ̒lŃZbgB
+
bit4:0
+
b/2 0..29 ̒lŃZbg
+
+
+ + +
+

+

RTCT|[gȂVXełA_~[Ƃĉ炩̓tƂėLȒlԂׂłB0ȂǂԂꍇÃt@C̃^CX^v͖ɂȂ܂B

+
+ + +
+

Ή

+

[hEI[\(_FS_READONLY == 1)ł͂̊֐͕KvƂ܂B

+
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/fdisk.html b/3rdparty/fatfs-0.10b/doc/ja/fdisk.html similarity index 97% rename from src/gfile/fatfs/doc/ja/fdisk.html rename to 3rdparty/fatfs-0.10b/doc/ja/fdisk.html index 27f78b33..0138803d 100644 --- a/src/gfile/fatfs/doc/ja/fdisk.html +++ b/3rdparty/fatfs-0.10b/doc/ja/fdisk.html @@ -1,97 +1,97 @@ - - - - - - - - -FatFs - f_fdisk - - - - -
-

f_fdisk

-

hCu𕪊܂B

-
-FRESULT f_fdisk (
-  BYTE  pdrv,         /* [IN] hCuԍ */
-  const DWORD part[], /* [IN] }bvEe[u */
-  void* work          /* [-] [NGA */
-);
-
-
- -
-

-
-
pdrv
-
hCũhCuԍw肵܂B
-
part[]
-
}bvEe[uւ̃|C^w肵܂B
-
work
-
[NGAւ̃|C^w肵܂BTCY_MAX_SSoCgKvłB
-
-
- - - -
-

-

̊֐́Aw肳ꂽhCuMBRɋe[u쐬܂B敪͈ʓIFDISK`ōs߁Aő4‚̊{쐬邱Ƃł܂Bgɂ͑ΉĂ܂B}bve[upart[]ɂ̓hCuǂ̂悤ɕ邩w肵ēn܂B̔z4‚̍ڂ琬A擪̍ڂ1Ԗڂ́AŌ̍ڂ4Ԗڂ̋̃TCY܂Bl100ȉ̏ꍇAhCȗeʂɑ΂銄p[ZgPʂŎw肵܂B100𒴂l̏ꍇ̓ZN^̒ڎwɂȂ܂B

-
- -
-

Ή

-

_FS_READOLNY == 0 _USE_MKFS == 1 _MULTI_PARTITION == 1 ̂Ƃgp”\łB

-
- -
-

gp

-
-    /* [U`̃{[Ǘe[u (_MULTI_PARTITION == 1 ̂ƂKv) */
-
-    PARTITION VolToPart[] = {
-        {0, 1},    /* _hCu 0 ==> hCu 0, 1 */
-        {0, 2},    /* _hCu 1 ==> hCu 0, 2 */
-        {1, 0}     /* _hCu 2 ==> hCu 1, o */
-    };
-
-
-    /* VhCu(0)̏ */
-
-    FATFS fs;
-    DWORD plist[] = {50, 50, 0, 0};  /* 2 */
-    BYTE work[_MAX_SS];
-
-    f_fdisk(0, plist, work);  /* hCu 0 ̕ */
-
-    f_mount(&fs "0:", 0);
-    f_mkfs("0:", 0, 0);       /* _hCu 0 ̃tH[}bg. ͖.  */
-    f_mount(0, "0:", 0);
-
-    f_mount(&fs, "1:", 0);
-    f_mkfs("1:", 0, 0);       /* _hCu 0 ̃tH[}bg. ͖.  */
-    f_mount(0, "1:", 0);
-
-
-
- -
-

See Also

-

Volume management, f_mkfs

-
- -

Return

- - + + + + + + + + +FatFs - f_fdisk + + + + +
+

f_fdisk

+

hCu𕪊܂B

+
+FRESULT f_fdisk (
+  BYTE  pdrv,         /* [IN] hCuԍ */
+  const DWORD part[], /* [IN] }bvEe[u */
+  void* work          /* [-] [NGA */
+);
+
+
+ +
+

+
+
pdrv
+
hCũhCuԍw肵܂B
+
part[]
+
}bvEe[uւ̃|C^w肵܂B
+
work
+
[NGAւ̃|C^w肵܂BTCY_MAX_SSoCgKvłB
+
+
+ + + +
+

+

̊֐́Aw肳ꂽhCuMBRɋe[u쐬܂B敪͈ʓIFDISK`ōs߁Aő4‚̊{쐬邱Ƃł܂Bgɂ͑ΉĂ܂B}bve[upart[]ɂ̓hCuǂ̂悤ɕ邩w肵ēn܂B̔z4‚̍ڂ琬A擪̍ڂ1Ԗڂ́AŌ̍ڂ4Ԗڂ̋̃TCY܂Bl100ȉ̏ꍇAhCȗeʂɑ΂銄p[ZgPʂŎw肵܂B100𒴂l̏ꍇ̓ZN^̒ڎwɂȂ܂B

+
+ +
+

Ή

+

_FS_READOLNY == 0 _USE_MKFS == 1 _MULTI_PARTITION == 1 ̂Ƃgp”\łB

+
+ +
+

gp

+
+    /* [U`̃{[Ǘe[u (_MULTI_PARTITION == 1 ̂ƂKv) */
+
+    PARTITION VolToPart[] = {
+        {0, 1},    /* _hCu 0 ==> hCu 0, 1 */
+        {0, 2},    /* _hCu 1 ==> hCu 0, 2 */
+        {1, 0}     /* _hCu 2 ==> hCu 1, o */
+    };
+
+
+    /* VhCu(0)̏ */
+
+    FATFS fs;
+    DWORD plist[] = {50, 50, 0, 0};  /* 2 */
+    BYTE work[_MAX_SS];
+
+    f_fdisk(0, plist, work);  /* hCu 0 ̕ */
+
+    f_mount(&fs "0:", 0);
+    f_mkfs("0:", 0, 0);       /* _hCu 0 ̃tH[}bg. ͖.  */
+    f_mount(0, "0:", 0);
+
+    f_mount(&fs, "1:", 0);
+    f_mkfs("1:", 0, 0);       /* _hCu 0 ̃tH[}bg. ͖.  */
+    f_mount(0, "1:", 0);
+
+
+
+ +
+

See Also

+

Volume management, f_mkfs

+
+ +

Return

+ + diff --git a/src/gfile/fatfs/doc/ja/filename.html b/3rdparty/fatfs-0.10b/doc/ja/filename.html similarity index 99% rename from src/gfile/fatfs/doc/ja/filename.html rename to 3rdparty/fatfs-0.10b/doc/ja/filename.html index c57d7aa1..5feff512 100644 --- a/src/gfile/fatfs/doc/ja/filename.html +++ b/3rdparty/fatfs-0.10b/doc/ja/filename.html @@ -1,76 +1,76 @@ - - - - - - - - -FatFs - パス名のフォーマット - - - -

パス名のフォーマット

-
-

ファイル・ディレクトリ名

-

FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。

-
"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"
-

FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、(_USE_LFN > 0)のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく'/''\'を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、'0''9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。

-

ヌル文字や制御文字('\0''\x1F')は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。

-

標準構成(_FS_RPATH == 0)のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ("."や"..")は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。

-

相対パスを有効(_FS_RPATH == 1)にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合はf_chdir()で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号はf_chdrive()で設定された値となります。

- - - - - - - - - - - - - -
パス名の例_FS_RPATH == 0_FS_RPATH == 1
file.txtドライブ0のルート・ディレクトリ下のファイルカレント・ドライブのカレント・ディレクトリ下のファイル
/file.txtドライブ0のルート・ディレクトリ下のファイルカレント・ドライブのルート・ディレクトリ下のファイル
ドライブ0のルート・ディレクトリカレント・ドライブのカレント・ディレクトリ
2:ドライブ2のルート・ディレクトリドライブ2のカレント・ディレクトリ
2:file1.txtドライブ2のルート・ディレクトリ下のファイルドライブ2のカレント・ディレクトリ下のファイル
2:/ドライブ2のルート・ディレクトリドライブ2のルート・ディレクトリ
../file.txt無効親ディレクトリ下のファイル
.無効このディレクトリ
..無効カレント・ディレクトリの親ディレクトリ
dir1/..無効カレント・ディレクトリ
/..無効ルート・ディレクトリ(その上は辿れない)
-

また、_STR_VOLUME_IDオプションを有効にすることでドライブ番号の識別には数字のほか、任意の文字列を使用することも可能になります。

-
- -


-
-

Unicode API

-

ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、TCHARで定義されていますが、これは通常はcharのエリアスになっています。そして、_CODE_PAGEで指定されるANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(_LFN_UNICODE == 1)にしたときは、TCHARはワイド文字(WCHAR, unsigned short)に切り替わり、パス名の入出力にUnicodeを使用するようになります。これによりLFN規格に完全対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とファイル上のエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように_T(s)および_TEXT(s)マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。

-
- f_open(fp, "filename.txt", FA_READ);      /* ANSI/OEM専用コード */
- f_open(fp, L"filename.txt", FA_READ);     /* Unicode専用コード */
- f_open(fp, _T("filename.txt"), FA_READ);  /* 両用コード(自動切り替え) */
-
-
- -


-
-

ボリューム管理

-

デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0、第一区画~第四区画の順に行われます。

-

_MULTI_PARTITIONに1を指定すると、それぞれの論理ドライブに対して個別に物理ドライブ番号と区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。

-
-例:論理ドライブ0~2を物理ドライブ0(非リムーバブル)の3つの基本区画に割り当て、
-   論理ドライブ3を物理ドライブ1(リムーバブル)に割り当てる場合。
-
-PARTITION VolToPart[] = {
-    {0, 1},     /* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */
-    {0, 2},     /* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */
-    {0, 3},     /* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */
-    {1, 0}      /* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */
-};
-
-論理ドライブと物理ドライブの関係
-
-

複数区画指定を使用する場合、次の点に注意しなければなりません。 -

    -
  • マウント可能な区画は基本区画のみで、拡張区画内には対応しない。
  • -
  • 複数のマウントされた区画を持つ物理ドライブは、非リムーバブルでなければならず、システム動作中のメディア交換は禁止。
  • -
-
- - - + + + + + + + + +FatFs - パス名のフォーマット + + + +

パス名のフォーマット

+
+

ファイル・ディレクトリ名

+

FatFsモジュールでのファイル、ディレクトリ、ドライブの指定方法はDOS/Windows APIとほぼ同じです。パス名のフォーマットは次の通りです。

+
"[論理ドライブ番号:][/]ディレクトリ名/ファイル名"
+

FatFsモジュールは長いファイル名(LFN)および8.3形式ファイル名(SFN)に対応しています。LFNは、(_USE_LFN > 0)のとき使用可能になります。ディレクトリ・セパレータにはDOS/Windows APIと同じく'/''\'を使用します。連続したセパレータは無視され1個として扱われます。唯一の違いは、論理ドライブの指定だけです。論理ドライブ番号は、'0''9'の一文字の数字とコロンで指定し、省略した場合はデフォルト・ドライブ(0またはカレント・ドライブ)が選択されます。

+

ヌル文字や制御文字('\0''\x1F')は、パス名の終端として認識されます。パス名に先行あるいは中に含まれるスペースは、LFN構成では名前の一部として有効ですが、非LFN構成ではスペースはパス名の終端として認識されます。

+

標準構成(_FS_RPATH == 0)のときは、全てのオブジェクトがルート・ディレクトリから辿る絶対パスで指定されます。OS指向なカレント・ディレクトリという概念は無く、またドット・ディレクトリ("."や"..")は使用できません。パス名先頭のセパレータは無視されます。デフォルト・ドライブ番号は常に0になります。

+

相対パスを有効(_FS_RPATH == 1)にしたときは、先行するセパレータの有無によって検索開始ディレクトリが変わり、セパレータがある場合はルート・ディレクトリから、無い場合はf_chdir()で設定されるカレント・ディレクトリからになります。またパス名にドット・ディレクトリが使用できます。デフォルト・ドライブ番号はf_chdrive()で設定された値となります。

+ + + + + + + + + + + + + +
パス名の例_FS_RPATH == 0_FS_RPATH == 1
file.txtドライブ0のルート・ディレクトリ下のファイルカレント・ドライブのカレント・ディレクトリ下のファイル
/file.txtドライブ0のルート・ディレクトリ下のファイルカレント・ドライブのルート・ディレクトリ下のファイル
ドライブ0のルート・ディレクトリカレント・ドライブのカレント・ディレクトリ
2:ドライブ2のルート・ディレクトリドライブ2のカレント・ディレクトリ
2:file1.txtドライブ2のルート・ディレクトリ下のファイルドライブ2のカレント・ディレクトリ下のファイル
2:/ドライブ2のルート・ディレクトリドライブ2のルート・ディレクトリ
../file.txt無効親ディレクトリ下のファイル
.無効このディレクトリ
..無効カレント・ディレクトリの親ディレクトリ
dir1/..無効カレント・ディレクトリ
/..無効ルート・ディレクトリ(その上は辿れない)
+

また、_STR_VOLUME_IDオプションを有効にすることでドライブ番号の識別には数字のほか、任意の文字列を使用することも可能になります。

+
+ +


+
+

Unicode API

+

ファイル関数の入出力のうちファイル名やパス名を指定する引数の型は、TCHARで定義されていますが、これは通常はcharのエリアスになっています。そして、_CODE_PAGEで指定されるANSI/OEMコード(SBCSまたはDBCS)の文字列として扱われます。ファイル名入出力をUnicodeとする構成(_LFN_UNICODE == 1)にしたときは、TCHARはワイド文字(WCHAR, unsigned short)に切り替わり、パス名の入出力にUnicodeを使用するようになります。これによりLFN規格に完全対応となり、ANSI/OEMコードにない文字(たとえば ✝☪✡☸☭など)も使用できます。この設定は文字列入出力関数のデータ型とファイル上のエンコーディングにも影響を与えます。リテラル文字列を定義するとき、次に示すように_T(s)および_TEXT(s)マクロを使ってANSI/OEMとUnicodeを自動切り替えすることができます。

+
+ f_open(fp, "filename.txt", FA_READ);      /* ANSI/OEM専用コード */
+ f_open(fp, L"filename.txt", FA_READ);     /* Unicode専用コード */
+ f_open(fp, _T("filename.txt"), FA_READ);  /* 両用コード(自動切り替え) */
+
+
+ +


+
+

ボリューム管理

+

デフォルトの構成では、それぞれの論理ドライブは同じ番号の物理ドライブに1:1で結びつけられていて、自動検出機能によりその物理ドライブ上の一つのFATボリュームがマウントされます。FATボリュームの検出は、セクタ0、第一区画~第四区画の順に行われます。

+

_MULTI_PARTITIONに1を指定すると、それぞれの論理ドライブに対して個別に物理ドライブ番号と区画を指定できるようになります。この構成では、論理ドライブと区画の対応を解決するためのテーブルを次に示すように定義する必要があります。

+
+例:論理ドライブ0~2を物理ドライブ0(非リムーバブル)の3つの基本区画に割り当て、
+   論理ドライブ3を物理ドライブ1(リムーバブル)に割り当てる場合。
+
+PARTITION VolToPart[] = {
+    {0, 1},     /* 論理ドライブ 0 ==> 物理ドライブ 0, 第1区画 */
+    {0, 2},     /* 論理ドライブ 1 ==> 物理ドライブ 0, 第2区画 */
+    {0, 3},     /* 論理ドライブ 2 ==> 物理ドライブ 0, 第3区画 */
+    {1, 0}      /* 論理ドライブ 3 ==> 物理ドライブ 1, 自動検出 */
+};
+
+論理ドライブと物理ドライブの関係
+
+

複数区画指定を使用する場合、次の点に注意しなければなりません。 +

    +
  • マウント可能な区画は基本区画のみで、拡張区画内には対応しない。
  • +
  • 複数のマウントされた区画を持つ物理ドライブは、非リムーバブルでなければならず、システム動作中のメディア交換は禁止。
  • +
+
+ + + diff --git a/src/gfile/fatfs/doc/ja/forward.html b/3rdparty/fatfs-0.10b/doc/ja/forward.html similarity index 97% rename from src/gfile/fatfs/doc/ja/forward.html rename to 3rdparty/fatfs-0.10b/doc/ja/forward.html index ffb2e60a..a5191c5a 100644 --- a/src/gfile/fatfs/doc/ja/forward.html +++ b/3rdparty/fatfs-0.10b/doc/ja/forward.html @@ -1,140 +1,140 @@ - - - - - - - - -FatFs - f_forward - - - - -
-

f_forward

-

t@Cf[^ǂݏoAMXg[ɒړ]܂B

-
-FRESULT f_forward (
-  FIL* fp,                         /* [IN] t@CEIuWFNg\ */
-  UINT (*func)(const BYTE*,UINT),  /* [IN] f[^]֐ */
-  UINT btf,                        /* [IN] ]oCg */
-  UINT* bf                         /* [OUT] ]ꂽoCg */
-);
-
-
- -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
func
-
f[^n[U`֐ւ̃|C^w肵܂B̊֐̎dl̓TvQƂĂB
-
btf
-
]oCg(0`UINT̍ől)w肵܂B
-
bf
-
ۂɓ]ꂽoCgi[ϐw|C^w肵܂B
-
-
- - - - - -
-

-

t@C̃f[^obt@ɓǂݏoɑMXg[ɒړ]܂BAvP[VŃf[^Eobt@KvƂȂ̂ŁǍꂽ‹ŗLłB[h/CgE|C^͓]ꂽoCgi݂܂Bw肳ꂽoCg̓]Ƀt@C̏I[ɒBꍇ⑗MXg[rW[ɂȂꍇA*bfbtfȂ܂B

-
- - -
-

Ή

-

_USE_FORWARD == 1ŁA_FS_TINY == 1̂ƂɎgp”\łB

-
- - -
-

gpiI[fBIĐj

-
-/*-----------------------------------------------------------------------*/
-/* f_forward֐Ă΂f[^M֐̗                           */
-/*-----------------------------------------------------------------------*/
-
-UINT out_stream (   /* ߂l: ]ꂽoCg܂̓Xg[̏ */
-    const BYTE *p,  /* ]f[^w|C^ */
-    UINT btf        /* >0: ]s(oCg). 0: Xg[̏Ԃ𒲂ׂ */
-)
-{
-    UINT cnt = 0;
-
-
-    if (btf == 0) {     /* ZXv */
-        /* Xg[̏ԂԂ (0: rW[, 1: fB) */
-        /* UAfBԂA]vŏȂƂ1oCg */
-        /* ]Ȃ f_forward֐ FR_INT_ERR ƂȂB */
-        if (FIFO_READY) cnt = 1;
-    }
-    else {              /* ]v */
-        do {    /* SẴoCg]邩AXg[rW[ɂȂ܂ŌJԂ */
-            FIFO_PORT = *p++;
-            cnt++;
-        } while (cnt < btf && FIFO_READY);
-    }
-
-    return cnt;
-}
-
-
-/*-----------------------------------------------------------------------*/
-/* f_forward֐̎gp                                                 */
-/*-----------------------------------------------------------------------*/
-
-FRESULT play_file (
-    char *fn        /* ĐI[fBIEt@Cw|C^ */
-)
-{
-    FRESULT rc;
-    FIL fil;
-    UINT dmy;
-
-    /* t@Cǂݏo[hŊJ */
-    rc = f_open(&fil, fn, FA_READ);
-    if (rc) return rc;
-
-    /* SẴf[^]邩G[܂ő */
-    while (rc == FR_OK && fil.fptr < fil.fsize) {
-
-        /* ق̏... */
-
-        /* I܂͗vɉăf[^Xg[ɑo */
-        rc = f_forward(&fil, out_stream, 1000, &dmy);
-    }
-
-    /* t@C‚Ė߂ */
-    f_close(&fil);
-    return rc;
-}
-
-
- - - - -

߂

- - + + + + + + + + +FatFs - f_forward + + + + +
+

f_forward

+

t@Cf[^ǂݏoAMXg[ɒړ]܂B

+
+FRESULT f_forward (
+  FIL* fp,                         /* [IN] t@CEIuWFNg\ */
+  UINT (*func)(const BYTE*,UINT),  /* [IN] f[^]֐ */
+  UINT btf,                        /* [IN] ]oCg */
+  UINT* bf                         /* [OUT] ]ꂽoCg */
+);
+
+
+ +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
func
+
f[^n[U`֐ւ̃|C^w肵܂B̊֐̎dl̓TvQƂĂB
+
btf
+
]oCg(0`UINT̍ől)w肵܂B
+
bf
+
ۂɓ]ꂽoCgi[ϐw|C^w肵܂B
+
+
+ + + + + +
+

+

t@C̃f[^obt@ɓǂݏoɑMXg[ɒړ]܂BAvP[VŃf[^Eobt@KvƂȂ̂ŁǍꂽ‹ŗLłB[h/CgE|C^͓]ꂽoCgi݂܂Bw肳ꂽoCg̓]Ƀt@C̏I[ɒBꍇ⑗MXg[rW[ɂȂꍇA*bfbtfȂ܂B

+
+ + +
+

Ή

+

_USE_FORWARD == 1ŁA_FS_TINY == 1̂ƂɎgp”\łB

+
+ + +
+

gpiI[fBIĐj

+
+/*-----------------------------------------------------------------------*/
+/* f_forward֐Ă΂f[^M֐̗                           */
+/*-----------------------------------------------------------------------*/
+
+UINT out_stream (   /* ߂l: ]ꂽoCg܂̓Xg[̏ */
+    const BYTE *p,  /* ]f[^w|C^ */
+    UINT btf        /* >0: ]s(oCg). 0: Xg[̏Ԃ𒲂ׂ */
+)
+{
+    UINT cnt = 0;
+
+
+    if (btf == 0) {     /* ZXv */
+        /* Xg[̏ԂԂ (0: rW[, 1: fB) */
+        /* UAfBԂA]vŏȂƂ1oCg */
+        /* ]Ȃ f_forward֐ FR_INT_ERR ƂȂB */
+        if (FIFO_READY) cnt = 1;
+    }
+    else {              /* ]v */
+        do {    /* SẴoCg]邩AXg[rW[ɂȂ܂ŌJԂ */
+            FIFO_PORT = *p++;
+            cnt++;
+        } while (cnt < btf && FIFO_READY);
+    }
+
+    return cnt;
+}
+
+
+/*-----------------------------------------------------------------------*/
+/* f_forward֐̎gp                                                 */
+/*-----------------------------------------------------------------------*/
+
+FRESULT play_file (
+    char *fn        /* ĐI[fBIEt@Cw|C^ */
+)
+{
+    FRESULT rc;
+    FIL fil;
+    UINT dmy;
+
+    /* t@Cǂݏo[hŊJ */
+    rc = f_open(&fil, fn, FA_READ);
+    if (rc) return rc;
+
+    /* SẴf[^]邩G[܂ő */
+    while (rc == FR_OK && fil.fptr < fil.fsize) {
+
+        /* ق̏... */
+
+        /* I܂͗vɉăf[^Xg[ɑo */
+        rc = f_forward(&fil, out_stream, 1000, &dmy);
+    }
+
+    /* t@C‚Ė߂ */
+    f_close(&fil);
+    return rc;
+}
+
+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/getcwd.html b/3rdparty/fatfs-0.10b/doc/ja/getcwd.html similarity index 92% rename from src/gfile/fatfs/doc/ja/getcwd.html rename to 3rdparty/fatfs-0.10b/doc/ja/getcwd.html index f104bc7d..13242809 100644 --- a/src/gfile/fatfs/doc/ja/getcwd.html +++ b/3rdparty/fatfs-0.10b/doc/ja/getcwd.html @@ -1,70 +1,70 @@ - - - - - - - - -FatFs - f_getcwd - - - - -
-

f_getcwd

-

JgEfBNg𓾂܂

-
-FRESULT f_getcwd (
-  TCHAR* buff, /* [OUT] obt@ */
-  UINT len     /* [IN] obt@ETCY */
-);
-
-
- -
-

-
-
buff
-
JgEfBNg̃pXi[obt@
-
len
-
TCHARPʂ̃obt@ETCY
-
-
- - - - - -
-

-

JgEhCũJgEfBNg̃tEpX擾܂B_VOLUMES2ȏ̂Ƃ́A_hCuԍ̕tꂽpXƂȂ܂B

-
- - -
-

Ή

-

_FS_RPATH == 2̂Ƃgp”\łB

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_getcwd + + + + +
+

f_getcwd

+

JgEfBNg𓾂܂B

+
+FRESULT f_getcwd (
+  TCHAR* buff, /* [OUT] obt@ */
+  UINT len     /* [IN] obt@ETCY */
+);
+
+
+ +
+

+
+
buff
+
JgEfBNg̃pXi[obt@
+
len
+
TCHARPʂ̃obt@ETCY
+
+
+ + + + + +
+

+

JgEhCũJgEfBNg̃tEpX擾܂B_VOLUMES2ȏ̂Ƃ́A_hCuԍ̕tꂽpXƂȂ܂B

+
+ + +
+

Ή

+

_FS_RPATH == 2̂Ƃgp”\łB

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/getfree.html b/3rdparty/fatfs-0.10b/doc/ja/getfree.html similarity index 82% rename from src/gfile/fatfs/doc/ja/getfree.html rename to 3rdparty/fatfs-0.10b/doc/ja/getfree.html index 4f1e43be..5235ce3b 100644 --- a/src/gfile/fatfs/doc/ja/getfree.html +++ b/3rdparty/fatfs-0.10b/doc/ja/getfree.html @@ -1,95 +1,95 @@ - - - - - - - - -FatFs - f_getfree - - - - -
-

f_getfree

-

{[̖gpNX^擾܂B

-
-FRESULT f_getfree (
-  const TCHAR* path,  /* [IN] ΏۃhCuw肵܂ */
-  DWORD* nclst,       /* [OUT] 󂫃NX^i[ϐւ̃|C^ */
-  FATFS** fatfs       /* [OUT] t@CEVXeEIuWFNgw|C^ւ̃|C^ */
-);
-
-
- -
-

-
-
path
-
ׂΏۂ̘_hCupXk'\0'I[̕ւ̃|C^w肵܂Bk̓JgEhCuӖ܂B
-
nclst
-
󂫃NX^i[DWORD^ϐւ̃|C^w肵܂B
-
fatfs
-
ΏۃhCũt@CEVXeEIuWFNgw|C^Ԃ܂B
-
-
- - - - - -
-

-

_hCű󂫃NX^擾܂BԂꂽt@CEVXeEIuWFNgcsizeoNX^̃ZN^Ă̂ŁAɃZN^Pʂ̋󂫃TCYvZł܂BFAT32{[ɂẮAFSINFȌ񂪎ۂ̋󂫃NX^ƓĂȂꍇAsmȒlԂ”\܂B̖邽߁A_FS_NOFSINFOIvVFSINFO𖳎ď̓tFATXL悤ɍ\邱Ƃł܂B

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

-
- - -
-

gp

-
-    FATFS *fs;
-    DWORD fre_clust, fre_sect, tot_sect;
-
-
-    /* hCu1̃{[Ƌ󂫃NX^𓾂 */
-    res = f_getfree("1:", &fre_clust, &fs);
-    if (res) die(res);
-
-    /* SZN^Ƌ󂫃ZN^vZ */
-    tot_sect = (fs->n_fatent - 2) * fs->csize;
-    fre_sect = fre_clust * fs->csize;
-
-    /* {[Ŝ̃TCYƋ󂫂̃TCY\ (512oCg/ZN^Ɖ) */
-    printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
-           tot_sect / 2, fre_sect / 2);
-
-
- - -
-

Q

-FATFS -
- -

߂

- - + + + + + + + + +FatFs - f_getfree + + + + +
+

f_getfree

+

{[̋󂫗̈̃TCY擾܂B

+
+FRESULT f_getfree (
+  const TCHAR* path,  /* [IN] ΏۃhCuw肵܂ */
+  DWORD* nclst,       /* [OUT] 󂫃NX^i[ϐւ̃|C^ */
+  FATFS** fatfs       /* [OUT] t@CEVXeEIuWFNgw|C^ւ̃|C^ */
+);
+
+
+ +
+

+
+
path
+
ׂΏۂ̘_hCupXk'\0'I[̕ւ̃|C^w肵܂Bk̓JgEhCuӖ܂B
+
nclst
+
󂫃NX^i[DWORD^ϐւ̃|C^w肵܂B
+
fatfs
+
ΏۃhCũt@CEVXeEIuWFNgw|C^Ԃ܂B
+
+
+ + + + + +
+

+

_hCű󂫗̈̃TCYNX^PʂŎ擾܂BԂꂽt@CEVXeEIuWFNgcsizeoNX^̃ZN^Ă̂ŁAɃZN^Pʂ̋󂫃TCYvZł܂BFAT32{[ɂẮAFSINFȌ񂪎ۂ̋󂫃NX^ƓĂȂꍇAsmȒlԂ”\܂B̖邽߁A_FS_NOFSINFOIvVŃ}Eg͕̏KtFATXL悤ɍ\邱Ƃł܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

+
+ + +
+

gp

+
+    FATFS *fs;
+    DWORD fre_clust, fre_sect, tot_sect;
+
+
+    /* hCu1̃{[Ƌ󂫃NX^𓾂 */
+    res = f_getfree("1:", &fre_clust, &fs);
+    if (res) die(res);
+
+    /* SZN^Ƌ󂫃ZN^vZ */
+    tot_sect = (fs->n_fatent - 2) * fs->csize;
+    fre_sect = fre_clust * fs->csize;
+
+    /* {[Ŝ̃TCYƋ󂫂̃TCY\ (512oCg/ZN^Ɖ) */
+    printf("%10lu KiB total drive space.\n%10lu KiB available.\n",
+           tot_sect / 2, fre_sect / 2);
+
+
+ + +
+

Q

+FATFS +
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/getlabel.html b/3rdparty/fatfs-0.10b/doc/ja/getlabel.html similarity index 96% rename from src/gfile/fatfs/doc/ja/getlabel.html rename to 3rdparty/fatfs-0.10b/doc/ja/getlabel.html index 957d2127..0bebbd41 100644 --- a/src/gfile/fatfs/doc/ja/getlabel.html +++ b/3rdparty/fatfs-0.10b/doc/ja/getlabel.html @@ -1,82 +1,82 @@ - - - - - - - - -FatFs - f_getlabel - - - - -
-

f_getlabel

-

{[Ex擾܂B

-
-FRESULT f_getlabel (
-  const TCHAR* path,  /* [IN] ΏۃhCu */
-  TCHAR* label,       /* [OUT] {[i[obt@ */
-  DWORD* vsn          /* [OUT] {[EVAԍi[ϐ */
-);
-
-
- -
-

-
-
path
-
ΏۂƂȂ_hCupXk'\0'I[̕ւ̃|C^w肵܂Bk̏ꍇ́AftHgEhCuw肵ƂɂȂ܂B
-
label
-
{[i[zւ̃|C^w肵܂BȂƂ12vf̃TCYKvłB{[Ȃꍇ̓k񂪕Ԃ܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
-
vsn
-
{[EVAԍi[DWORD^ϐւ̃|C^w肵܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
-
-
- - - - - -
-

Ή

-

_USE_LABEL == 1̂ƂɎgp”\łB

-
- - -
-

gp

-
-    char str[12];
-
-    /* ftHgEhCũ{[𓾂 */
-    f_getlabel("", str, 0);
-
-    /* hCu2̃{[𓾂 */
-    f_getlabel("2:", str, 0);
-
-
- - -
-

Q

-f_setlabel -
- - -

߂

- - + + + + + + + + +FatFs - f_getlabel + + + + +
+

f_getlabel

+

{[Ex擾܂B

+
+FRESULT f_getlabel (
+  const TCHAR* path,  /* [IN] ΏۃhCu */
+  TCHAR* label,       /* [OUT] {[i[obt@ */
+  DWORD* vsn          /* [OUT] {[EVAԍi[ϐ */
+);
+
+
+ +
+

+
+
path
+
ΏۂƂȂ_hCupXk'\0'I[̕ւ̃|C^w肵܂Bk̏ꍇ́AftHgEhCuw肵ƂɂȂ܂B
+
label
+
{[i[zւ̃|C^w肵܂BȂƂ12vf̃TCYKvłB{[Ȃꍇ̓k񂪕Ԃ܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
+
vsn
+
{[EVAԍi[DWORD^ϐւ̃|C^w肵܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
+
+
+ + + + + +
+

Ή

+

_USE_LABEL == 1̂ƂɎgp”\łB

+
+ + +
+

gp

+
+    char str[12];
+
+    /* ftHgEhCũ{[𓾂 */
+    f_getlabel("", str, 0);
+
+    /* hCu2̃{[𓾂 */
+    f_getlabel("2:", str, 0);
+
+
+ + +
+

Q

+f_setlabel +
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/gets.html b/3rdparty/fatfs-0.10b/doc/ja/gets.html similarity index 85% rename from src/gfile/fatfs/doc/ja/gets.html rename to 3rdparty/fatfs-0.10b/doc/ja/gets.html index 8c94db6c..1efa125b 100644 --- a/src/gfile/fatfs/doc/ja/gets.html +++ b/3rdparty/fatfs-0.10b/doc/ja/gets.html @@ -1,65 +1,65 @@ - - - - - - - - -FatFs - f_gets - - - - -
-

f_gets

-

t@C當ǂݏo܂B

-
-TCHAR* f_gets (
-  TCHAR* buff, /* [OUT] obt@ */
-  int len,     /* [IN] obt@̃TCY */
-  FIL* fp      /* [IN] t@CEIuWFNg */
-);
-
-
- -
-

-
-
buff
-
ǂݏoobt@w|C^w肵܂B
-
len
-
obt@̃TCYvfŎw肵܂B
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

֐buffԂ܂B

-
- - -
-

-

̊֐f_read()̃bp[֐łBǂݏóAŏ'\n'ǂݍނAt@CI[ɒB邩Alen - 1ǂݏo܂ő܂Bǂݍ܂ꂽ̏I[ɂ'\0't܂BɃt@CI[1ǂݍ܂ȂƂA܂͉炩̃G[Ƃ͊֐͎skE|C^Ԃ܂Bt@CI[G[f_eof(),f_error()}NŒׂ܂B

-

Unicode API\(_LFN_UNICODE == 1)IĂƂ́AbuffUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)œǂݏo܂B

-
- - -
-

Ή

-

_USE_STRFUNC1܂2̂Ƃgp”\łB2̂Ƃ́At@CɊ܂܂'\r'菜ăobt@ɓǂݍ܂܂B

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_gets + + + + +
+

f_gets

+

t@C當ǂݏo܂B

+
+TCHAR* f_gets (
+  TCHAR* buff, /* [OUT] obt@ */
+  int len,     /* [IN] obt@̃TCY */
+  FIL* fp      /* [IN] t@CEIuWFNg */
+);
+
+
+ +
+

+
+
buff
+
ǂݏoobt@w|C^w肵܂B
+
len
+
obt@̃TCYvfŎw肵܂B
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

֐buffԂ܂B

+
+ + +
+

+

̊֐f_read()̃bp[֐łBǂݏóAŏ'\n'ǂݍނAt@CI[ɒB邩Alen - 1ǂݏo܂ő܂Bǂݍ܂ꂽ̏I[ɂ'\0't܂BɃt@CI[1ǂݍ܂ȂƂA܂͉炩̃G[Ƃ͊֐͎skE|C^Ԃ܂Bt@CI[G[f_eof(),f_error()}NŒׂ܂B

+

Unicode API\(_LFN_UNICODE == 1)IĂƂ́AbuffUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)œǂݏo܂B

+
+ + +
+

Ή

+

_USE_STRFUNC1܂2̂Ƃgp”\łB2̂Ƃ́At@CɊ܂܂'\r'菜ăobt@ɓǂݍ܂܂B

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/lseek.html b/3rdparty/fatfs-0.10b/doc/ja/lseek.html similarity index 97% rename from src/gfile/fatfs/doc/ja/lseek.html rename to 3rdparty/fatfs-0.10b/doc/ja/lseek.html index 55788526..b9a6aa30 100644 --- a/src/gfile/fatfs/doc/ja/lseek.html +++ b/3rdparty/fatfs-0.10b/doc/ja/lseek.html @@ -1,129 +1,129 @@ - - - - - - - - -FatFs - f_lseek - - - - -
-

f_lseek

-

t@C̃[h/CgE|C^ړ܂B܂AV[N@\gpɂCLMT(q)̍쐬ɂgp܂B

-
-FRESULT f_lseek (
-  FIL* fp,    /* [IN] t@CEIuWFNg\̂ւ̃|C^ */
-  DWORD ofs   /* [IN] ړItZbg */
-);
-
-
- -
-

-
-
fp
-
ΏۂƂȂt@CEIuWFNg\̂ւ̃|C^w肵܂B
-
ofs
-
ړ̃ItZbg([h/CgE|C^)lBt@C擪̃ItZbgoCgPʂŎw肵܂B
-
-
- - - - - -
-

-

t@C̃[h/CgE|C^(ɓǂݏoE݂oCg̃ItZbg)ړ܂BItZbǧ_̓t@C擪łB݃[hŃt@CETCY傫Ȓlw肷ƁA܂Ńt@CETCYgAgꂽ̃f[^͖`ƂȂ܂Bf[^xɏ݂Ƃ́A\߂̊֐ŕKvȃTCY܂Ńt@CETCYgĂƗǂł傤Bf_lseek()IƂ́A[h/CgE|C^ړ`FbNׂłB[h/CgE|C^w菬Ƃ́Ǎl܂B

-
    -
  • 񏑂݃[h܂͍V[NE[ĥ߁At@CETCYŃNbvꂽB
  • -
  • t@CgɃfBXNtɂȂB
  • -
-

_USE_FASTSEEK1ŁAƒt@CEIuWFNgcltbloNULLȊO(f_open()NULLɐݒ肳)̂ƂAV[NE[hɂȂ܂B̓t@C̃NX^zu(CLMT)ɕێĂƂɂAFATɃANZX邱ƂȂV[N⃍OEV[Nɍs@\łBV[NE[h́Af_read()/f_wtite()̓ɂKp܂BV[NE[hłf_wtite()/f_lseek()ɂt@CETCY̊g͂ł܂B

-

V[NsOɁACLMT쐬ĂKv܂B쐬ɂ́A܂CLMTi[obt@(DWORD^z)Acltbloɂ̃|C^Zbg܂BāAz̐擪vfɂ̔z̃TCY(vf)Af_lseek()ofsCREATE_LINKMAPw肵ČĂяo܂B֐CLMT쐬Aȍ~f_read()/f_write()/f_lseek()łFATւ̃ANZX͔܂BFR_NOT_ENOUGH_COREŎsƂ͔zTCYsŁA擪vfɂ͎ۂɕKvƂȂvfԂ܂BKvȗvf́A(t@C̕ + 1) * 2 łBƂ΁At@C5‚̃tOgɕfĂƂɕKvȗvf́A12ƂȂ܂B

-
- - -
-

Ή

-

_FS_MINIMIZE < 3̂Ƃgp”\łB

-
- - -
-

gp

-
-    /* t@CJ */
-    fp = malloc(sizeof (FIL));
-    res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
-    if (res) ...
-
-    /* t@CEItZbg5000ֈړ */
-    res = f_lseek(fp, 5000);
-
-    /* t@CI[ֈړ(t@CNjL̏) */
-    res = f_lseek(fp, f_size(fp));
-
-    /* 3000oCgi߂ */
-    res = f_lseek(fp, f_tell(fp) + 3000);
-
-    /* 2000oCg߂ (bvAEhɒ) */
-    res = f_lseek(fp, f_tell(fp) - 2000);
-
-
-/* NX^s蓖 (Xg[~OECg̃obt@EI[o[h~) */
-
-    res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE);    /* t@C쐬 */
-
-    res = f_lseek(fp, MAX_SIZE);             /* \ȃNX^̐s蓖 */
-    if (res || f_tell(fp) != PRE_SIZE) ...   /* t@Cgꂽ`FbN */
-
-    res = f_lseek(fp, DATA_START);           /* f[^EXg[̋L^(AP[VfBC) */
-    ...
-
-    res = f_truncate(fp);                    /* sv̈̐؂̂ */
-    res = f_lseek(fp, 0);                    /* wb_̋L^ */
-    ...
-
-    res = f_close(fp);
-
-
-/* V[N@\g */
-
-    DWORD clmt[SZ_TBL];                    /* NE}bvEe[ui[obt@ */
-
-    res = f_lseek(fp, ofs1);               /* ʏV[N (I[vAcltblNULLɏ) */
-
-    fp->cltbl = clmt;                      /* V[N@\̗L */
-    clmt[0] = SZ_TBL;                      /* 擪vfɔzvfZbg */
-    res = f_lseek(fp, CREATE_LINKMAP);     /* CLMT̍쐬 */
-    ...
-
-    res = f_lseek(fp, ofs2);               /* ȍ~Af_read/f_write/f_lseekFATANZX͔Ȃ */
-
-
- - -
-

Q

-

f_open, FIL

-
- -

߂

- - + + + + + + + + +FatFs - f_lseek + + + + +
+

f_lseek

+

t@C̃[h/CgE|C^ړ܂B܂AV[N@\gpɂCLMT(q)̍쐬ɂgp܂B

+
+FRESULT f_lseek (
+  FIL* fp,    /* [IN] t@CEIuWFNg\̂ւ̃|C^ */
+  DWORD ofs   /* [IN] ړItZbg */
+);
+
+
+ +
+

+
+
fp
+
ΏۂƂȂt@CEIuWFNg\̂ւ̃|C^w肵܂B
+
ofs
+
ړ̃ItZbg([h/CgE|C^)lBt@C擪̃ItZbgoCgPʂŎw肵܂B
+
+
+ + + + + +
+

+

t@C̃[h/CgE|C^(ɓǂݏoE݂oCg̃ItZbg)ړ܂BItZbǧ_̓t@C擪łB݃[hŃt@CETCY傫Ȓlw肷ƁA܂Ńt@CETCYgAgꂽ̃f[^͖`ƂȂ܂Bf[^xɏ݂Ƃ́A\߂̊֐ŕKvȃTCY܂Ńt@CETCYgĂƗǂł傤Bf_lseek()IƂ́A[h/CgE|C^ړ`FbNׂłB[h/CgE|C^w菬Ƃ́Ǎl܂B

+
    +
  • 񏑂݃[h܂͍V[NE[ĥ߁At@CETCYŃNbvꂽB
  • +
  • t@CgɃfBXNtɂȂB
  • +
+

_USE_FASTSEEK1ŁAƒt@CEIuWFNgcltbloNULLȊO(f_open()NULLɐݒ肳)̂ƂAV[NE[hɂȂ܂B̓t@C̃NX^zu(CLMT)ɕێĂƂɂAFATɃANZX邱ƂȂV[N⃍OEV[Nɍs@\łBV[NE[h́Af_read()/f_wtite()̓ɂKp܂BV[NE[hłf_wtite()/f_lseek()ɂt@CETCY̊g͂ł܂B

+

V[NsOɁACLMT쐬ĂKv܂B쐬ɂ́A܂CLMTi[obt@(DWORD^z)Acltbloɂ̃|C^Zbg܂BāAz̐擪vfɂ̔z̃TCY(vf)Af_lseek()ofsCREATE_LINKMAPw肵ČĂяo܂B֐CLMT쐬Aȍ~f_read()/f_write()/f_lseek()łFATւ̃ANZX͔܂BFR_NOT_ENOUGH_COREŎsƂ͔zTCYsŁA擪vfɂ͎ۂɕKvƂȂvfԂ܂BKvȗvf́A(t@C̕ + 1) * 2 łBƂ΁At@C5‚̃tOgɕfĂƂɕKvȗvf́A12ƂȂ܂B

+
+ + +
+

Ή

+

_FS_MINIMIZE < 3̂Ƃgp”\łB

+
+ + +
+

gp

+
+    /* t@CJ */
+    fp = malloc(sizeof (FIL));
+    res = f_open(fp, "file.dat", FA_READ|FA_WRITE);
+    if (res) ...
+
+    /* t@CEItZbg5000ֈړ */
+    res = f_lseek(fp, 5000);
+
+    /* t@CI[ֈړ(t@CNjL̏) */
+    res = f_lseek(fp, f_size(fp));
+
+    /* 3000oCgi߂ */
+    res = f_lseek(fp, f_tell(fp) + 3000);
+
+    /* 2000oCg߂ (bvAEhɒ) */
+    res = f_lseek(fp, f_tell(fp) - 2000);
+
+
+/* NX^s蓖 (Xg[~OECg̃obt@EI[o[h~) */
+
+    res = f_open(fp, "record.wav", FA_CREATE_NEW | FA_WRITE);    /* t@C쐬 */
+
+    res = f_lseek(fp, MAX_SIZE);             /* \ȃNX^̐s蓖 */
+    if (res || f_tell(fp) != PRE_SIZE) ...   /* t@Cgꂽ`FbN */
+
+    res = f_lseek(fp, DATA_START);           /* f[^EXg[̋L^(AP[VfBC) */
+    ...
+
+    res = f_truncate(fp);                    /* sv̈̐؂̂ */
+    res = f_lseek(fp, 0);                    /* wb_̋L^ */
+    ...
+
+    res = f_close(fp);
+
+
+/* V[N@\g */
+
+    DWORD clmt[SZ_TBL];                    /* NE}bvEe[ui[obt@ */
+
+    res = f_lseek(fp, ofs1);               /* ʏV[N (I[vAcltblNULLɏ) */
+
+    fp->cltbl = clmt;                      /* V[N@\̗L */
+    clmt[0] = SZ_TBL;                      /* 擪vfɔzvfZbg */
+    res = f_lseek(fp, CREATE_LINKMAP);     /* CLMT̍쐬 */
+    ...
+
+    res = f_lseek(fp, ofs2);               /* ȍ~Af_read/f_write/f_lseekFATANZX͔Ȃ */
+
+
+ + +
+

Q

+

f_open, FIL

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/mkdir.html b/3rdparty/fatfs-0.10b/doc/ja/mkdir.html similarity index 96% rename from src/gfile/fatfs/doc/ja/mkdir.html rename to 3rdparty/fatfs-0.10b/doc/ja/mkdir.html index ef107d3f..a0f71580 100644 --- a/src/gfile/fatfs/doc/ja/mkdir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/mkdir.html @@ -1,80 +1,80 @@ - - - - - - - - -FatFs - f_mkdir - - - - -
-

f_mkdir

-

fBNg쐬܂B

-
-FRESULT f_mkdir (
-  const TCHAR* path /* [IN] 쐬fBNgւ̃|C^ */
-);
-
-
- -
-

-
-
path
-
쐬fBNgpXk'\0'I[̕ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

̃fBNg쐬܂B

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

-
- - -
-

gp

-
-    res = f_mkdir("sub1");
-    if (res) die(res);
-    res = f_mkdir("sub1/sub2");
-    if (res) die(res);
-    res = f_mkdir("sub1/sub2/sub3");
-    if (res) die(res);
-
-
- -

߂

- - + + + + + + + + +FatFs - f_mkdir + + + + +
+

f_mkdir

+

fBNg쐬܂B

+
+FRESULT f_mkdir (
+  const TCHAR* path /* [IN] 쐬fBNgւ̃|C^ */
+);
+
+
+ +
+

+
+
path
+
쐬fBNgpXk'\0'I[̕ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

̃fBNg쐬܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂Ƃgp”\łB

+
+ + +
+

gp

+
+    res = f_mkdir("sub1");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2");
+    if (res) die(res);
+    res = f_mkdir("sub1/sub2/sub3");
+    if (res) die(res);
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/mkfs.html b/3rdparty/fatfs-0.10b/doc/ja/mkfs.html similarity index 92% rename from src/gfile/fatfs/doc/ja/mkfs.html rename to 3rdparty/fatfs-0.10b/doc/ja/mkfs.html index 02e98f99..9a7465f9 100644 --- a/src/gfile/fatfs/doc/ja/mkfs.html +++ b/3rdparty/fatfs-0.10b/doc/ja/mkfs.html @@ -1,73 +1,73 @@ - - - - - - - - -FatFs - f_mkfs - - - - -
-

f_mkfs

-

_hCuFAT{[쐬(tH[}bg)܂B

-
-FRESULT f_mkfs (
-  const TCHAR* path, /* [IN] _hCuԍ */
-  BYTE  sfd,         /* [IN] 쐬@ */
-  UINT  au           /* [IN] NXE^TCY */
-);
-
-
- -
-

-
-
path
-
tH[}bgΏۂ̘_hCupXk'\0'I[̕ւ̃|C^w肵܂BhCuԍ܂܂Ȃꍇ́AJgEhCuӖ܂B
-
sfd
-
p[e[V`B(0(FDISK) ܂ 1(SFD))
-
au
-
NX^ETCYoCgPʂŎw肵܂BΏۃhCũZN^ETCYn{(n = 1`128ŁA2̗ݏ)łȂ΂Ȃ܂B0w肵ꍇA{[̃TCYɉftHg̃NX^ETCYI܂B
-
-
- - - -
-

-

hCuFAT{[쐬܂BFDISK`w肳ꂽꍇ́AhCuŜ߂{(p[e[V)쐬A̒FAT{[쐬܂BSFD`ł́AFAT{[hCu̐擪ZN^x^ō쐬܂B

-

tH[}bg_hCu}`Ep[e[V@\(_MULTI_PARTITION)ɂē̋(1`4)ɌѕtĂꍇ́A̋̒FAT{[쐬܂Bsfd͖A܂Ή镨hCu͂ɐ旧Af_fdisk()܂͑̃c[œK؂ɋݒ肳ĂKv܂B

-

p[e[V`ɂ́AFDISK`SFD`̓ʂ肠܂BFDISK`́An[hfBXNAMMCASDCACFCAU DiskȂǂŕWIɎgp܂BFDISK`ł͈̕hCuɈ‚܂͕̋쐬邱Ƃł܂BǗMBR(hCu̐擪ZN^)ɋL^܂BSFD`͒Pɉ̕sȂ`ŁA{[͕hCu̐擪ZN^Jn܂BSFD`́Atbs[EfBXNA}CNhCuAwfBXNAт̑X[p[Etbs[EfBAŕWIɎgpĂ܂B

-

FAT^Cv(FAT12/FAT16/FAT32)́Ã{[NX^ɂĂ̂݌錈܂[FATdl]ɂȂĂāAȊO̗v͂܂BāAǂFAT^CvɂȂ邩̓{[ETCYƃNX^ETCYɈˑ܂BNX^ETCY͑傫قǐ\オ܂B

-

NX^FAT^Cv̋Eɋ߂ȂƂ́AFR_MKFS_ABORTEDŊ֐s”\܂B

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_USE_MKFS == 1̂Ƃgp”\łB

-
- - -
-

Q

-

{[Ǘ, f_fdisk

-
- -

߂

- - + + + + + + + + +FatFs - f_mkfs + + + + +
+

f_mkfs

+

_hCuFAT{[쐬(tH[}bg)܂B

+
+FRESULT f_mkfs (
+  const TCHAR* path, /* [IN] _hCuԍ */
+  BYTE  sfd,         /* [IN] 쐬@ */
+  UINT  au           /* [IN] NXE^TCY */
+);
+
+
+ +
+

+
+
path
+
tH[}bgΏۂ̘_hCupXk'\0'I[̕ւ̃|C^w肵܂BhCuԍ܂܂Ȃꍇ́AJgEhCuӖ܂B
+
sfd
+
p[e[V`B(0(FDISK) ܂ 1(SFD))
+
au
+
NX^ETCYoCgPʂŎw肵܂Bl͑ΏۃhCũZN^ETCYn{(n = 1`128ŁA2̗ݏ)łȂ΂Ȃ܂B0Ȃǂ̖lw肵ꍇA{[̃TCYɉftHg̃NX^ETCYI܂B
+
+
+ + + +
+

+

hCuFAT{[쐬܂BFDISK`w肳ꂽꍇ́AhCuŜ߂{(p[e[V)쐬A̒FAT{[쐬܂BSFD`ł́AFAT{[hCu̐擪ZN^x^ō쐬܂B

+

tH[}bg_hCu}`Ep[e[V@\(_MULTI_PARTITION)ɂē̋(1`4)ɌѕtĂꍇ́A̋̒FAT{[쐬܂Bsfd͖A܂Ή镨hCu͂ɐ旧Af_fdisk()܂͑̃c[œK؂ɋݒ肳ĂKv܂B

+

p[e[V`ɂ́AFDISK`SFD`̓ʂ肠܂BFDISK`́An[hfBXNAMMCASDCACFCAU DiskȂǂŕWIɎgp܂BFDISK`ł͈̕hCuɈ‚܂͕̋쐬邱Ƃł܂BǗMBR(hCu̐擪ZN^)ɋL^܂BSFD`͒Pɉ̕sȂ`ŁA{[͕hCu̐擪ZN^Jn܂BSFD`́Atbs[EfBXNA}CNhCuAwfBXNAт̑X[p[Etbs[EfBAŕWIɎgpĂ܂B

+

FAT^Cv(FAT12/FAT16/FAT32)́Ã{[NX^ɂĂ̂݌錈܂[FATdl]ɂȂĂāAȊO̗v͂܂BāAǂFAT^CvɂȂ邩̓{[ETCYƃNX^ETCYɈˑ܂BNX^ETCY͑傫قǐ\オ܂B

+

NX^FAT^Cv̋Eɋ߂ȂƂ́AFR_MKFS_ABORTEDŊ֐s”\܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_USE_MKFS == 1̂Ƃgp”\łB

+
+ + +
+

Q

+

{[Ǘ, f_fdisk

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/mount.html b/3rdparty/fatfs-0.10b/doc/ja/mount.html similarity index 85% rename from src/gfile/fatfs/doc/ja/mount.html rename to 3rdparty/fatfs-0.10b/doc/ja/mount.html index 645a40ed..0a9bc4eb 100644 --- a/src/gfile/fatfs/doc/ja/mount.html +++ b/3rdparty/fatfs-0.10b/doc/ja/mount.html @@ -1,82 +1,82 @@ - - - - - - - - -FatFs - f_mount - - - - -
-

f_mount

-

_hCuɃt@CEVXeEIuWFNgo^E܂B

-
-FRESULT f_mount (
-  FATFS*       fatfs,  /* [IN] t@CEVXeEIuWFNg */
-  const TCHAR* path,   /* [IN] _hCuԍ */
-  BYTE         opt     /* [IN] IvV */
-);
-
-
- -
-

-
-
fatfs
-
o^t@CEVXeEIuWFNgւ̃|C^B
-
path
-
ΏۂƂȂ_hCupXk'\0'I[̕ւ̃|C^w肵܂BhCuԍ܂܂Ȃꍇ́AftHgEhCuw肵ƂɂȂ܂B
-
opt
-
t@CEVXeEIuWFNg̓o^ƓɃ}Egsǂw肷tOBo^̂Ƃ͈Ӗ܂B
-
-
- - - - -
-

-

FatFsW[ł́Aꂼ̘_hCut@CEVXeEIuWFNgƂ[NEGAKvłB̊֐͘_hCuɃt@CEVXeEIuWFNgo^薕肵܂B炩̃t@C֐gpOɁÅ֐ł̘_hCũt@CEVXeEIuWFNg^ĂȂ΂Ȃ܂BfatfsɃkE|C^w肷ƁA̘_hCũt@CEVXeEIuWFNg̓o^͖邾łBo^ꂽt@CEVXeEIuWFNg͉̃ł܂BΏۂ̘_hCuɊJĂt@CfBNgꍇA͑SĖɂȂ܂B̊֐͎̓̂悤ȏɍs܂B

-
    -
  1. Ώۂ̘_hCupath瓾B
  2. -
  3. ɓo^Ăt@CEVXeEIuWFNg̓NAAo^B
  4. -
  5. fatfsLȃ|C^̂Ƃ́Ãt@CEVXeEIuWFNgNAo^B
  6. -
  7. }Eg삪w肳ĂƂ́AsB
  8. -
-

opt0w肷ƁA}Eg(hCȕAFAT{[̌ABPB͂t@CEVXeEIuWFNg)͍sꂸA֐͕hCȕԂɊւ炸ɐ܂B֐ł͉ʃCւ̃ANZX͔Aw肳ꂽt@CEVXeEIuWFNgNA()ÃAhXzɓo^邾łBPɓo^ς݂̃t@CEVXeEIuWFNgNAړIɂg܂BāAă{[ւ̃ANZXsꂽƂ̂ꂩł^̏ꍇ́Aۂ̃}Eg삪s܂B

-
    -
  • t@CEVXeEIuWFNgNA()(f_mount()̎sɂ)
  • -
  • hCu(VXeEZbg⃁fBǍɂ)
  • -
-

opt1w肷ƁAo^ɑă}Eg삪s܂B}EgɎsƑΉG[Ԃ܂Ao^͗LȂ̂ő{[ւ̃ANZXōĂу}Eg삪s܂B

-

ʃC̎チfBǍoT|[gȂ(disk_status()ɔfȂ)Ƃ́AAvP[V̓fBǍケ̊֐Ńt@CEVXeEIuWFNg𖾎IɃNAčă}Egɍs悤ɂKv܂B

-
- - -
-

Ή

-

SĂ̍\Ŏgp”\łB

-
- - -
-

Q

-

f_open, FATFS

-
- -

߂

- - + + + + + + + + +FatFs - f_mount + + + + +
+

f_mount

+

_hCuɃt@CEVXeEIuWFNgo^E܂B

+
+FRESULT f_mount (
+  FATFS*       fs,     /* [IN] t@CEVXeEIuWFNg */
+  const TCHAR* path,   /* [IN] _hCuԍ */
+  BYTE         opt     /* [IN] IvV */
+);
+
+
+ +
+

+
+
fs
+
o^t@CEVXeEIuWFNgւ̃|C^B
+
path
+
ΏۂƂȂ_hCupXk'\0'I[̕ւ̃|C^w肵܂BhCuԍ܂܂Ȃꍇ́AftHgEhCuw肵ƂɂȂ܂B
+
opt
+
t@CEVXeEIuWFNg̓o^ƓɃ}Egsǂw肷tOBo^̂Ƃ͈Ӗ܂B
+
+
+ + + + +
+

+

FatFsW[ł́Aꂼ̘_hCut@CEVXeEIuWFNgƂ[NEGAKvłB̊֐͘_hCuɃt@CEVXeEIuWFNgo^薕肵܂B炩̃t@C֐gpOɁÅ֐ł̘_hCũt@CEVXeEIuWFNg^ĂȂ΂Ȃ܂BfsɃkE|C^w肷ƁA̘_hCũt@CEVXeEIuWFNg̓o^͖邾łBo^ꂽt@CEVXeEIuWFNg͉̃ł܂BΏۂ̘_hCuɊJĂt@CfBNgꍇA͑SĖɂȂ܂B̊֐͎̓̂悤ȏɍs܂B

+
    +
  1. Ώۂ̘_hCupath瓾B
  2. +
  3. ɓo^Ăt@CEVXeEIuWFNg̓NAAo^B
  4. +
  5. fsLȃ|C^̂Ƃ́Ãt@CEVXeEIuWFNgNAo^B
  6. +
  7. }Eg삪w肳ĂƂ́AsB
  8. +
+

opt0w肷ƁA}Eg(hCȕAFAT{[̌ABPB͂t@CEVXeEIuWFNg)͍sꂸA֐͕hCȕԂɊւ炸ɐ܂B֐ł͉ʃCւ̃ANZX͔Aw肳ꂽt@CEVXeEIuWFNgNA()ÃAhXzɓo^邾łBPɓo^ς݂̃t@CEVXeEIuWFNgNAړIɂg܂BāAă{[ւ̃ANZXsꂽƂ̂ꂩł^̏ꍇ́Aۂ̃}Eg삪s܂B

+
    +
  • t@CEVXeEIuWFNgNA()(f_mount()̎sɂ)
  • +
  • hCu(VXeEZbg⃁fBǍɂ)
  • +
+

opt1w肷ƁAo^ɑă}Eg삪s܂B}EgɎsƑΉG[Ԃ܂Ao^͗LȂ̂ő{[ւ̃ANZXōĂу}Eg삪s܂B

+

ʃC̎チfBǍoT|[gȂ(disk_status()ɔfȂ)Ƃ́AAvP[V̓fBǍケ̊֐Ńt@CEVXeEIuWFNg𖾎IɃNAčă}Egɍs悤ɂKv܂B

+
+ + +
+

Ή

+

SĂ̍\Ŏgp”\łB

+
+ + +
+

Q

+

f_open, FATFS

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/open.html b/3rdparty/fatfs-0.10b/doc/ja/open.html similarity index 97% rename from src/gfile/fatfs/doc/ja/open.html rename to 3rdparty/fatfs-0.10b/doc/ja/open.html index a4c4a18d..8ee3b2bc 100644 --- a/src/gfile/fatfs/doc/ja/open.html +++ b/3rdparty/fatfs-0.10b/doc/ja/open.html @@ -1,171 +1,171 @@ - - - - - - - - -FatFs - f_open - - - - -
-

f_open

-

t@CI[v܂͍쐬܂B

-
-FRESULT f_open (
-  FIL* fp,           /* [OUT] ̃t@CEIuWFNg\̂ւ̃|C^ */
-  const TCHAR* path, /* [IN] t@Cւ̃|C^ */
-  BYTE mode          /* [IN] [htO */
-);
-
-
- -
-

-
-
fp
-
V쐬t@CEIuWFNg\̂ւ̃|C^w肵܂Bȍ~Ãt@C‚܂ł̃t@CEIuWFNggpăt@C܂B
-
path
-
Jt@Ct@Ck'\0'I[̕ւ̃|C^w肵܂B
-
mode
-
t@C̃ANZX@I[v@߂tOłB̃p[^ɂ͎̑gݍ킹w肵܂B
- - - - - - - - -
lӖ
FA_READǂݏo[hŊJ܂BǂݏꍇFA_WRITEƋɎw肵܂B
FA_WRITE݃[hŊJ܂BǂݏꍇFA_READƋɎw肵܂B
FA_OPEN_EXISTING̃t@CJ܂Bt@CƂ̓G[ɂȂ܂B(ftHg)
FA_OPEN_ALWAYS̃t@CJ܂Bt@CƂ̓t@C쐬܂BNjL̏ꍇ́A̕@ŃI[vAf_lseek()Ńt@C̍ŌɈړĂB
FA_CREATE_NEWt@C쐬܂B̃t@Cꍇ́AFR_EXISTŎs܂B
FA_CREATE_ALWAYSt@C쐬܂B̃t@Cꍇ́ATCY0ɂĂJ܂B
-
-
-
- - - - - -
-

-

̃t@CJAVt@C쐬܂B֐ƃt@CEIuWFNg쐬Aȍ~̃t@Cɑ΂ANZXɎgp܂Bt@C‚Ƃ́Af_close()gp܂B炩̕ύXsꂽt@Č㐳‚ȂꍇÃt@Cjꍇ܂B

-

ɊJĂt@CJKvꍇ́AdANZXQƂĂBA‚̃t@Cɑ΂鏑݃[h܂ޏdI[v͏ɋ֎~łB

-

t@CEANZXJnOɁAf_mount()gĂꂼ̘_hCuɃ[NEGA(t@CEVXeEIuWFNg)^Kv܂B̏̌A̘_hCuɑ΂đSẴt@C֐g悤ɂȂ܂B

-
- - -
-

Ή

-

SĂ̍\Ŏgp”\łB_FS_READONLY == 1̂Ƃ́AFA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS̊etO̓T|[g܂B

-
- - -
-

gp

-
-/* eLXgt@Cǂݏoĕ\ */
-
-FATFS FatFs;   /* _hCũ[NEGA(t@CEVXeEIuWFNg) */
-
-int main (void)
-{
-    FIL fil;       /* t@CEIuWFNg */
-    char line[82]; /* sobt@ */
-    FRESULT fr;    /* ߂l */
-
-
-    /* ftHgEhCuɃ[NGA^ */
-    f_mount(&FatFs, "", 0);
-
-    /* eLXgEt@CJ */
-    fr = f_open(&fil, "message.txt", FA_READ);
-    if (fr) return (int)fr;
-
-    /* 1s“ǂݏoĕ\ */
-    while (f_gets(line, sizeof line, &fil))
-        printf(line);
-
-    /* t@C‚ */
-    f_close(&fil);
-
-    return 0;
-}
-
-
-/* hCu1̃t@C "file.bin" hCu0փRs[ */
-
-int main (void)
-{
-    FATFS fs[2];         /* _hCũ[NGA(t@CEVXeEIuWFNg) */
-    FIL fsrc, fdst;      /* t@CEIuWFNg */
-    BYTE buffer[4096];   /* File copy buffer */
-    FRESULT fr;          /* FatFs function common result code */
-    UINT br, bw;         /* File R/W count */
-
-    /* hCu0,1Ƀ[NEGA^ */
-    f_mount(&fs[0], "0:", 0);
-    f_mount(&fs[1], "1:", 0);
-
-    /* hCu1̃Rs[t@CJ */
-    res = f_open(&fsrc, "1:file.dat", FA_OPEN_EXISTING | FA_READ);
-    if (fr) return (int)fr;
-
-    /* hCu0ɃRs[t@C쐬 */
-    res = f_open(&fdst, "0:file.dat", FA_CREATE_ALWAYS | FA_WRITE);
-    if (fr) return (int)fr;
-
-    /* Rs[Rs[Ƀf[^] */
-    for (;;) {
-        res = f_read(&fsrc, buffer, sizeof buffer, &br); /* Rs[炩ǂݏo */
-        if (res || br == 0) break;   /* G[t@CI[ */
-        res = f_write(&fdst, buffer, br, &bw);           /* Rs[ɏ */
-        if (res || bw < br) break;   /* G[fBXNt */
-    }
-
-    /* SẴt@C‚ */
-    f_close(&fsrc);
-    f_close(&fdst);
-
-    /* [NEGAJ */
-    f_mount(NULL, "0:", 0);
-    f_mount(NULL, "1:", 0);
-
-    return (int)fr;
-}
-
-
- - - - -

߂

- - + + + + + + + + +FatFs - f_open + + + + +
+

f_open

+

t@CI[v܂͍쐬܂B

+
+FRESULT f_open (
+  FIL* fp,           /* [OUT] ̃t@CEIuWFNg\̂ւ̃|C^ */
+  const TCHAR* path, /* [IN] t@Cւ̃|C^ */
+  BYTE mode          /* [IN] [htO */
+);
+
+
+ +
+

+
+
fp
+
V쐬t@CEIuWFNg\̂ւ̃|C^w肵܂Bȍ~Ãt@C‚܂ł̃t@CEIuWFNggpăt@C܂B
+
path
+
Jt@Ct@Ck'\0'I[̕ւ̃|C^w肵܂B
+
mode
+
t@C̃ANZX@I[v@߂tOłB̃p[^ɂ͎̑gݍ킹w肵܂B
+ + + + + + + + +
lӖ
FA_READǂݏo[hŊJ܂BǂݏꍇFA_WRITEƋɎw肵܂B
FA_WRITE݃[hŊJ܂BǂݏꍇFA_READƋɎw肵܂B
FA_OPEN_EXISTING̃t@CJ܂Bt@CƂ̓G[ɂȂ܂B(ftHg)
FA_OPEN_ALWAYS̃t@CJ܂Bt@CƂ̓t@C쐬܂BNjL̏ꍇ́A̕@ŃI[vAf_lseek()Ńt@C̍ŌɈړĂB
FA_CREATE_NEWt@C쐬܂B̃t@Cꍇ́AFR_EXISTŎs܂B
FA_CREATE_ALWAYSt@C쐬܂B̃t@Cꍇ́ATCY0ɂĂJ܂B
+
+
+
+ + + + + +
+

+

̃t@CJAVt@C쐬܂B֐ƃt@CEIuWFNg쐬Aȍ~̃t@Cɑ΂ANZXɎgp܂Bt@C‚Ƃ́Af_close()gp܂B炩̕ύXsꂽt@Č㐳‚ȂꍇÃt@Cjꍇ܂B

+

ɊJĂt@CJKvꍇ́AdANZXQƂĂBA‚̃t@Cɑ΂鏑݃[h܂ޏdI[v͏ɋ֎~łB

+

t@CEANZXJnOɁAf_mount()gĂꂼ̘_hCuɃ[NEGA(t@CEVXeEIuWFNg)^Kv܂B̏̌A̘_hCuɑ΂đSẴt@C֐g悤ɂȂ܂B

+
+ + +
+

Ή

+

SĂ̍\Ŏgp”\łB_FS_READONLY == 1̂Ƃ́AFA_WRITE, FA_CREATE_ALWAYS, FA_CREATE_NEW, FA_OPEN_ALWAYS̊etO̓T|[g܂B

+
+ + +
+

gp

+
+/* eLXgt@Cǂݏoĕ\ */
+
+FATFS FatFs;   /* _hCũ[NEGA(t@CEVXeEIuWFNg) */
+
+int main (void)
+{
+    FIL fil;       /* t@CEIuWFNg */
+    char line[82]; /* sobt@ */
+    FRESULT fr;    /* ߂l */
+
+
+    /* ftHgEhCuɃ[NGA^ */
+    f_mount(&FatFs, "", 0);
+
+    /* eLXgEt@CJ */
+    fr = f_open(&fil, "message.txt", FA_READ);
+    if (fr) return (int)fr;
+
+    /* 1s“ǂݏoĕ\ */
+    while (f_gets(line, sizeof line, &fil))
+        printf(line);
+
+    /* t@C‚ */
+    f_close(&fil);
+
+    return 0;
+}
+
+
+/* hCu1̃t@C "file.bin" hCu0փRs[ */
+
+int main (void)
+{
+    FATFS fs[2];         /* _hCũ[NGA(t@CEVXeEIuWFNg) */
+    FIL fsrc, fdst;      /* t@CEIuWFNg */
+    BYTE buffer[4096];   /* File copy buffer */
+    FRESULT fr;          /* FatFs function common result code */
+    UINT br, bw;         /* File R/W count */
+
+    /* hCu0,1Ƀ[NEGA^ */
+    f_mount(&fs[0], "0:", 0);
+    f_mount(&fs[1], "1:", 0);
+
+    /* hCu1̃Rs[t@CJ */
+    res = f_open(&fsrc, "1:file.dat", FA_OPEN_EXISTING | FA_READ);
+    if (fr) return (int)fr;
+
+    /* hCu0ɃRs[t@C쐬 */
+    res = f_open(&fdst, "0:file.dat", FA_CREATE_ALWAYS | FA_WRITE);
+    if (fr) return (int)fr;
+
+    /* Rs[Rs[Ƀf[^] */
+    for (;;) {
+        res = f_read(&fsrc, buffer, sizeof buffer, &br); /* Rs[炩ǂݏo */
+        if (res || br == 0) break;   /* G[t@CI[ */
+        res = f_write(&fdst, buffer, br, &bw);           /* Rs[ɏ */
+        if (res || bw < br) break;   /* G[fBXNt */
+    }
+
+    /* SẴt@C‚ */
+    f_close(&fsrc);
+    f_close(&fdst);
+
+    /* [NEGAJ */
+    f_mount(NULL, "0:", 0);
+    f_mount(NULL, "1:", 0);
+
+    return (int)fr;
+}
+
+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/opendir.html b/3rdparty/fatfs-0.10b/doc/ja/opendir.html similarity index 96% rename from src/gfile/fatfs/doc/ja/opendir.html rename to 3rdparty/fatfs-0.10b/doc/ja/opendir.html index 93091605..88aa62ea 100644 --- a/src/gfile/fatfs/doc/ja/opendir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/opendir.html @@ -1,76 +1,76 @@ - - - - - - - - -FatFs - f_opendir - - - - -
-

f_opendir

-

fBNgJ܂B

-
-FRESULT f_opendir (
-  DIR* dp,           /* [OUT] fBNgEuWFNg\̂ւ̃|C^ */
-  const TCHAR* path  /* [IN] fBNgւ̃|C^ */
-);
-
-
- -
-

-
-
dp
-
̃fBNgEIuWFNg\̂ւ̃|C^w肵܂B
-
path
-
I[vfBNgpXk'\0'I[̕ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

fBNgJ܂BIA쐬ꂽDIR\̂gẴfBNg̍ڂǂݏo܂B

-
- - -
-

Ή

-

_FS_MINIMIZE <= 1̂Ƃgp”\ɂȂ܂B

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_opendir + + + + +
+

f_opendir

+

fBNgJ܂B

+
+FRESULT f_opendir (
+  DIR* dp,           /* [OUT] fBNgEuWFNg\̂ւ̃|C^ */
+  const TCHAR* path  /* [IN] fBNgւ̃|C^ */
+);
+
+
+ +
+

+
+
dp
+
̃fBNgEIuWFNg\̂ւ̃|C^w肵܂B
+
path
+
I[vfBNgpXk'\0'I[̕ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

fBNgJ܂BIA쐬ꂽDIR\̂gẴfBNg̍ڂǂݏo܂B

+
+ + +
+

Ή

+

_FS_MINIMIZE <= 1̂Ƃgp”\ɂȂ܂B

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/printf.html b/3rdparty/fatfs-0.10b/doc/ja/printf.html similarity index 88% rename from src/gfile/fatfs/doc/ja/printf.html rename to 3rdparty/fatfs-0.10b/doc/ja/printf.html index 12bc9c55..0250f657 100644 --- a/src/gfile/fatfs/doc/ja/printf.html +++ b/3rdparty/fatfs-0.10b/doc/ja/printf.html @@ -1,93 +1,93 @@ - - - - - - - - -FatFs - f_printf - - - - -
-

f_printf

-

t@Cɏ݂܂B

-
-int f_printf (
-  FIL* fp,           /* [IN] t@CEIuWFNg */
-  const TCHAR* fmt,  /* [IN] 䕶 */
-  ...
-);
-
-
- -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
fmt
-
k'\0'I[̏䕶w|C^w肵܂Bk͏܂܂B
-
...
-
IvV̈B
- -
-
- - -
-

߂l

-

񂪐ɏ܂ƁA܂ꂽԂ܂BfBXNt܂͂̑G[ɂ萳ɏ܂ȂƂ́A֐͎sEOF (-1)Ԃ܂B

-
- - -
-

-

̊֐́Af_putc()f_puts()̃bp[֐łB@\CWCũTuZbgƂȂĂāA䕶͎Ɏ̂gp”\łB

-
    -
  • ^Cv: c C s S d D u U x X b B
  • -
  • xw: l L
  • -
  • tO: 0 -
  • -
-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_USE_STRFUNC 1܂ 2̂Ƃgp”\ɂȂ܂B2̎́Ao͂Ɋ܂܂'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

-

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AfmtUnicodeɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

-
- - -
-

gp

-
-    f_printf(&fil, "%d", 1234);            /* "1234" */
-    f_printf(&fil, "%6d,%3d%%", -200, 5);  /* "  -200,  5%" */
-    f_printf(&fil, "%ld", 12345L);         /* "12345" */
-    f_printf(&fil, "%06d", 25);            /* "000025" */
-    f_printf(&fil, "%06d", -25);           /* "000-25" */
-    f_printf(&fil, "%-6d", 25);            /* "25    " */
-    f_printf(&fil, "%u", -1);              /* "65535" or "4294967295" */
-    f_printf(&fil, "%04x", 0xAB3);         /* "0ab3" */
-    f_printf(&fil, "%08LX", 0x123ABCL);    /* "00123ABC" */
-    f_printf(&fil, "%016b", 0x550F);       /* "0101010100001111" */
-    f_printf(&fil, "%s", "String");        /* "String" */
-    f_printf(&fil, "%8s", "abc");          /* "     abc" */
-    f_printf(&fil, "%-8s", "abc");         /* "abc     " */
-    f_printf(&fil, "%c", 'a');             /* "a" */
-    f_printf(&fil, "%f", 10.0);            /* _͖T|[g */
-
-
- - - - -

߂

- - + + + + + + + + +FatFs - f_printf + + + + +
+

f_printf

+

t@Cɏ݂܂B

+
+int f_printf (
+  FIL* fp,           /* [IN] t@CEIuWFNg */
+  const TCHAR* fmt,  /* [IN] 䕶 */
+  ...
+);
+
+
+ +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
fmt
+
k'\0'I[̏䕶w|C^w肵܂Bk͏܂܂B
+
...
+
IvV̈B
+ +
+
+ + +
+

߂l

+

񂪐ɏ܂ƁA܂ꂽԂ܂BfBXNt܂͂̑G[ɂ萳ɏ܂ȂƂ́A֐͎sEOF (-1)Ԃ܂B

+
+ + +
+

+

̊֐́Af_putc()f_puts()̃bp[֐łB@\CWCũTuZbgƂȂĂāA䕶͎Ɏ̂gp”\łB

+
    +
  • ^Cv: c C s S d D u U x X b B
  • +
  • xw: l L
  • +
  • tO: 0 -
  • +
+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_USE_STRFUNC1܂2̂Ƃgp”\ɂȂ܂B2̎́Ao͂Ɋ܂܂'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

+

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AfmtUnicodeɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

+
+ + +
+

gp

+
+    f_printf(&fil, "%d", 1234);            /* "1234" */
+    f_printf(&fil, "%6d,%3d%%", -200, 5);  /* "  -200,  5%" */
+    f_printf(&fil, "%ld", 12345L);         /* "12345" */
+    f_printf(&fil, "%06d", 25);            /* "000025" */
+    f_printf(&fil, "%06d", -25);           /* "000-25" */
+    f_printf(&fil, "%-6d", 25);            /* "25    " */
+    f_printf(&fil, "%u", -1);              /* "65535" or "4294967295" */
+    f_printf(&fil, "%04x", 0xAB3);         /* "0ab3" */
+    f_printf(&fil, "%08LX", 0x123ABCL);    /* "00123ABC" */
+    f_printf(&fil, "%016b", 0x550F);       /* "0101010100001111" */
+    f_printf(&fil, "%s", "String");        /* "String" */
+    f_printf(&fil, "%8s", "abc");          /* "     abc" */
+    f_printf(&fil, "%-8s", "abc");         /* "abc     " */
+    f_printf(&fil, "%c", 'a');             /* "a" */
+    f_printf(&fil, "%f", 10.0);            /* _͖T|[g */
+
+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/putc.html b/3rdparty/fatfs-0.10b/doc/ja/putc.html similarity index 97% rename from src/gfile/fatfs/doc/ja/putc.html rename to 3rdparty/fatfs-0.10b/doc/ja/putc.html index 724f4c2e..d9e2a374 100644 --- a/src/gfile/fatfs/doc/ja/putc.html +++ b/3rdparty/fatfs-0.10b/doc/ja/putc.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_putc - - - - -
-

f_putc

-

t@Cɕ݂܂B

-
-int f_putc (
-  TCHAR chr,  /* [IN] ޕ */
-  FIL* fp     /* [IN] t@CEIuWFNg */
-);
-
-
- -
-

-
-
chr
-
ޕw肵܂B
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

ɏ܂Ə񂾕Ԃ܂BfBXNt܂̓G[ɂ菑܂ȂƂEOF (-1)Ԃ܂B

-

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AchrUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

-
- - -
-

-

1t@Cɏ݂܂B̊֐f_write()̃bp[֐łB

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_USE_STRFUNC 1܂ 2̂Ƃgp”\łB2w肷ƁA'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_putc + + + + +
+

f_putc

+

t@Cɕ݂܂B

+
+int f_putc (
+  TCHAR chr,  /* [IN] ޕ */
+  FIL* fp     /* [IN] t@CEIuWFNg */
+);
+
+
+ +
+

+
+
chr
+
ޕw肵܂B
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

ɏ܂Ə񂾕Ԃ܂BfBXNt܂̓G[ɂ菑܂ȂƂEOF (-1)Ԃ܂B

+

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AchrUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

+
+ + +
+

+

1t@Cɏ݂܂B̊֐f_write()̃bp[֐łB

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_USE_STRFUNC 1܂ 2̂Ƃgp”\łB2w肷ƁA'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/puts.html b/3rdparty/fatfs-0.10b/doc/ja/puts.html similarity index 81% rename from src/gfile/fatfs/doc/ja/puts.html rename to 3rdparty/fatfs-0.10b/doc/ja/puts.html index ea768a43..6f5c463c 100644 --- a/src/gfile/fatfs/doc/ja/puts.html +++ b/3rdparty/fatfs-0.10b/doc/ja/puts.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_puts - - - - -
-

f_puts

-

t@Cɕ݂܂B

-
-int f_puts (
-  const TCHAR* str,  /* [IN] ޕ */
-  FIL* fp            /* [IN] t@CEIuWFNg */
-);
-
-
- -
-

-
-
str
-
ރk'\0'I[̕w|C^w肵܂Bk͏܂܂B
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

񂪐ɏ܂ƁA܂ꂽԂ܂BfBXNt܂̓G[ɂ菑݂fꂽƂEOF (-1)Ԃ܂B

-

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AstrUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

-
- - -
-

-

t@Cɏ݂܂B̊֐f_write()̃bp[֐łB

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_USE_STRFUNC 1܂ 2̂Ƃgp”\łB2w肷ƁAɊ܂܂'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_puts + + + + +
+

f_puts

+

t@Cɕ݂܂B

+
+int f_puts (
+  const TCHAR* str,  /* [IN] ޕ */
+  FIL* fp            /* [IN] t@CEIuWFNg */
+);
+
+
+ +
+

+
+
str
+
ރk'\0'I[̕w|C^w肵܂Bk͏܂܂B
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

񂪐ɏ܂ƁA܂ꂽԂ܂BfBXNt܂̓G[ɂ菑݂fꂽƂEOF (-1)Ԃ܂B

+

APIUnicodeI(_LFN_UNICODE1)ĂƂ́AstrUTF-16ɂȂ܂At@C̃GR[h́A_STRF_ENCODEIvVőIł܂BȊO͖̎ϊ(1oCg/1)ŏ݂܂B

+
+ + +
+

+

t@Cɏ݂܂B̊֐f_write()̃bp[֐łB

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_USE_STRFUNC1܂2̂Ƃgp”\łB2w肷ƁAɊ܂܂'\n''\r'+'\n'ɓWJăt@Cɏ܂܂B

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/rc.html b/3rdparty/fatfs-0.10b/doc/ja/rc.html similarity index 98% rename from src/gfile/fatfs/doc/ja/rc.html rename to 3rdparty/fatfs-0.10b/doc/ja/rc.html index 8bcfb247..1f1140f9 100644 --- a/src/gfile/fatfs/doc/ja/rc.html +++ b/3rdparty/fatfs-0.10b/doc/ja/rc.html @@ -1,85 +1,85 @@ - - - - - - - - -FatFs - 戻り値 - - - -

ファイル関数の戻り値

-

FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト・コード(FRESULT型(enum))を返します。関数が成功した場合は0を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。

- -
-
FR_OK (0)
-
関数は成功した。
-
FR_DISK_ERR
-
下位レイヤ(disk_read(), disk_write(), disk_ioctl()関数)で回復不能なエラーが発生した。
※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外のの操作ができなくなります。
-
FR_INT_ERR
-
内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。 -
    -
  • ボリューム上のFAT構造にエラーがある。
  • -
  • スタック不足や不正なメモリ操作等によるワーク・エリアの破壊。多くはこれが原因。
  • -
-※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。
-
FR_NOT_READY
-
物理ドライブが動作可能な状態にない。または、ドライブの初期化に失敗した。
-
FR_NO_FILE
-
指定されたファイルが見つからなかった。
-
FR_NO_PATH
-
指定されたパスが見つからなかった。
-
FR_INVALID_NAME
-
指定された文字列がパス名のフォーマットとして無効。
-
FR_DENIED
-
そのオブジェクトに対する操作の拒否。原因としては次のようなことが考えられます。 -
    -
  • 書き込み禁止属性(AM_RDO)を持つファイルを書き込みモードで開こうとした。
  • -
  • 書き込み禁止属性を持つファイルやディレクトリを削除しようとした。
  • -
  • 空でないディレクトリまたはカレント・ディレクトリを削除しようとした。
  • -
  • FA_READフラグを付けずに開いたファイルに対して読み出しを行った。
  • -
  • FA_WRITEフラグを付けずに開いたファイルに対して書き込みまたはそれに類する操作を行った。
  • -
  • ボリュームまたはディレクトリ・テーブルが満杯でファイルやディレクトリを作成できなかった。
  • -
-
-
FR_EXIST
-
新しく作成しようとしたオブジェクトと同じ名前のオブジェクトが既に存在する。
-
FR_INVALID_OBJECT
-
指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効(オープンされていない、既に閉じられた、破損しているなど)、またはヌル・ポインタが渡された。また、開かれたままのオブジェクトは、それの属するボリュームのマウント動作により無効となります。
-
FR_WRITE_PROTECTED
-
物理ドライブが書き込み禁止状態のとき、書き込みを伴う操作を行おうとした。
-
FR_INVALID_DRIVE
-
パス名中に指定されたドライブ番号が無効、またはパス名にヌル・ポインタが渡された。(関連オプション: _VOLUMES)
-
FR_NOT_ENABLED
-
そのボリュームの操作に必要なワーク・エリア(ファイル・システム・オブジェクト構造体)が与えられていない。
-
FR_NO_FILESYSTEM
-
物理ドライブ上に有効なFATボリュームが見つからなかった。
-
FR_MKFS_ABORTED
-
f_mkfs()の処理が開始前に中断された。原因としては次のようなことが考えられます。 -
    -
  • ボリュームが小さすぎる。
  • -
  • FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。
  • -
  • その論理ドライブに対応する区画が見つからなかった。(関連オプション: _MULTI_PARTITION)
  • -
-
-
FR_TIMEOUT
-
再入制御による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: _TIMEOUT)
-
FR_LOCKED
-
多重アクセス排他機能により、そのファイルやディレクトリに対して行おうとしたアクセスが拒否された。(関連オプション: _FS_LOCK)
-
FR_NOT_ENOUGH_CORE
-
メモリ不足による失敗。原因としては次のようなことが考えられます。 -
    -
  • LFN操作バッファの動的確保に失敗した。(関連オプション: _USE_LFN)
  • -
  • 与えられた配列のサイズが実際に必要なサイズに対して不足している。
  • -
-
-
FR_TOO_MANY_OPEN_FILES
-
同時オープン可能なファイル数を越えてファイルを開こうとした。(関連オプション: _FS_LOCK)
-
FR_INVALID_PARAMETER
-
与えられたパラメータが無効または矛盾している。
-
- - - + + + + + + + + +FatFs - 戻り値 + + + +

ファイル関数の戻り値

+

FatFsのAPIでは、一部の関数を除き結果に応じた共通のリザルト・コード(FRESULT型(enum))を返します。関数が成功した場合は0を返します。失敗した場合は0以外の値を返し、値はエラーの種類を示します。

+ +
+
FR_OK (0)
+
関数は成功した。
+
FR_DISK_ERR
+
下位レイヤ(disk_read(), disk_write(), disk_ioctl()関数)で回復不能なエラーが発生した。
※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外のの操作ができなくなります。
+
FR_INT_ERR
+
内部処理の健全性に異常が検出された。原因としては次のようなことが考えられます。 +
    +
  • ボリューム上のFAT構造にエラーがある。
  • +
  • スタック不足や不正なメモリ操作等によるワーク・エリアの破壊。多くはこれが原因。
  • +
+※開かれたファイルの操作においてこのエラーが発生すると、そのファイル・オブジェクトはアボート状態となり、クローズ以外の操作ができなくなります。
+
FR_NOT_READY
+
物理ドライブが動作可能な状態にない。または、ドライブの初期化に失敗した。
+
FR_NO_FILE
+
指定されたファイルが見つからなかった。
+
FR_NO_PATH
+
指定されたパスが見つからなかった。
+
FR_INVALID_NAME
+
指定された文字列がパス名のフォーマットとして無効。
+
FR_DENIED
+
そのオブジェクトに対する操作の拒否。原因としては次のようなことが考えられます。 +
    +
  • 書き込み禁止属性(AM_RDO)を持つファイルを書き込みモードで開こうとした。
  • +
  • 書き込み禁止属性を持つファイルやディレクトリを削除しようとした。
  • +
  • 空でないディレクトリまたはカレント・ディレクトリを削除しようとした。
  • +
  • FA_READフラグを付けずに開いたファイルに対して読み出しを行った。
  • +
  • FA_WRITEフラグを付けずに開いたファイルに対して書き込みまたはそれに類する操作を行った。
  • +
  • ボリュームまたはディレクトリ・テーブルが満杯でファイルやディレクトリを作成できなかった。
  • +
+
+
FR_EXIST
+
新しく作成しようとしたオブジェクトと同じ名前のオブジェクトが既に存在する。
+
FR_INVALID_OBJECT
+
指定されたファイル・オブジェクトやディレクトリ・オブジェクトが無効(オープンされていない、既に閉じられた、破損しているなど)、またはヌル・ポインタが渡された。また、開かれたままのオブジェクトは、それの属するボリュームのマウント動作により無効となります。
+
FR_WRITE_PROTECTED
+
物理ドライブが書き込み禁止状態のとき、書き込みを伴う操作を行おうとした。
+
FR_INVALID_DRIVE
+
パス名中に指定されたドライブ番号が無効、またはパス名にヌル・ポインタが渡された。(関連オプション: _VOLUMES)
+
FR_NOT_ENABLED
+
そのボリュームの操作に必要なワーク・エリア(ファイル・システム・オブジェクト構造体)が与えられていない。
+
FR_NO_FILESYSTEM
+
物理ドライブ上に有効なFATボリュームが見つからなかった。
+
FR_MKFS_ABORTED
+
f_mkfs()の処理が開始前に中断された。原因としては次のようなことが考えられます。 +
    +
  • ボリュームが小さすぎる。
  • +
  • FATタイプの計算に矛盾が見つかった。クラスタ数がFATタイプの境界付近になるときに発生する場合があります。
  • +
  • その論理ドライブに対応する区画が見つからなかった。(関連オプション: _MULTI_PARTITION)
  • +
+
+
FR_TIMEOUT
+
再入制御による待ち時間が定義された時間を越えたため、関数は実行されなかった。(関連オプション: _TIMEOUT)
+
FR_LOCKED
+
多重アクセス排他機能により、そのファイルやディレクトリに対して行おうとしたアクセスが拒否された。(関連オプション: _FS_LOCK)
+
FR_NOT_ENOUGH_CORE
+
メモリ不足による失敗。原因としては次のようなことが考えられます。 +
    +
  • LFN操作バッファの動的確保に失敗した。(関連オプション: _USE_LFN)
  • +
  • 与えられた配列のサイズが実際に必要なサイズに対して不足している。
  • +
+
+
FR_TOO_MANY_OPEN_FILES
+
同時オープン可能なファイル数を越えてファイルを開こうとした。(関連オプション: _FS_LOCK)
+
FR_INVALID_PARAMETER
+
与えられたパラメータが無効または矛盾している。
+
+ + + diff --git a/src/gfile/fatfs/doc/ja/read.html b/3rdparty/fatfs-0.10b/doc/ja/read.html similarity index 97% rename from src/gfile/fatfs/doc/ja/read.html rename to 3rdparty/fatfs-0.10b/doc/ja/read.html index 04ef8b30..94b8d1e3 100644 --- a/src/gfile/fatfs/doc/ja/read.html +++ b/3rdparty/fatfs-0.10b/doc/ja/read.html @@ -1,75 +1,75 @@ - - - - - - - - -FatFs - f_read - - - - -
-

f_read

-

t@Cf[^ǂݏo܂B

-
-FRESULT f_read (
-  FIL* fp,     /* [IN] t@CEIuWFNg\ */
-  void* buff,  /* [OUT] ǂݏof[^i[obt@ */
-  UINT btr,    /* [IN] ǂݏooCg */
-  UINT* br     /* [OUT] ǂݏoꂽoCg */
-);
-
-
- -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
buff
-
ǂݏof[^i[obt@w|C^w肵܂B
-
btr
-
ǂݏooCg(0`UINT^̍ől)w肵܂B
-
br
-
ۂɓǂݏoꂽoCgi[ϐw|C^w肵܂B߂l͊֐̐ۂɂ炸ɗLłB
-
-
- - - - - -
-

-

ǂݍ݊JnʒúÃ݂[h/CgE|C^ɂȂ܂B[h/CgE|C^͓ǂݍ܂ꂽoCgi݂܂B֐ÍA*br̒l`FbNׂłB*brbtrƂ́AǂݍݒɃt@C̏I[ɒBƂĂ܂B

-
- - -
-

Ή

-

SĂ̍\Ŏgp”\łB

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_read + + + + +
+

f_read

+

t@Cf[^ǂݏo܂B

+
+FRESULT f_read (
+  FIL* fp,     /* [IN] t@CEIuWFNg\ */
+  void* buff,  /* [OUT] ǂݏof[^i[obt@ */
+  UINT btr,    /* [IN] ǂݏooCg */
+  UINT* br     /* [OUT] ǂݏoꂽoCg */
+);
+
+
+ +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
buff
+
ǂݏof[^i[obt@w|C^w肵܂B
+
btr
+
ǂݏooCg(0`UINT^̍ől)w肵܂B
+
br
+
ۂɓǂݏoꂽoCgi[ϐw|C^w肵܂B߂l͊֐̐ۂɂ炸ɗLłB
+
+
+ + + + + +
+

+

ǂݍ݊JnʒúÃ݂[h/CgE|C^ɂȂ܂B[h/CgE|C^͓ǂݍ܂ꂽoCgi݂܂B֐ÍA*br̒l`FbNׂłB*brbtrƂ́AǂݍݒɃt@C̏I[ɒBƂĂ܂B

+
+ + +
+

Ή

+

SĂ̍\Ŏgp”\łB

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/readdir.html b/3rdparty/fatfs-0.10b/doc/ja/readdir.html similarity index 96% rename from src/gfile/fatfs/doc/ja/readdir.html rename to 3rdparty/fatfs-0.10b/doc/ja/readdir.html index db6bed66..d516b355 100644 --- a/src/gfile/fatfs/doc/ja/readdir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/readdir.html @@ -1,126 +1,126 @@ - - - - - - - - -FatFs - f_readdir - - - - -
-

f_readdir

-

fBNgڂǂݏo܂

-
-FRESULT f_readdir (
-  DIR* dp,      /* [IN] fBNgEuWFNg\̂ւ̃|C^ */
-  FILINFO* fno  /* [OUT] t@C\̂ւ̃|C^ */
-);
-
-
- -
-

-
-
dp
-
LȃfBNgEIuWFNg\̂ւ̃|C^w肵܂B
-
fno
-
ǂݏofBNgڂi[t@C\̂ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

fBNg̍(t@CƃfBNg)ǂݏo܂B̊֐JԂs邱Ƃɂ肻̃fBNg̑SĂ̍ڂǂݏoƂł܂Bt@C̏ڍׂɂ‚Ă FILINFO\̂QƂĂBSĂ̍ڂǂݏoAǂݏoڂƂ́Afname[]oɃk񂪕Ԃ܂BfnoɃkE|C^w肷ƁÃfBNg̃[hECfbNX擪Ɋ߂܂B܂Å֐͎Ɏ悤Ɋ֘A\IvVɂ蓮삪ς܂B

-

hbgEGg("."A"..")́A΃pXLȂƂ(_FS_RPATH >= 1)ɂ̂ݏo͂Ɍ܂B

-

LFN@\LȎ́Å֐̌Ăяoɐ旧FILINFOlfnamelfsizeLȒlŏĂȂ΂Ȃ܂BlfnameLFNi[obt@ŁAlfsize͂̃obt@̗vfłBLFNǂݏoKvȂƂ́AlfnameɃkE|C^ZbgĂB̏Ɉ‚łYꍇ́ALFNi[obt@Ƀk񂪕Ԃ܂B

-
    -
  • fBNgڂLFN񂪑݂ȂB
  • -
  • LFN̒ɑ΂LFNi[obt@܂LFNobt@̃TCYs\B
  • -
  • LFNɌ݂OEMR[hɑ݂Ȃ܂܂ĂB(Unicode\̂Ƃ)
  • -
-

܂AfBNgڂLFN񂪑݂Ȃꍇ́Afname[]ɉp܂܂ꍇ܂B

-
- - -
-

Ή

-

_FS_MINIMIZE <= 1̂ƂɎgp”\łB

-
- - -
-

gp

-
-FRESULT scan_files (
-    char* path        /* Jnm[h ([NGAƂĂgp) */
-)
-{
-    FRESULT res;
-    FILINFO fno;
-    DIR dir;
-    int i;
-    char *fn;   /* Unicode\z */
-#if _USE_LFN
-    static char lfn[_MAX_LFN + 1];
-    fno.lfname = lfn;
-    fno.lfsize = sizeof lfn;
-#endif
-
-
-    res = f_opendir(&dir, path);                       /* fBNgJ */
-    if (res == FR_OK) {
-        i = strlen(path);
-        for (;;) {
-            res = f_readdir(&dir, &fno);                   /* fBNgڂ1“ǂݏo */
-            if (res != FR_OK || fno.fname[0] == 0) break;  /* G[܂͍ږ̂Ƃ͔ */
-            if (fno.fname[0] == '.') continue;             /* hbgGg͖ */
-#if _USE_LFN
-            fn = *fno.lfname ? fno.lfname : fno.fname;
-#else
-            fn = fno.fname;
-#endif
-            if (fno.fattrib & AM_DIR) {                    /* fBNg */
-                sprintf(&path[i], "/%s", fn);
-                res = scan_files(path);
-                if (res != FR_OK) break;
-                path[i] = 0;
-            } else {                                       /* t@C */
-                printf("%s/%s\n", path, fn);
-            }
-        }
-        f_closedir(&dir);
-    }
-
-    return res;
-}
-
-
- - - - -

߂

- - + + + + + + + + +FatFs - f_readdir + + + + +
+

f_readdir

+

fBNgڂǂݏo܂B

+
+FRESULT f_readdir (
+  DIR* dp,      /* [IN] fBNgEuWFNg\̂ւ̃|C^ */
+  FILINFO* fno  /* [OUT] t@C\̂ւ̃|C^ */
+);
+
+
+ +
+

+
+
dp
+
LȃfBNgEIuWFNg\̂ւ̃|C^w肵܂B
+
fno
+
ǂݏofBNgڂi[t@C\̂ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

fBNg̍(t@CƃfBNg)ǂݏo܂B̊֐JԂs邱Ƃɂ肻̃fBNg̑SĂ̍ڂǂݏoƂł܂Bt@C̏ڍׂɂ‚Ă FILINFO\̂QƂĂBSĂ̍ڂǂݏoAǂݏoڂƂ́Afname[]oɃk񂪕Ԃ܂BfnoɃkE|C^w肷ƁÃfBNg̃[hECfbNX擪Ɋ߂܂B܂Å֐͎Ɏ悤Ɋ֘A\IvVɂ蓮삪ς܂B

+

hbgEGg("."A"..")́A΃pXLȂƂ(_FS_RPATH >= 1)ɂ̂ݏo͂Ɍ܂B

+

LFN@\LȎ́Å֐̌Ăяoɐ旧FILINFOlfnamelfsizeLȒlŏĂȂ΂Ȃ܂BlfnameLFNi[obt@ŁAlfsize͂̃obt@̗vfłBLFNǂݏoKvȂƂ́AlfnameɃkE|C^ZbgĂB̏Ɉ‚łYꍇ́ALFNi[obt@Ƀk񂪕Ԃ܂B

+
    +
  • fBNgڂLFN񂪑݂ȂB
  • +
  • LFN̒ɑ΂LFNi[obt@܂LFNobt@̃TCYs\B
  • +
  • LFNɌ݂OEMR[hɑ݂Ȃ܂܂ĂB(Unicode\̂Ƃ)
  • +
+

܂AfBNgڂLFN񂪑݂Ȃꍇ́Afname[]ɉp܂܂ꍇ܂B

+
+ + +
+

Ή

+

_FS_MINIMIZE <= 1̂ƂɎgp”\łB

+
+ + +
+

gp

+
+FRESULT scan_files (
+    char* path        /* Jnm[h ([NGAƂĂgp) */
+)
+{
+    FRESULT res;
+    FILINFO fno;
+    DIR dir;
+    int i;
+    char *fn;   /* Unicode\z */
+#if _USE_LFN
+    static char lfn[_MAX_LFN + 1];
+    fno.lfname = lfn;
+    fno.lfsize = sizeof lfn;
+#endif
+
+
+    res = f_opendir(&dir, path);                       /* fBNgJ */
+    if (res == FR_OK) {
+        i = strlen(path);
+        for (;;) {
+            res = f_readdir(&dir, &fno);                   /* fBNgڂ1“ǂݏo */
+            if (res != FR_OK || fno.fname[0] == 0) break;  /* G[܂͍ږ̂Ƃ͔ */
+            if (fno.fname[0] == '.') continue;             /* hbgGg͖ */
+#if _USE_LFN
+            fn = *fno.lfname ? fno.lfname : fno.fname;
+#else
+            fn = fno.fname;
+#endif
+            if (fno.fattrib & AM_DIR) {                    /* fBNg */
+                sprintf(&path[i], "/%s", fn);
+                res = scan_files(path);
+                if (res != FR_OK) break;
+                path[i] = 0;
+            } else {                                       /* t@C */
+                printf("%s/%s\n", path, fn);
+            }
+        }
+        f_closedir(&dir);
+    }
+
+    return res;
+}
+
+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/rename.html b/3rdparty/fatfs-0.10b/doc/ja/rename.html similarity index 94% rename from src/gfile/fatfs/doc/ja/rename.html rename to 3rdparty/fatfs-0.10b/doc/ja/rename.html index 03e3aff4..54d1762e 100644 --- a/src/gfile/fatfs/doc/ja/rename.html +++ b/3rdparty/fatfs-0.10b/doc/ja/rename.html @@ -1,82 +1,82 @@ - - - - - - - - -FatFs - f_rename - - - - -
-

f_rename

-

t@C܂̓TuEfBNg̖O̕ύX܂͈ړB

-
-FRESULT f_rename (
-  const TCHAR* old_name, /* [IN] ÂIuWFNg */
-  const TCHAR* new_name  /* [IN] VIuWFNg */
-);
-
-
- -
-

-
-
old_name
-
ύXΏۂ̃t@C܂̓TuEfBNgpXk'\0'I[̕ւ̃|C^w肵܂B
-
new_name
-
VpXk'\0'I[̕ւ̃|C^w肵܂Bɑ݂IuWFNgƓO͎g܂B܂AhCuԍ͎w肵ĂAold_nameŌ߂ꂽ_hCũIuWFNgƂĈ܂B
-
-
- - - - - -
-

-

t@C܂̓TuEfBNg̖OύX܂B܂Aɕʂ̃fBNgւ̈ړ”\łAقȂhCuւ̈ړ͂ł܂BJĂIuWFNgɑ΂ĎgpĂ͂Ȃ܂B

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

-
- - -
-

gp

-
-    /* t@C܂̓TufBNg̖OύX */
-    f_rename("oldname.txt", "newname.txt");
-
-    /* t@C܂̓TufBNg̖O̕ύXƕʂ̃fBNgւ̈ړ */
-    f_rename("oldname.txt", "dir1/newname.txt");
-
-
- -

߂

- - + + + + + + + + +FatFs - f_rename + + + + +
+

f_rename

+

t@C܂̓TuEfBNg̖O̕ύX܂͈ړ܂B

+
+FRESULT f_rename (
+  const TCHAR* old_name, /* [IN] ÂIuWFNg */
+  const TCHAR* new_name  /* [IN] VIuWFNg */
+);
+
+
+ +
+

+
+
old_name
+
ύXΏۂ̃t@C܂̓TuEfBNgpXk'\0'I[̕ւ̃|C^w肵܂B
+
new_name
+
VpXk'\0'I[̕ւ̃|C^w肵܂Bɑ݂IuWFNgƓO͎g܂B܂AhCuԍ͎w肵ĂAold_nameŌ߂ꂽ_hCũIuWFNgƂĈ܂B
+
+
+ + + + + +
+

+

t@C܂̓TuEfBNg̖OύX܂B܂Aɕʂ̃fBNgւ̈ړ”\łAقȂhCuւ̈ړ͂ł܂BJĂIuWFNgɑ΂ĎgpĂ͂Ȃ܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

+
+ + +
+

gp

+
+    /* t@C܂̓TufBNg̖OύX */
+    f_rename("oldname.txt", "newname.txt");
+
+    /* t@C܂̓TufBNg̖O̕ύXƕʂ̃fBNgւ̈ړ */
+    f_rename("oldname.txt", "dir1/newname.txt");
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/sdir.html b/3rdparty/fatfs-0.10b/doc/ja/sdir.html similarity index 98% rename from src/gfile/fatfs/doc/ja/sdir.html rename to 3rdparty/fatfs-0.10b/doc/ja/sdir.html index 3e6f7120..d305f23d 100644 --- a/src/gfile/fatfs/doc/ja/sdir.html +++ b/3rdparty/fatfs-0.10b/doc/ja/sdir.html @@ -1,40 +1,40 @@ - - - - - - - - -FatFs - DIR - - - - -
-

DIR

-

DIR\̂́Af_opendir(), f_readdir()̃[NEGAƂĎgp܂BAvP[V́A̍\̂̃oĂ͂Ȃ܂B

-
-typedef struct {
-    FATFS*  fs;        /* et@CEVXeEIuWFNgւ̃|C^ */
-    WORD    id;        /* et@CEVXeEIuWFNg̃}EgID */
-    WORD    index;     /* ɌJnfBNgECfbNXԍ */
-    DWORD   sclust;    /* e[uJnNX^ (0:[g) */
-    DWORD   clust;     /* ݂̃NX^ԍ */
-    DWORD   sect;      /* ݂̃ZN^ԍ */
-    BYTE*   dir;       /* ݂SFNGgւ̃|C^ */
-    BYTE*   fn;        /* SFNobt@ւ̃|C^ (in/out) {file[8],ext[3],status[1]} */
-#if _FS_LOCK
-    UINT    lockid;    /* bNID */
-#endif
-#if _USE_LFN
-    WCHAR*  lfn;       /* LFNobt@ւ̃|C^ (in/out) */
-    WORD    lfn_idx;   /* LFNGg̐擪CfbNX (0xFFFF:) */
-#endif
-} DIR;
-
-
- -

߂

- - + + + + + + + + +FatFs - DIR + + + + +
+

DIR

+

DIR\̂́Af_opendir(), f_readdir()̃[NEGAƂĎgp܂BAvP[V́A̍\̂̃oĂ͂Ȃ܂B

+
+typedef struct {
+    FATFS*  fs;        /* et@CEVXeEIuWFNgւ̃|C^ */
+    WORD    id;        /* et@CEVXeEIuWFNg̃}EgID */
+    WORD    index;     /* ɌJnfBNgECfbNXԍ */
+    DWORD   sclust;    /* e[uJnNX^ (0:[g) */
+    DWORD   clust;     /* ݂̃NX^ԍ */
+    DWORD   sect;      /* ݂̃ZN^ԍ */
+    BYTE*   dir;       /* ݂SFNGgւ̃|C^ */
+    BYTE*   fn;        /* SFNobt@ւ̃|C^ (in/out) {file[8],ext[3],status[1]} */
+#if _FS_LOCK
+    UINT    lockid;    /* bNID */
+#endif
+#if _USE_LFN
+    WCHAR*  lfn;       /* LFNobt@ւ̃|C^ (in/out) */
+    WORD    lfn_idx;   /* LFNGg̐擪CfbNX (0xFFFF:) */
+#endif
+} DIR;
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/setlabel.html b/3rdparty/fatfs-0.10b/doc/ja/setlabel.html similarity index 96% rename from src/gfile/fatfs/doc/ja/setlabel.html rename to 3rdparty/fatfs-0.10b/doc/ja/setlabel.html index af4a2437..fa0e4921 100644 --- a/src/gfile/fatfs/doc/ja/setlabel.html +++ b/3rdparty/fatfs-0.10b/doc/ja/setlabel.html @@ -1,89 +1,89 @@ - - - - - - - - -FatFs - f_setlabel - - - - -
-

f_setlabel

-

{[Ƀ{[Exݒ肵܂B

-
-FRESULT f_setlabel (
-  const TCHAR* label  /* [IN] ݒ肷{[Exւ̃|C^ */
-);
-
-
- -
-

-
-
label
-
ݒ肷{[Exk'\0'I[̕ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

̐擪ɃhCuԍ܂ޏꍇ́A̘_hCuɑ΂Đݒ肳܂B܂܂Ȃꍇ́AftHgEhCuɐݒ肳܂B{[Ex폜Ƃ́Akw肵܂B{[Ex̃tH[}bǵAt@C(SFN)ƂقړłA̓_قȂ܂B

-
    -
  • [JR[hZ11oCgȉBLFNg͓Kp܂B
  • -
  • sIh܂ނƂ͂łȂB
  • -
  • Cӂ̈ʒuɃXy[XuƂłBAŌƂȂXy[X͏B
  • -
-
- -
-

Ή

-

_FS_READONLY == 0ŁA_USE_LABEL == 1̂ƂɎgp”\łB

-
- - -
-

gp

-
-    /* ftHgEhCuɃ{[Exݒ */
-    f_setlabel("DATA DISK");
-
-    /* hCu2Ƀ{[Exݒ */
-    f_setlabel("2:DISK 3 OF 4");
-
-    /* hCu2̃{[Ex폜 */
-    f_setlabel("2:");
-
-
- - -
-

Q

-f_getlabel -
- - -

߂

- - + + + + + + + + +FatFs - f_setlabel + + + + +
+

f_setlabel

+

{[Ƀ{[Exݒ肵܂B

+
+FRESULT f_setlabel (
+  const TCHAR* label  /* [IN] ݒ肷{[Exւ̃|C^ */
+);
+
+
+ +
+

+
+
label
+
ݒ肷{[Exk'\0'I[̕ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

̐擪ɃhCuԍ܂ޏꍇ́A̘_hCuɑ΂Đݒ肳܂B܂܂Ȃꍇ́AftHgEhCuɐݒ肳܂B{[Ex폜Ƃ́Akw肵܂B{[Ex̃tH[}bǵAt@C(SFN)ƂقړłA̓_قȂ܂B

+
    +
  • [JR[hZ11oCgȉBLFNg͓Kp܂B
  • +
  • sIh܂ނƂ͂łȂB
  • +
  • Cӂ̈ʒuɃXy[XuƂłBAŌƂȂXy[X͏B
  • +
+
+ +
+

Ή

+

_FS_READONLY == 0ŁA_USE_LABEL == 1̂ƂɎgp”\łB

+
+ + +
+

gp

+
+    /* ftHgEhCuɃ{[Exݒ */
+    f_setlabel("DATA DISK");
+
+    /* hCu2Ƀ{[Exݒ */
+    f_setlabel("2:DISK 3 OF 4");
+
+    /* hCu2̃{[Ex폜 */
+    f_setlabel("2:");
+
+
+ + +
+

Q

+f_getlabel +
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/sfatfs.html b/3rdparty/fatfs-0.10b/doc/ja/sfatfs.html similarity index 98% rename from src/gfile/fatfs/doc/ja/sfatfs.html rename to 3rdparty/fatfs-0.10b/doc/ja/sfatfs.html index ed5ac87f..0c9fa573 100644 --- a/src/gfile/fatfs/doc/ja/sfatfs.html +++ b/3rdparty/fatfs-0.10b/doc/ja/sfatfs.html @@ -1,55 +1,55 @@ - - - - - - - - -FatFs - FATFS - - - - -
-

FATFS

-

FATFS\(t@CEVXeEIuWFNg)́AX̘_hCũ_Ci~bNE[NEGAێAf_mount()FatFsW[ɓo^܂Bs^C~ÓAf_mount()(}Egw)̎s܂̓fBǍ̍ŏ̃t@CEANZX̎łBAvP[V́A̍\̂̃oĂ͂Ȃ܂B

- -
-typedef struct {
-    BYTE    fs_type;      /* FAT^Cv */
-    BYTE    drv;          /* hCuԍ */
-    BYTE    csize;        /* NX^̃ZN^ (1,2,4,8,...,128)*/
-    BYTE    n_fats;       /* FAT̑d (1,2) */
-    BYTE    wflag;        /* win[]_[eBEtO */
-    BYTE    fsi_flag;     /* FSINFOtO (b7:Disabled, b0:Dirty)*/
-    WORD    id;           /* t@CEVXeE}EgID */
-    WORD    n_rootdir;    /* [gEfBNg̃Gg (FAT12/16) */
-#if _MAX_SS != _MIN_SS
-    WORD    ssize;        /* ZN^ETCY (512, 1024, 2048 or 4096) */
-#endif
-#if _FS_REENTRANT
-    _SYNC_t sobj;         /* IuWFNgID */
-#endif
-#if !_FS_READONLY
-    DWORD   last_clust;   /* FSINFO: ŌɊ蓖ĂꂽNX^ԍ */
-    DWORD   free_clust;   /* FSINFO: 󂫃NX^ */
-#endif
-#if _FS_RPATH
-    DWORD   cdir;         /* JgEfBNg̃NX^ (0:[g) */
-#endif
-    DWORD   n_fatent;     /* FATGg (NX^ + 2) */
-    DWORD   fsize;        /* FAT 1‚̃ZN^ */
-    DWORD   volbase;      /* {[JnZN^ */
-    DWORD   fatbase;      /* FAT̈JnZN^ */
-    DWORD   dirbase;      /* [gEfBNg̈JnZN^(NX^) */
-    DWORD   database;     /* f[^̈JnZN^ */
-    DWORD   winsect;      /* win[]ɌĂZN^ԍ */
-    BYTE    win[_MAX_SS]; /* fBXNEANZXEEBhE */
-} FATFS;
-
-
- -

߂

- - + + + + + + + + +FatFs - FATFS + + + + +
+

FATFS

+

FATFS\(t@CEVXeEIuWFNg)́AX̘_hCũ_Ci~bNE[NEGAێAf_mount()FatFsW[ɓo^܂Bs^C~ÓAf_mount()(}Egw)̎s܂̓fBǍ̍ŏ̃t@CEANZX̎łBAvP[V́A̍\̂̃oĂ͂Ȃ܂B

+ +
+typedef struct {
+    BYTE    fs_type;      /* FAT^Cv */
+    BYTE    drv;          /* hCuԍ */
+    BYTE    csize;        /* NX^̃ZN^ (1,2,4,8,...,128)*/
+    BYTE    n_fats;       /* FAT̑d (1,2) */
+    BYTE    wflag;        /* win[]_[eBEtO */
+    BYTE    fsi_flag;     /* FSINFOtO (b7:Disabled, b0:Dirty)*/
+    WORD    id;           /* t@CEVXeE}EgID */
+    WORD    n_rootdir;    /* [gEfBNg̃Gg (FAT12/16) */
+#if _MAX_SS != _MIN_SS
+    WORD    ssize;        /* ZN^ETCY (512, 1024, 2048 or 4096) */
+#endif
+#if _FS_REENTRANT
+    _SYNC_t sobj;         /* IuWFNgID */
+#endif
+#if !_FS_READONLY
+    DWORD   last_clust;   /* FSINFO: ŌɊ蓖ĂꂽNX^ԍ */
+    DWORD   free_clust;   /* FSINFO: 󂫃NX^ */
+#endif
+#if _FS_RPATH
+    DWORD   cdir;         /* JgEfBNg̃NX^ (0:[g) */
+#endif
+    DWORD   n_fatent;     /* FATGg (NX^ + 2) */
+    DWORD   fsize;        /* FAT 1‚̃ZN^ */
+    DWORD   volbase;      /* {[JnZN^ */
+    DWORD   fatbase;      /* FAT̈JnZN^ */
+    DWORD   dirbase;      /* [gEfBNg̈JnZN^(NX^) */
+    DWORD   database;     /* f[^̈JnZN^ */
+    DWORD   winsect;      /* win[]ɌĂZN^ԍ */
+    BYTE    win[_MAX_SS]; /* fBXNEANZXEEBhE */
+} FATFS;
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/sfile.html b/3rdparty/fatfs-0.10b/doc/ja/sfile.html similarity index 98% rename from src/gfile/fatfs/doc/ja/sfile.html rename to 3rdparty/fatfs-0.10b/doc/ja/sfile.html index 36a73b38..21290443 100644 --- a/src/gfile/fatfs/doc/ja/sfile.html +++ b/3rdparty/fatfs-0.10b/doc/ja/sfile.html @@ -1,48 +1,48 @@ - - - - - - - - -FatFs - FIL - - - - -
-

FIL

-

FIL\(t@CEIuWFNg)́Af_open()ŏAȌセ̃t@C̏Ԃێ܂B܂Af_close()Ńt@C‚Ɩ܂BAvP[V́A̍\̂̃oĂ͂Ȃ܂(cltbl͗O)B^Cj[\ł́AɃZN^Eobt@mۂ̂ŁALTCYɒӂKvłB

- -
-typedef struct {
-    FATFS*  fs;           /* et@CEVXeEIuWFNgւ̃|C^ */
-    WORD    id;           /* et@CEVXeEIuWFNg̃}EgID */
-    BYTE    flag;         /* t@CEXe[^XEtO */
-    BYTE    err;          /* G[ftO */
-    DWORD   fptr;         /* t@Cǂݏ|C^ (t@C擪̃oCgEItZbg) */
-    DWORD   fsize;        /* t@CETCY(oCgP) */
-    DWORD   sclust;       /* t@CJnNX^ԍ (0:蓖Ė) */
-    DWORD   clust;        /* ݂̃NX^ */
-    DWORD   dsect;        /* ݂̃f[^EZN^ */
-#if !_FS_READONLY
-    DWORD   dir_sect;     /* ̃t@C̃fBNgEGĝZN^ */
-    BYTE*   dir_ptr;      /* ̃t@C̃fBNgւ̃|C^ */
-#endif
-#if _USE_FASTSEEK
-    DWORD*  cltbl;        /* t@C̃NX^ENւ̃|C^ (I[vNULLZbg) */
-#endif
-#if _FS_LOCK
-    UINT    lockid;       /* t@CEbNID */
-#endif
-#if !_FS_TINY
-    BYTE    buf[_MAX_SS]; /* t@CEvCx[gEf[^]obt@ */
-#endif
-} FIL;
-
-
- -

߂

- - + + + + + + + + +FatFs - FIL + + + + +
+

FIL

+

FIL\(t@CEIuWFNg)́Af_open()ŏAȌセ̃t@C̏Ԃێ܂B܂Af_close()Ńt@C‚Ɩ܂BAvP[V́A̍\̂̃oĂ͂Ȃ܂(cltbl͗O)B^Cj[\ł́AɃZN^Eobt@mۂ̂ŁALTCYɒӂKvłB

+ +
+typedef struct {
+    FATFS*  fs;           /* et@CEVXeEIuWFNgւ̃|C^ */
+    WORD    id;           /* et@CEVXeEIuWFNg̃}EgID */
+    BYTE    flag;         /* t@CEXe[^XEtO */
+    BYTE    err;          /* G[ftO */
+    DWORD   fptr;         /* t@Cǂݏ|C^ (t@C擪̃oCgEItZbg) */
+    DWORD   fsize;        /* t@CETCY(oCgP) */
+    DWORD   sclust;       /* t@CJnNX^ԍ (0:蓖Ė) */
+    DWORD   clust;        /* ݂̃NX^ */
+    DWORD   dsect;        /* ݂̃f[^EZN^ */
+#if !_FS_READONLY
+    DWORD   dir_sect;     /* ̃t@C̃fBNgEGĝZN^ */
+    BYTE*   dir_ptr;      /* ̃t@C̃fBNgւ̃|C^ */
+#endif
+#if _USE_FASTSEEK
+    DWORD*  cltbl;        /* t@C̃NX^ENւ̃|C^ (I[vNULLZbg) */
+#endif
+#if _FS_LOCK
+    UINT    lockid;       /* t@CEbNID */
+#endif
+#if !_FS_TINY
+    BYTE    buf[_MAX_SS]; /* t@CEvCx[gEf[^]obt@ */
+#endif
+} FIL;
+
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/sfileinfo.html b/3rdparty/fatfs-0.10b/doc/ja/sfileinfo.html similarity index 97% rename from src/gfile/fatfs/doc/ja/sfileinfo.html rename to 3rdparty/fatfs-0.10b/doc/ja/sfileinfo.html index 1a3db24d..a4b1fe2d 100644 --- a/src/gfile/fatfs/doc/ja/sfileinfo.html +++ b/3rdparty/fatfs-0.10b/doc/ja/sfileinfo.html @@ -1,70 +1,70 @@ - - - - - - - - -FatFs - FILINFO - - - - -
-

FILINFO

-

FILINFO\̂́Af_stat(), f_readdir()ŕԂt@Cێ܂B

-
-typedef struct {
-    DWORD fsize;     /* t@CETCY */
-    WORD fdate;      /* ŌɍXVꂽt */
-    WORD ftime;      /* ŌɍXVꂽ  */
-    BYTE fattrib;    /* Agr[g */
-    TCHAR fname[13]; /* Zt@C (8.3tH[}bg) */
-#if _USE_LFN
-    TCHAR* lfname;   /* t@C̃obt@ւ̃|C^ */
-    int lfsize;      /* t@C̃obt@̃TCY [] */
-#endif
-} FILINFO;
-
-
- -

o

-
-
fsize
-
t@C̃oCgPʂ̃TCYi[܂BfBNg̏ꍇ͏0łB
-
fdate
-
t@C̕ύXꂽtA܂̓fBNg̍쐬ꂽti[܂B
-
-
bit15:9
-
1980NN_ƂN 0..127 œ܂B
-
bit8:5
-
1..12 ̒lœ܂B
-
bit4:0
-
1..31 ̒lœ܂B
-
-
-
ftime
-
t@C̕ύXꂽA܂̓fBNg̍쐬ꂽi[܂B
-
-
bit15:11
-
0..23 ̒lœ܂B
-
bit10:5
-
0..59 ̒lœ܂B
-
bit4:0
-
b/2 0..29 ̒lœ܂B
-
-
-
fattrib
-
tOi[܂BtOAM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC̑gݍ킹ƂȂ܂B
-
fname[]
-
8.3`̖O'\0'ŏI镶ƂĊi[܂BLFN\̂Ƃ́Aɑ啶ŕԂ܂BLFN\̂Ƃ͒ZOԂ܂AASCIIpɂȂꍇ܂B
-
lfname
-
Ԃ钷t@Ci[obt@ւ̃|C^B̍\̂gpOɃAvP[Vɂ菉Ȃ΂Ȃ܂B̃oNULLݒ肳LFN͕Ԃ܂BLFN\̂Ƃ͂̃o݂͑܂B
-
lfsize
-
t@Ci[obt@̃TCY(vf)B̍\̂gpOɃAvP[Vɂ菉Ȃ΂Ȃ܂BLFN\̂Ƃ͂̃o݂͑܂B
-
- -

߂

- - + + + + + + + + +FatFs - FILINFO + + + + +
+

FILINFO

+

FILINFO\̂́Af_stat(), f_readdir()ŕԂt@Cێ܂B

+
+typedef struct {
+    DWORD fsize;     /* t@CETCY */
+    WORD fdate;      /* ŌɍXVꂽt */
+    WORD ftime;      /* ŌɍXVꂽ  */
+    BYTE fattrib;    /* Agr[g */
+    TCHAR fname[13]; /* Zt@C (8.3tH[}bg) */
+#if _USE_LFN
+    TCHAR* lfname;   /* t@C̃obt@ւ̃|C^ */
+    int lfsize;      /* t@C̃obt@̃TCY [] */
+#endif
+} FILINFO;
+
+
+ +

o

+
+
fsize
+
t@C̃oCgPʂ̃TCYi[܂BfBNg̏ꍇ͏0łB
+
fdate
+
t@C̕ύXꂽtA܂̓fBNg̍쐬ꂽti[܂B
+
+
bit15:9
+
1980NN_ƂN 0..127 œ܂B
+
bit8:5
+
1..12 ̒lœ܂B
+
bit4:0
+
1..31 ̒lœ܂B
+
+
+
ftime
+
t@C̕ύXꂽA܂̓fBNg̍쐬ꂽi[܂B
+
+
bit15:11
+
0..23 ̒lœ܂B
+
bit10:5
+
0..59 ̒lœ܂B
+
bit4:0
+
b/2 0..29 ̒lœ܂B
+
+
+
fattrib
+
tOi[܂BtOAM_DIR, AM_RDO, AM_HID, AM_SYS, AM_ARC̑gݍ킹ƂȂ܂B
+
fname[]
+
8.3`̖O'\0'ŏI镶ƂĊi[܂BLFN\̂Ƃ́Aɑ啶ŕԂ܂BLFN\̂Ƃ͒ZOԂ܂AASCIIpɂȂꍇ܂B
+
lfname
+
Ԃ钷t@Ci[obt@ւ̃|C^B̍\̂gpOɃAvP[Vɂ菉Ȃ΂Ȃ܂B̃oNULLݒ肳LFN͕Ԃ܂BLFN\̂Ƃ͂̃o݂͑܂B
+
lfsize
+
t@Ci[obt@̃TCY(vf)B̍\̂gpOɃAvP[Vɂ菉Ȃ΂Ȃ܂BLFN\̂Ƃ͂̃o݂͑܂B
+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/size.html b/3rdparty/fatfs-0.10b/doc/ja/size.html similarity index 95% rename from src/gfile/fatfs/doc/ja/size.html rename to 3rdparty/fatfs-0.10b/doc/ja/size.html index caff05da..959bc468 100644 --- a/src/gfile/fatfs/doc/ja/size.html +++ b/3rdparty/fatfs-0.10b/doc/ja/size.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_size - - - - -
-

f_size

-

t@C̃TCY擾܂B

-
-DWORD f_size (
-  FIL* fp   /* [IN] t@CEIuWFNg */
-);
-
-
- - -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

oCgPʂ̃t@CETCYԂ܂B

-
- - -
-

-

f_size֐́ArWł̓}NƂĎĂ܂B

-
-#define f_size(fp) ((fp)->fsize)
-
-
- - -
-

Ή

-

Ɏgp”\B

-
- - -
-

Q

-

f_open, f_lseek, FIL

-
- -

߂

- - + + + + + + + + +FatFs - f_size + + + + +
+

f_size

+

t@C̃TCY擾܂B

+
+DWORD f_size (
+  FIL* fp   /* [IN] t@CEIuWFNg */
+);
+
+
+ + +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

oCgPʂ̃t@CETCYԂ܂B

+
+ + +
+

+

f_size֐́ArWł̓}NƂĎĂ܂B

+
+#define f_size(fp) ((fp)->fsize)
+
+
+ + +
+

Ή

+

Ɏgp”\B

+
+ + +
+

Q

+

f_open, f_lseek, FIL

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/stat.html b/3rdparty/fatfs-0.10b/doc/ja/stat.html similarity index 97% rename from src/gfile/fatfs/doc/ja/stat.html rename to 3rdparty/fatfs-0.10b/doc/ja/stat.html index 5337f348..2a88bbf6 100644 --- a/src/gfile/fatfs/doc/ja/stat.html +++ b/3rdparty/fatfs-0.10b/doc/ja/stat.html @@ -1,74 +1,74 @@ - - - - - - - - -FatFs - f_stat - - - - -
-

f_stat

-

t@C܂̓TuEfBNg݂̑𒲂ׁA܂̏擾܂B

-
-FRESULT f_stat (
-  const TCHAR* path,  /* [IN] IuWFNgւ̃|C^ */
-  FILINFO* fno        /* [OUT] t@C\̂ւ̃|C^ */
-);
-
-
- -
-

-
-
path
-
`FbNIuWFNgk'\0'I[̕w|C^w肵܂B
-
fno
-
IuWFNg݂Ƃɂ̏i[t@C\̂ւ̃|C^w肵܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
-
-
- - - - - -
-

-

w肳ꂽt@C܂̓TuEfBNg݂̑𒲂ׂ܂B݂Ȃꍇ́AFR_NO_FILEA܂B݂ꍇFR_OKAAt@C\̂ɂւ(TCYA^CX^vAђZt@C)XgA܂B

-
- - -
-

Ή

-

_FS_MINIMIZE == 0̂ƂɎgp”\łB

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_stat + + + + +
+

f_stat

+

t@C܂̓TuEfBNg݂̑𒲂ׁA܂̏擾܂B

+
+FRESULT f_stat (
+  const TCHAR* path,  /* [IN] IuWFNgւ̃|C^ */
+  FILINFO* fno        /* [OUT] t@C\̂ւ̃|C^ */
+);
+
+
+ +
+

+
+
path
+
`FbNIuWFNgk'\0'I[̕w|C^w肵܂B
+
fno
+
IuWFNg݂Ƃɂ̏i[t@C\̂ւ̃|C^w肵܂B̏񂪕svȂƂ̓kE|C^w肵ĂB
+
+
+ + + + + +
+

+

w肳ꂽt@C܂̓TuEfBNg݂̑𒲂ׂ܂B݂Ȃꍇ́AFR_NO_FILEA܂B݂ꍇFR_OKAAt@C\̂ɂւ(TCYA^CX^vAђZt@C)XgA܂B

+
+ + +
+

Ή

+

_FS_MINIMIZE == 0̂ƂɎgp”\łB

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/sync.html b/3rdparty/fatfs-0.10b/doc/ja/sync.html similarity index 95% rename from src/gfile/fatfs/doc/ja/sync.html rename to 3rdparty/fatfs-0.10b/doc/ja/sync.html index cb798731..34403275 100644 --- a/src/gfile/fatfs/doc/ja/sync.html +++ b/3rdparty/fatfs-0.10b/doc/ja/sync.html @@ -1,66 +1,66 @@ - - - - - - - - -FatFs - f_sync - - - - -
-

f_sync

-

ݒ̃t@C̃LbVꂽtbV܂B

-
-FRESULT f_sync (
-  FIL* fp     /* [IN] t@CEIuWFNg\̂ւ̃|C^ */
-);
-
-
- -
-

-
-
fp
-
synct@C̃t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

̊֐f_close()Ɠs܂At@C͈Jꂽ܂܂ɂȂAǂݏ𑱍sł܂BMOȂǁA݃[hŒԃt@CJĂAvP[VɂāAI܂͋؂̗ǂƂł̊֐gp邱ƂɂAsӂ̓df⃁fBA̎Oɂ莸f[^ŏɂ邱Ƃł܂B̔wiɂ‚ẮAAvP[VEm[gQƂĂB

-

ۂ̂ƂAf_close()ł͂̊֐Ăяot@CEIuWFNg𖳌Ă邾Ȃ̂ŁAf_close()Of_sync()͖ӖłB

-
- - -
-

Ή

-

_FS_READONLY == 0̂ƂɎgp”\łB

-
- - -
-

Q

-

f_close

-
- -

߂

- - + + + + + + + + +FatFs - f_sync + + + + +
+

f_sync

+

ݒ̃t@C̃LbVꂽtbV܂B

+
+FRESULT f_sync (
+  FIL* fp     /* [IN] t@CEIuWFNg\̂ւ̃|C^ */
+);
+
+
+ +
+

+
+
fp
+
synct@C̃t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

̊֐f_close()Ɠs܂At@C͈Jꂽ܂܂ɂȂAǂݏ𑱍sł܂BMOȂǁA݃[hŒԃt@CJĂAvP[VɂāAI܂͋؂̗ǂƂł̊֐gp邱ƂɂAsӂ̓df⃁fBA̎Oɂ莸f[^ŏɂ邱Ƃł܂B̔wiɂ‚ẮAAvP[VEm[gQƂĂB

+

ۂ̂ƂAf_close()ł͂̊֐Ăяot@CEIuWFNg𖳌Ă邾Ȃ̂ŁAf_close()Of_sync()uƂ͖ӖłB

+
+ + +
+

Ή

+

_FS_READONLY == 0̂ƂɎgp”\łB

+
+ + +
+

Q

+

f_close

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/tell.html b/3rdparty/fatfs-0.10b/doc/ja/tell.html similarity index 96% rename from src/gfile/fatfs/doc/ja/tell.html rename to 3rdparty/fatfs-0.10b/doc/ja/tell.html index 1dee9825..c39505e0 100644 --- a/src/gfile/fatfs/doc/ja/tell.html +++ b/3rdparty/fatfs-0.10b/doc/ja/tell.html @@ -1,62 +1,62 @@ - - - - - - - - -FatFs - f_tell - - - - -
-

f_tell

-

݂̃[h/CgE|C^擾܂B

-
-DWORD f_tell (
-  FIL* fp   /* [IN] t@CEIuWFNg */
-);
-
-
- - -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
-
- - -
-

߂l

-

݂̃[h/CgE|C^(t@C擪̃oCgPʂ̃ItZbg)Ԃ܂B

-
- - -
-

-

f_tell֐́ArWł̓}NƂĎĂ܂B

-
-#define f_tell(fp) ((fp)->fptr)
-
-
- - -
-

Ή

-

Ɏgp”\B

-
- - -
-

Q

-

f_open, f_lseek, FIL

-
- -

߂

- - + + + + + + + + +FatFs - f_tell + + + + +
+

f_tell

+

݂̃[h/CgE|C^擾܂B

+
+DWORD f_tell (
+  FIL* fp   /* [IN] t@CEIuWFNg */
+);
+
+
+ + +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
+
+ + +
+

߂l

+

݂̃[h/CgE|C^(t@C擪̃oCgPʂ̃ItZbg)Ԃ܂B

+
+ + +
+

+

f_tell֐́ArWł̓}NƂĎĂ܂B

+
+#define f_tell(fp) ((fp)->fptr)
+
+
+ + +
+

Ή

+

Ɏgp”\B

+
+ + +
+

Q

+

f_open, f_lseek, FIL

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/truncate.html b/3rdparty/fatfs-0.10b/doc/ja/truncate.html similarity index 96% rename from src/gfile/fatfs/doc/ja/truncate.html rename to 3rdparty/fatfs-0.10b/doc/ja/truncate.html index 29bf480a..23ed35ea 100644 --- a/src/gfile/fatfs/doc/ja/truncate.html +++ b/3rdparty/fatfs-0.10b/doc/ja/truncate.html @@ -1,67 +1,67 @@ - - - - - - - - -FatFs - f_truncate - - - - -
-

f_truncate

-

t@C؂l߂܂B

-
-FRESULT f_truncate (
-  FIL* fp     /* [IN] t@CEIuWFNgւ̃|C^ */
-);
-
-
- -
-

-
-
fp
-
؂lߑΏۃt@C̃t@CEIuWFNgւ̃|C^
-
-
- - - - - -
-

-

t@C݂̒̃[h/CgE|C^ɐ؂l߂܂B[h/CgE|C^Ƀt@C̏I[wĂƂ́Å֐͉̌ʂ܂B

-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

-
- - -
-

Q

-

f_open, f_lseek, FIL

-
- - -

Return

- - + + + + + + + + +FatFs - f_truncate + + + + +
+

f_truncate

+

t@C؂l߂܂B

+
+FRESULT f_truncate (
+  FIL* fp     /* [IN] t@CEIuWFNgւ̃|C^ */
+);
+
+
+ +
+

+
+
fp
+
؂lߑΏۃt@C̃t@CEIuWFNgւ̃|C^
+
+
+ + + + + +
+

+

t@C݂̒̃[h/CgE|C^ɐ؂l߂܂B[h/CgE|C^Ƀt@C̏I[wĂƂ́Å֐͉̌ʂ܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

+
+ + +
+

Q

+

f_open, f_lseek, FIL

+
+ + +

Return

+ + diff --git a/src/gfile/fatfs/doc/ja/unlink.html b/3rdparty/fatfs-0.10b/doc/ja/unlink.html similarity index 97% rename from src/gfile/fatfs/doc/ja/unlink.html rename to 3rdparty/fatfs-0.10b/doc/ja/unlink.html index 7cfb703f..ac38552f 100644 --- a/src/gfile/fatfs/doc/ja/unlink.html +++ b/3rdparty/fatfs-0.10b/doc/ja/unlink.html @@ -1,74 +1,74 @@ - - - - - - - - -FatFs - f_unlink - - - - -
-

f_unlink

-

t@C܂̓TuEfBNg폜܂B

-
-FRESULT f_unlink (
-  const TCHAR* path  /* [IN] IuWFNgւ̃|C^ */
-);
-
-
- -
-

-
-
path
-
폜ΏۂpXk'\0'I[̕ւ̃|C^w肵܂B
-
-
- - - - - -
-

-

폜Ώۂ̃IuWFNg̏ɓĂ͂܂ꍇÃANZX͋ۂ֐͎s܂B -

    -
  • [hEI[(AM_RDO)Ăꍇ́A(FR_DENIED)B
  • -
  • łȂTuEfBNg܂̓JgEfBNgłꍇ́A(FR_DENIED)B
  • -
  • JĂt@C܂̓TuEfBNgłꍇ́AdANZXLȂSɋ(FR_LOCKED)܂AłȂƂ͕sȑƂȂAFAT\j󂳂”\܂B
  • -
-

-
- -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

-
- - -

߂

- - + + + + + + + + +FatFs - f_unlink + + + + +
+

f_unlink

+

t@C܂̓TuEfBNg폜܂B

+
+FRESULT f_unlink (
+  const TCHAR* path  /* [IN] IuWFNgւ̃|C^ */
+);
+
+
+ +
+

+
+
path
+
폜ΏۂpXk'\0'I[̕ւ̃|C^w肵܂B
+
+
+ + + + + +
+

+

폜Ώۂ̃IuWFNg̏ɓĂ͂܂ꍇÃANZX͋ۂ֐͎s܂B +

    +
  • [hEI[(AM_RDO)Ăꍇ́A(FR_DENIED)B
  • +
  • łȂTuEfBNg܂̓JgEfBNgłꍇ́A(FR_DENIED)B
  • +
  • JĂt@C܂̓TuEfBNgłꍇ́AdANZXLȂSɋ(FR_LOCKED)܂AłȂƂ͕sȑƂȂAFAT\j󂳂”\܂B
  • +
+

+
+ +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

+
+ + +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/utime.html b/3rdparty/fatfs-0.10b/doc/ja/utime.html similarity index 96% rename from src/gfile/fatfs/doc/ja/utime.html rename to 3rdparty/fatfs-0.10b/doc/ja/utime.html index 382defbb..8bccf652 100644 --- a/src/gfile/fatfs/doc/ja/utime.html +++ b/3rdparty/fatfs-0.10b/doc/ja/utime.html @@ -1,99 +1,99 @@ - - - - - - - - -FatFs - f_utime - - - - -
-

f_utime

-

t@C܂̓TuEfBNg̃^CX^vύX܂B

-
-FRESULT f_utime (
-  const TCHAR* path,  /* [IN] IuWFNgւ̃|C^ */
-  const FILINFO* fno  /* [IN] ݒ肷t */
-);
-
-
- -
-

-
-
path
-
ύXΏۂ̃IuWFNgpXk'\0'I[̕w肵܂B
-
fno
-
ݒ肷tƎԂfdateftimeoɐݒ肳ꂽFILINFO\̂ւ̃|C^B̃o͂̊֐ł͈Ӗ܂B
-
-
- - - - - -
-

-

IuWFNg̃^CX^vύX܂B

-
- - -
-

gp

-
-FRESULT set_timestamp (
-    char *obj,     /* t@Cւ̃|C^ */
-    int year,
-    int month,
-    int mday,
-    int hour,
-    int min,
-    int sec
-)
-{
-    FILINFO fno;
-
-    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
-    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
-
-    return f_utime(obj, &fno);
-}
-
-
- - -
-

Ή

-

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

-
- - -
-

Q

-

f_stat, FILINFO

-
- -

߂

- - + + + + + + + + +FatFs - f_utime + + + + +
+

f_utime

+

t@C܂̓TuEfBNg̃^CX^vύX܂B

+
+FRESULT f_utime (
+  const TCHAR* path,  /* [IN] IuWFNgւ̃|C^ */
+  const FILINFO* fno  /* [IN] ݒ肷t */
+);
+
+
+ +
+

+
+
path
+
ύXΏۂ̃IuWFNgpXk'\0'I[̕w肵܂B
+
fno
+
ݒ肷tƎԂfdateftimeoɐݒ肳ꂽFILINFO\̂ւ̃|C^B̃o͂̊֐ł͈Ӗ܂B
+
+
+ + + + + +
+

+

IuWFNg̃^CX^vύX܂B

+
+ + +
+

gp

+
+FRESULT set_timestamp (
+    char *obj,     /* t@Cւ̃|C^ */
+    int year,
+    int month,
+    int mday,
+    int hour,
+    int min,
+    int sec
+)
+{
+    FILINFO fno;
+
+    fno.fdate = (WORD)(((year - 1980) * 512U) | month * 32U | mday);
+    fno.ftime = (WORD)(hour * 2048U | min * 32U | sec / 2U);
+
+    return f_utime(obj, &fno);
+}
+
+
+ + +
+

Ή

+

_FS_READONLY == 0ŁA_FS_MINIMIZE == 0̂ƂɎgp”\łB

+
+ + +
+

Q

+

f_stat, FILINFO

+
+ +

߂

+ + diff --git a/src/gfile/fatfs/doc/ja/write.html b/3rdparty/fatfs-0.10b/doc/ja/write.html similarity index 97% rename from src/gfile/fatfs/doc/ja/write.html rename to 3rdparty/fatfs-0.10b/doc/ja/write.html index 35da3fa9..9156571d 100644 --- a/src/gfile/fatfs/doc/ja/write.html +++ b/3rdparty/fatfs-0.10b/doc/ja/write.html @@ -1,75 +1,75 @@ - - - - - - - - -FatFs - f_write - - - - -
-

f_write

-

t@CɃf[^݂܂B

-
-FRESULT f_write (
-  FIL* fp,           /* [IN] t@CEIuWFNg */
-  const void* buff,  /* [IN] ݃f[^ */
-  UINT btw,          /* [IN] ރoCg */
-  UINT* bw           /* [OUT] ܂ꂽoCg */
-);
-
-
- -
-

-
-
fp
-
t@CEIuWFNg\̂ւ̃|C^w肵܂B
-
buff
-
ރf[^i[obt@w|C^w肵܂B
-
btw
-
ރoCg(0`UINT^̍ől)w肵܂B
-
bw
-
܂ꂽoCgi[ϐw|C^w肵܂B߂l͊֐̐ۂɂ炸ɗLłB
-
-
- - - - - -
-

-

݊JnʒúA[h/CgE|C^̈ʒuɂȂ܂B[h/CgE|C^͎ۂɏ܂ꂽoCgi݂܂B֐IAvoCg܂ꂽǂ*bw`FbNׂłB*bwbtw菬Ƃ́AfBXNEtӖ܂BfBXNEtĂƂ܂͂ɋ߂Ƃ́A䂪A܂ŎԂꍇ܂B

-
- - -
-

Ή

-

_FS_READONLY == 0̂ƂɎgp”\łB

-
- - - - -

߂

- - + + + + + + + + +FatFs - f_write + + + + +
+

f_write

+

t@CɃf[^݂܂B

+
+FRESULT f_write (
+  FIL* fp,           /* [IN] t@CEIuWFNg */
+  const void* buff,  /* [IN] ݃f[^ */
+  UINT btw,          /* [IN] ރoCg */
+  UINT* bw           /* [OUT] ܂ꂽoCg */
+);
+
+
+ +
+

+
+
fp
+
t@CEIuWFNg\̂ւ̃|C^w肵܂B
+
buff
+
ރf[^i[obt@w|C^w肵܂B
+
btw
+
ރoCg(0`UINT^̍ől)w肵܂B
+
bw
+
܂ꂽoCgi[ϐw|C^w肵܂B߂l͊֐̐ۂɂ炸ɗLłB
+
+
+ + + + + +
+

+

݊JnʒúA[h/CgE|C^̈ʒuɂȂ܂B[h/CgE|C^͎ۂɏ܂ꂽoCgi݂܂B֐IAvoCg܂ꂽǂ*bw`FbNׂłB*bwbtw菬Ƃ́AfBXNEtӖ܂BfBXNEtĂƂ܂͂ɋ߂Ƃ́A䂪A܂ŎԂꍇ܂B

+
+ + +
+

Ή

+

_FS_READONLY == 0̂ƂɎgp”\łB

+
+ + + + +

߂

+ + diff --git a/src/gfile/fatfs/doc/updates.txt b/3rdparty/fatfs-0.10b/doc/updates.txt similarity index 86% rename from src/gfile/fatfs/doc/updates.txt rename to 3rdparty/fatfs-0.10b/doc/updates.txt index c2d0bc51..a86c01cb 100644 --- a/src/gfile/fatfs/doc/updates.txt +++ b/3rdparty/fatfs-0.10b/doc/updates.txt @@ -1,146 +1,146 @@ -R0.10b, May 19, 2014 - Fixed a hard error in the disk I/O layer can collapse the directory entry. - Fixed LFN entry is not deleted on delete/rename an object with its lossy converted SFN. - -R0.10a, Jan 15, 2014 - Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) - Added a configuration option of minimum sector size. (_MIN_SS) - 2nd argument of f_rename() can have a drive number and it will be ignored. - Fixed f_mount() with forced mount fails when drive number is >= 1. - Fixed f_close() invalidates the file object without volume lock. - Fixed f_closedir() returns but the volume lock is left acquired. - Fixed creation of an entry with LFN fails on too many SFN collisions. - -R0.10, Oct 02, 2013 - Added selection of character encoding on the file. (_STRF_ENCODE) - Added f_closedir(). - Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) - Added forced mount feature with changes of f_mount(). - Improved behavior of volume auto detection. - Improved write throughput of f_puts() and f_printf(). - Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). - Fixed f_write() can be truncated when the file size is close to 4GB. - Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code. - -R0.09b, Jan 24, 2013 - Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1) - -R0.09a, Aug 27, 2012 - Fixed assertion failure due to OS/2 EA on FAT12/16. - Changed API rejects null object pointer to avoid crash. - Changed option name _FS_SHARE to _FS_LOCK. - -R0.09, Sep 06, 2011 - f_mkfs() supports multiple partition to finish the multiple partition feature. - Added f_fdisk(). (_MULTI_PARTITION = 2) - -R0.08b, Jan 15, 2011 - Fast seek feature is also applied to f_read() and f_write(). - f_lseek() reports required table size on creating CLMP. - Extended format syntax of f_printf(). - Ignores duplicated directory separators in given path names. - -R0.08a, Aug 16, 2010 - Added f_getcwd(). (_FS_RPATH = 2) - Added sector erase feature. (_USE_ERASE) - Moved file lock semaphore table from fs object to the bss. - Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'. - Fixed f_mkfs() creates wrong FAT32 volume. - -R0.08, May 15, 2010 - Added a memory configuration option. (_USE_LFN) - Added file lock feature. (_FS_SHARE) - Added fast seek feature. (_USE_FASTSEEK) - Changed some types on the API, XCHAR->TCHAR. - Changed fname member in the FILINFO structure on Unicode cfg. - String functions support UTF-8 encoding files on Unicode cfg. - -R0.07e, Nov 3, 2009 - Separated out configuration options from ff.h to ffconf.h. - Added a configuration option, _LFN_UNICODE. - Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. - Fixed name matching error on the 13 char boundary. - Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. - -R0.07c, Jun 21, 2009 - Fixed f_unlink() may return FR_OK on error. - Fixed wrong cache control in f_lseek(). - Added relative path feature. - Added f_chdir(). - Added f_chdrive(). - Added proper case conversion to extended characters. - -R0.07a, Apr 14, 2009 - Separated out OS dependent code on re-entrant configuration. - Added multiple sector size support. - -R0.07, Apr 01, 2009 - Merged Tiny-FatFs into FatFs as a buffer configuration option. - Added long file name support. - Added multiple code page support. - Added re-entrancy for multitask operation. - Added auto cluster size selection to f_mkfs(). - Added rewind option to f_readdir(). - Changed result code of critical errors. - Renamed string functions to avoid name collision. - -R0.06, Apr 01, 2008 - Added f_forward. (Tiny-FatFs) - Added string functions: fgets, fputc, fputs and fprintf. - Improved performance of f_lseek on moving to the same or following cluster. - -R0.05a, Feb 03, 2008 - Added f_truncate. - Added f_utime. - Fixed off by one error at FAT sub-type determination. - Fixed btr in f_read can be mistruncated. - Fixed cached sector is left not flushed when create and close without write. - -R0.05, Aug 26, 2007 - Changed arguments of f_read, f_write. - Changed arguments of f_mkfs. (FatFs) - Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs) - Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs) - -R0.04b, May 05, 2007 - Added _USE_NTFLAG option. - Added FSInfo support. - Fixed some problems corresponds to FAT32. (Tiny-FatFs) - Fixed DBCS name can result FR_INVALID_NAME. - Fixed short seek (<= csize) collapses the file object. - -R0.04a, Apr 01, 2007 - Supported multiple partitions on a plysical drive. (FatFs) - Added minimization level 3. - Added a capability of extending file size to f_lseek. - Fixed an endian sensitive code in f_mkfs. (FatFs) - Fixed a problem corresponds to FAT32 support. (Tiny-FatFs) - -R0.04, Feb 04, 2007 - Supported multiple drive system. (FatFs) - Changed some APIs for multiple drive system. - Added f_mkfs. (FatFs) - Added _USE_FAT32 option. (Tiny-FatFs) - -R0.03a, Dec 11, 2006 - Improved cluster scan algolithm to write files fast. - Fixed f_mkdir creates incorrect directory on FAT32. - -R0.03, Sep 22, 2006 - Added f_rename. - Changed option _FS_MINIMUM to _FS_MINIMIZE. - -R0.02a, Jun 10, 2006 - Added a configuration option _FS_MINIMUM. - -R0.02, Jun 01, 2006 - Added FAT12. - Removed unbuffered mode. - Fixed a problem on small (<32M) patition. - -R0.01, Apr 29, 2006 - First release - -R0.00, Feb 26, 2006 - Prototype (not released) - +R0.10b, May 19, 2014 + Fixed a hard error in the disk I/O layer can collapse the directory entry. + Fixed LFN entry is not deleted on delete/rename an object with its lossy converted SFN. + +R0.10a, Jan 15, 2014 + Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) + Added an option for minimum sector size. (_MIN_SS) + 2nd argument of f_rename() can have a drive number and it will be ignored. + Fixed f_mount() with forced mount fails when drive number is larger than 0. + Fixed f_close() invalidates the file object without volume lock. + Fixed volume lock is left acquired after return from f_closedir(). + Fixed creation of a directory entry with LFN fails on too many SFN collisions. + +R0.10, Oct 02, 2013 + Added an option for character encoding on the file. (_STRF_ENCODE) + Added f_closedir(). + Added forced full FAT scan option for f_getfree(). (_FS_NOFSINFO) + Added forced mount feature with changes of f_mount(). + Improved behavior of volume auto detection. + Improved write throughput of f_puts() and f_printf(). + Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). + Fixed f_write() can be truncated when the file size is close to 4GB. + Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect result code on error. + +R0.09b, Jan 24, 2013 + Added f_getlabel() and f_setlabel(). (_USE_LABEL = 1) + +R0.09a, Aug 27, 2012 + Fixed assertion failure due to OS/2 EA on FAT12/16 volume. + Changed file functions reject null object pointer to avoid crash. + Changed option name _FS_SHARE to _FS_LOCK. + +R0.09, Sep 06, 2011 + f_mkfs() supports multiple partition to complete the multiple partition feature. + Added f_fdisk(). (_MULTI_PARTITION = 2) + +R0.08b, Jan 15, 2011 + Fast seek feature is also applied to f_read() and f_write(). + f_lseek() reports required table size on creating CLMP. + Extended format syntax of f_printf(). + Ignores duplicated directory separators in given path names. + +R0.08a, Aug 16, 2010 + Added f_getcwd(). (_FS_RPATH = 2) + Added sector erase feature. (_USE_ERASE) + Moved file lock semaphore table from fs object to the bss. + Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'. + Fixed f_mkfs() creates wrong FAT32 volume. + +R0.08, May 15, 2010 + Added a memory configuration option. (_USE_LFN) + Added file lock feature. (_FS_SHARE) + Added fast seek feature. (_USE_FASTSEEK) + Changed some types on the API, XCHAR->TCHAR. + Changed fname member in the FILINFO structure on Unicode cfg. + String functions support UTF-8 encoding files on Unicode cfg. + +R0.07e, Nov 3, 2009 + Separated out configuration options from ff.h to ffconf.h. + Added a configuration option, _LFN_UNICODE. + Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. + Fixed name matching error on the 13 char boundary. + Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. + +R0.07c, Jun 21, 2009 + Fixed f_unlink() may return FR_OK on error. + Fixed wrong cache control in f_lseek(). + Added relative path feature. + Added f_chdir(). + Added f_chdrive(). + Added proper case conversion to extended characters. + +R0.07a, Apr 14, 2009 + Separated out OS dependent code on re-entrant configuration. + Added multiple sector size support. + +R0.07, Apr 01, 2009 + Merged Tiny-FatFs into FatFs as a buffer configuration option. + Added long file name support. + Added multiple code page support. + Added re-entrancy for multitask operation. + Added auto cluster size selection to f_mkfs(). + Added rewind option to f_readdir(). + Changed result code of critical errors. + Renamed string functions to avoid name collision. + +R0.06, Apr 01, 2008 + Added f_forward. (Tiny-FatFs) + Added string functions: fgets, fputc, fputs and fprintf. + Improved performance of f_lseek on moving to the same or following cluster. + +R0.05a, Feb 03, 2008 + Added f_truncate. + Added f_utime. + Fixed off by one error at FAT sub-type determination. + Fixed btr in f_read can be mistruncated. + Fixed cached sector is left not flushed when create and close without write. + +R0.05, Aug 26, 2007 + Changed arguments of f_read, f_write. + Changed arguments of f_mkfs. (FatFs) + Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs) + Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs) + +R0.04b, May 05, 2007 + Added _USE_NTFLAG option. + Added FSInfo support. + Fixed some problems corresponds to FAT32. (Tiny-FatFs) + Fixed DBCS name can result FR_INVALID_NAME. + Fixed short seek (<= csize) collapses the file object. + +R0.04a, Apr 01, 2007 + Supported multiple partitions on a plysical drive. (FatFs) + Added minimization level 3. + Added a capability of extending file size to f_lseek. + Fixed an endian sensitive code in f_mkfs. (FatFs) + Fixed a problem corresponds to FAT32 support. (Tiny-FatFs) + +R0.04, Feb 04, 2007 + Supported multiple drive system. (FatFs) + Changed some APIs for multiple drive system. + Added f_mkfs. (FatFs) + Added _USE_FAT32 option. (Tiny-FatFs) + +R0.03a, Dec 11, 2006 + Improved cluster scan algolithm to write files fast. + Fixed f_mkdir creates incorrect directory on FAT32. + +R0.03, Sep 22, 2006 + Added f_rename. + Changed option _FS_MINIMUM to _FS_MINIMIZE. + +R0.02a, Jun 10, 2006 + Added a configuration option _FS_MINIMUM. + +R0.02, Jun 01, 2006 + Added FAT12. + Removed unbuffered mode. + Fixed a problem on small (<32M) patition. + +R0.01, Apr 29, 2006 + First release + +R0.00, Feb 26, 2006 + Prototype (not released) + diff --git a/src/gfile/fatfs/src/00readme.txt b/3rdparty/fatfs-0.10b/src/00readme.txt similarity index 98% rename from src/gfile/fatfs/src/00readme.txt rename to 3rdparty/fatfs-0.10b/src/00readme.txt index 7285d330..e7692095 100644 --- a/src/gfile/fatfs/src/00readme.txt +++ b/3rdparty/fatfs-0.10b/src/00readme.txt @@ -1,158 +1,158 @@ -FatFs Module Source Files R0.10b (C)ChaN, 2014 - - -FILES - - ffconf.h Configuration file for FatFs module. - ff.h Common include file for FatFs and application module. - ff.c FatFs module. - diskio.h Common include file for FatFs and disk I/O module. - diskio.c An example of glue function to attach existing disk I/O module to FatFs. - integer.h Integer type definitions for FatFs. - option Optional external functions. - - Low level disk I/O module is not included in this archive because the FatFs - module is only a generic file system layer and not depend on any specific - storage device. You have to provide a low level disk I/O module that written - to control your storage device. - - - -AGREEMENTS - - FatFs module is an open source software to implement FAT file system to - small embedded systems. This is a free software and is opened for education, - research and commercial developments under license policy of following trems. - - Copyright (C) 2014, ChaN, all right reserved. - - * The FatFs module is a free software and there is NO WARRANTY. - * No restriction on use. You can use, modify and redistribute it for - personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY. - * Redistributions of source code must retain the above copyright notice. - - - -REVISION HISTORY - - Feb 26, 2006 R0.00 Prototype - - Apr 29, 2006 R0.01 First release. - - Jun 01, 2006 R0.02 Added FAT12. - Removed unbuffered mode. - Fixed a problem on small (<32M) patition. - - Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM. - - Sep 22, 2006 R0.03 Added f_rename. - Changed option _FS_MINIMUM to _FS_MINIMIZE. - - Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast. - Fixed f_mkdir creates incorrect directory on FAT32. - - Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs) - Changed some APIs for multiple drive system. - Added f_mkfs. (FatFs) - Added _USE_FAT32 option. (Tiny-FatFs) - - Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs) - Fixed an endian sensitive code in f_mkfs. (FatFs) - Added a capability of extending the file size to f_lseek. - Added minimization level 3. - Fixed a problem that can collapse a sector when recreate an - existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs) - - May 05, 2007 R0.04b Added _USE_NTFLAG option. - Added FSInfo support. - Fixed some problems corresponds to FAT32. (Tiny-FatFs) - Fixed DBCS name can result FR_INVALID_NAME. - Fixed short seek (0 < ofs <= csize) collapses the file object. - - Aug 25, 2007 R0.05 Changed arguments of f_read, f_write. - Changed arguments of f_mkfs. (FatFs) - Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs) - Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs) - - Feb 03, 2008 R0.05a Added f_truncate(). - Added f_utime(). - Fixed off by one error at FAT sub-type determination. - Fixed btr in f_read() can be mistruncated. - Fixed cached sector is not flushed when create and close without write. - - Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs) - Added string functions: fputc(), fputs(), fprintf() and fgets(). - Improved performance of f_lseek() on move to the same or following cluster. - - Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option. - Added long file name support. - Added multiple code page support. - Added re-entrancy for multitask operation. - Added auto cluster size selection to f_mkfs(). - Added rewind option to f_readdir(). - Changed result code of critical errors. - Renamed string functions to avoid name collision. - - Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg. - Added multiple sector size support. - - Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error. - Fixed wrong cache control in f_lseek(). - Added relative path feature. - Added f_chdir(). - Added f_chdrive(). - Added proper case conversion for extended characters. - - Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h. - Added a configuration option, _LFN_UNICODE. - Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. - Fixed name matching error on the 13 char boundary. - Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. - - May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN) - Added file lock feature. (_FS_SHARE) - Added fast seek feature. (_USE_FASTSEEK) - Changed some types on the API, XCHAR->TCHAR. - Changed fname member in the FILINFO structure on Unicode cfg. - String functions support UTF-8 encoding files on Unicode cfg. - - Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2) - Added sector erase feature. (_USE_ERASE) - Moved file lock semaphore table from fs object to the bss. - Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'. - Fixed f_mkfs() creates wrong FAT32 volume. - - Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write(). - f_lseek() reports required table size on creating CLMP. - Extended format syntax of f_printf function. - Ignores duplicated directory separators in given path names. - - Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature. - Added f_fdisk(). (_MULTI_PARTITION = 2) - - Aug 27,'12 R0.09a Fixed assertion failure due to OS/2 EA on FAT12/16. - Changed f_open() and f_opendir() reject null object pointer to avoid crash. - Changed option name _FS_SHARE to _FS_LOCK. - - Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL) - - Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE) - Added f_closedir(). - Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) - Added forced mount feature with changes of f_mount(). - Improved behavior of volume auto detection. - Improved write throughput of f_puts() and f_printf(). - Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). - Fixed f_write() can be truncated when the file size is close to 4GB. - Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code. - - Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) - Added a configuration option of minimum sector size. (_MIN_SS) - 2nd argument of f_rename() can have a drive number and it will be ignored. - Fixed f_mount() with forced mount fails when drive number is >= 1. - Fixed f_close() invalidates the file object without volume lock. - Fixed f_closedir() returns but the volume lock is left acquired. - Fixed creation of an entry with LFN fails on too many SFN collisions. - - Mar 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry. - Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. +FatFs Module Source Files R0.10b (C)ChaN, 2014 + + +FILES + + ffconf.h Configuration file for FatFs module. + ff.h Common include file for FatFs and application module. + ff.c FatFs module. + diskio.h Common include file for FatFs and disk I/O module. + diskio.c An example of glue function to attach existing disk I/O module to FatFs. + integer.h Integer type definitions for FatFs. + option Optional external functions. + + Low level disk I/O module is not included in this archive because the FatFs + module is only a generic file system layer and not depend on any specific + storage device. You have to provide a low level disk I/O module that written + to control your storage device. + + + +AGREEMENTS + + FatFs module is an open source software to implement FAT file system to + small embedded systems. This is a free software and is opened for education, + research and commercial developments under license policy of following trems. + + Copyright (C) 2014, ChaN, all right reserved. + + * The FatFs module is a free software and there is NO WARRANTY. + * No restriction on use. You can use, modify and redistribute it for + personal, non-profit or commercial product UNDER YOUR RESPONSIBILITY. + * Redistributions of source code must retain the above copyright notice. + + + +REVISION HISTORY + + Feb 26, 2006 R0.00 Prototype + + Apr 29, 2006 R0.01 First release. + + Jun 01, 2006 R0.02 Added FAT12. + Removed unbuffered mode. + Fixed a problem on small (<32M) patition. + + Jun 10, 2006 R0.02a Added a configuration option _FS_MINIMUM. + + Sep 22, 2006 R0.03 Added f_rename. + Changed option _FS_MINIMUM to _FS_MINIMIZE. + + Dec 11, 2006 R0.03a Improved cluster scan algolithm to write files fast. + Fixed f_mkdir creates incorrect directory on FAT32. + + Feb 04, 2007 R0.04 Supported multiple drive system. (FatFs) + Changed some APIs for multiple drive system. + Added f_mkfs. (FatFs) + Added _USE_FAT32 option. (Tiny-FatFs) + + Apr 01, 2007 R0.04a Supported multiple partitions on a plysical drive. (FatFs) + Fixed an endian sensitive code in f_mkfs. (FatFs) + Added a capability of extending the file size to f_lseek. + Added minimization level 3. + Fixed a problem that can collapse a sector when recreate an + existing file in any sub-directory at non FAT32 cfg. (Tiny-FatFs) + + May 05, 2007 R0.04b Added _USE_NTFLAG option. + Added FSInfo support. + Fixed some problems corresponds to FAT32. (Tiny-FatFs) + Fixed DBCS name can result FR_INVALID_NAME. + Fixed short seek (0 < ofs <= csize) collapses the file object. + + Aug 25, 2007 R0.05 Changed arguments of f_read, f_write. + Changed arguments of f_mkfs. (FatFs) + Fixed f_mkfs on FAT32 creates incorrect FSInfo. (FatFs) + Fixed f_mkdir on FAT32 creates incorrect directory. (FatFs) + + Feb 03, 2008 R0.05a Added f_truncate(). + Added f_utime(). + Fixed off by one error at FAT sub-type determination. + Fixed btr in f_read() can be mistruncated. + Fixed cached sector is not flushed when create and close without write. + + Apr 01, 2008 R0.06 Added f_forward(). (Tiny-FatFs) + Added string functions: fputc(), fputs(), fprintf() and fgets(). + Improved performance of f_lseek() on move to the same or following cluster. + + Apr 01, 2009, R0.07 Merged Tiny-FatFs as a buffer configuration option. + Added long file name support. + Added multiple code page support. + Added re-entrancy for multitask operation. + Added auto cluster size selection to f_mkfs(). + Added rewind option to f_readdir(). + Changed result code of critical errors. + Renamed string functions to avoid name collision. + + Apr 14, 2009, R0.07a Separated out OS dependent code on reentrant cfg. + Added multiple sector size support. + + Jun 21, 2009, R0.07c Fixed f_unlink() may return FR_OK on error. + Fixed wrong cache control in f_lseek(). + Added relative path feature. + Added f_chdir(). + Added f_chdrive(). + Added proper case conversion for extended characters. + + Nov 03, 2009 R0.07e Separated out configuration options from ff.h to ffconf.h. + Added a configuration option, _LFN_UNICODE. + Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH. + Fixed name matching error on the 13 char boundary. + Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. + + May 15, 2010, R0.08 Added a memory configuration option. (_USE_LFN) + Added file lock feature. (_FS_SHARE) + Added fast seek feature. (_USE_FASTSEEK) + Changed some types on the API, XCHAR->TCHAR. + Changed fname member in the FILINFO structure on Unicode cfg. + String functions support UTF-8 encoding files on Unicode cfg. + + Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2) + Added sector erase feature. (_USE_ERASE) + Moved file lock semaphore table from fs object to the bss. + Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'. + Fixed f_mkfs() creates wrong FAT32 volume. + + Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write(). + f_lseek() reports required table size on creating CLMP. + Extended format syntax of f_printf function. + Ignores duplicated directory separators in given path names. + + Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature. + Added f_fdisk(). (_MULTI_PARTITION = 2) + + Aug 27,'12 R0.09a Fixed assertion failure due to OS/2 EA on FAT12/16. + Changed f_open() and f_opendir() reject null object pointer to avoid crash. + Changed option name _FS_SHARE to _FS_LOCK. + + Jan 23,'13 R0.09b Added f_getlabel() and f_setlabel(). (_USE_LABEL) + + Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE) + Added f_closedir(). + Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) + Added forced mount feature with changes of f_mount(). + Improved behavior of volume auto detection. + Improved write throughput of f_puts() and f_printf(). + Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). + Fixed f_write() can be truncated when the file size is close to 4GB. + Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code. + + Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) + Added a configuration option of minimum sector size. (_MIN_SS) + 2nd argument of f_rename() can have a drive number and it will be ignored. + Fixed f_mount() with forced mount fails when drive number is >= 1. + Fixed f_close() invalidates the file object without volume lock. + Fixed f_closedir() returns but the volume lock is left acquired. + Fixed creation of an entry with LFN fails on too many SFN collisions. + + Mar 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry. + Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. diff --git a/3rdparty/fatfs-0.10b/src/diskio.c b/3rdparty/fatfs-0.10b/src/diskio.c new file mode 100644 index 00000000..461e99a3 --- /dev/null +++ b/3rdparty/fatfs-0.10b/src/diskio.c @@ -0,0 +1,236 @@ +/*-----------------------------------------------------------------------*/ +/* Low level disk I/O module skeleton for FatFs (C)ChaN, 2013 */ +/*-----------------------------------------------------------------------*/ +/* If a working storage control module is available, it should be */ +/* attached to the FatFs via a glue function rather than modifying it. */ +/* This is an example of glue functions to attach various exsisting */ +/* storage control module to the FatFs module with a defined API. */ +/*-----------------------------------------------------------------------*/ + +#include "diskio.h" /* FatFs lower layer API */ +#include "usbdisk.h" /* Example: USB drive control */ +#include "atadrive.h" /* Example: ATA drive control */ +#include "sdcard.h" /* Example: MMC/SDC contorl */ + +/* Definitions of physical drive number for each media */ +#define ATA 0 +#define MMC 1 +#define USB 2 + + +/*-----------------------------------------------------------------------*/ +/* Inidialize a Drive */ +/*-----------------------------------------------------------------------*/ + +DSTATUS disk_initialize ( + BYTE pdrv /* Physical drive nmuber (0..) */ +) +{ + DSTATUS stat; + int result; + + switch (pdrv) { + case ATA : + result = ATA_disk_initialize(); + + // translate the reslut code here + + return stat; + + case MMC : + result = MMC_disk_initialize(); + + // translate the reslut code here + + return stat; + + case USB : + result = USB_disk_initialize(); + + // translate the reslut code here + + return stat; + } + return STA_NOINIT; +} + + + +/*-----------------------------------------------------------------------*/ +/* Get Disk Status */ +/*-----------------------------------------------------------------------*/ + +DSTATUS disk_status ( + BYTE pdrv /* Physical drive nmuber (0..) */ +) +{ + DSTATUS stat; + int result; + + switch (pdrv) { + case ATA : + result = ATA_disk_status(); + + // translate the reslut code here + + return stat; + + case MMC : + result = MMC_disk_status(); + + // translate the reslut code here + + return stat; + + case USB : + result = USB_disk_status(); + + // translate the reslut code here + + return stat; + } + return STA_NOINIT; +} + + + +/*-----------------------------------------------------------------------*/ +/* Read Sector(s) */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_read ( + BYTE pdrv, /* Physical drive nmuber (0..) */ + BYTE *buff, /* Data buffer to store read data */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to read (1..128) */ +) +{ + DRESULT res; + int result; + + switch (pdrv) { + case ATA : + // translate the arguments here + + result = ATA_disk_read(buff, sector, count); + + // translate the reslut code here + + return res; + + case MMC : + // translate the arguments here + + result = MMC_disk_read(buff, sector, count); + + // translate the reslut code here + + return res; + + case USB : + // translate the arguments here + + result = USB_disk_read(buff, sector, count); + + // translate the reslut code here + + return res; + } + return RES_PARERR; +} + + + +/*-----------------------------------------------------------------------*/ +/* Write Sector(s) */ +/*-----------------------------------------------------------------------*/ + +#if _USE_WRITE +DRESULT disk_write ( + BYTE pdrv, /* Physical drive nmuber (0..) */ + const BYTE *buff, /* Data to be written */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to write (1..128) */ +) +{ + DRESULT res; + int result; + + switch (pdrv) { + case ATA : + // translate the arguments here + + result = ATA_disk_write(buff, sector, count); + + // translate the reslut code here + + return res; + + case MMC : + // translate the arguments here + + result = MMC_disk_write(buff, sector, count); + + // translate the reslut code here + + return res; + + case USB : + // translate the arguments here + + result = USB_disk_write(buff, sector, count); + + // translate the reslut code here + + return res; + } + return RES_PARERR; +} +#endif + + +/*-----------------------------------------------------------------------*/ +/* Miscellaneous Functions */ +/*-----------------------------------------------------------------------*/ + +#if _USE_IOCTL +DRESULT disk_ioctl ( + BYTE pdrv, /* Physical drive nmuber (0..) */ + BYTE cmd, /* Control code */ + void *buff /* Buffer to send/receive control data */ +) +{ + DRESULT res; + int result; + + switch (pdrv) { + case ATA : + // pre-process here + + result = ATA_disk_ioctl(cmd, buff); + + // post-process here + + return res; + + case MMC : + // pre-process here + + result = MMC_disk_ioctl(cmd, buff); + + // post-process here + + return res; + + case USB : + // pre-process here + + result = USB_disk_ioctl(cmd, buff); + + // post-process here + + return res; + } + return RES_PARERR; +} +#endif diff --git a/src/gfile/fatfs/src/diskio.h b/3rdparty/fatfs-0.10b/src/diskio.h similarity index 96% rename from src/gfile/fatfs/src/diskio.h rename to 3rdparty/fatfs-0.10b/src/diskio.h index 3c2b09d1..4d72b910 100644 --- a/src/gfile/fatfs/src/diskio.h +++ b/3rdparty/fatfs-0.10b/src/diskio.h @@ -1,80 +1,80 @@ -/*-----------------------------------------------------------------------/ -/ Low level disk interface modlue include file (C)ChaN, 2013 / -/-----------------------------------------------------------------------*/ - -#ifndef _DISKIO_DEFINED -#define _DISKIO_DEFINED - -#ifdef __cplusplus -extern "C" { -#endif - -#define _USE_WRITE 1 /* 1: Enable disk_write function */ -#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ - -#include "integer.h" - - -/* Status of Disk Functions */ -typedef BYTE DSTATUS; - -/* Results of Disk Functions */ -typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ -} DRESULT; - - -/*---------------------------------------*/ -/* Prototypes for disk control functions */ - - -DSTATUS disk_initialize (BYTE pdrv); -DSTATUS disk_status (BYTE pdrv); -DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); -DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); -DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); - - -/* Disk Status Bits (DSTATUS) */ - -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ - - -/* Command code for disk_ioctrl fucntion */ - -/* Generic command (used by FatFs) */ -#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ -#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ -#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ - -/* Generic command (not used by FatFs) */ -#define CTRL_POWER 5 /* Get/Set power status */ -#define CTRL_LOCK 6 /* Lock/Unlock media removal */ -#define CTRL_EJECT 7 /* Eject media */ -#define CTRL_FORMAT 8 /* Create physical format on the media */ - -/* MMC/SDC specific ioctl command */ -#define MMC_GET_TYPE 10 /* Get card type */ -#define MMC_GET_CSD 11 /* Get CSD */ -#define MMC_GET_CID 12 /* Get CID */ -#define MMC_GET_OCR 13 /* Get OCR */ -#define MMC_GET_SDSTAT 14 /* Get SD status */ - -/* ATA/CF specific ioctl command */ -#define ATA_GET_REV 20 /* Get F/W revision */ -#define ATA_GET_MODEL 21 /* Get model name */ -#define ATA_GET_SN 22 /* Get serial number */ - -#ifdef __cplusplus -} -#endif - -#endif +/*-----------------------------------------------------------------------/ +/ Low level disk interface modlue include file (C)ChaN, 2013 / +/-----------------------------------------------------------------------*/ + +#ifndef _DISKIO_DEFINED +#define _DISKIO_DEFINED + +#ifdef __cplusplus +extern "C" { +#endif + +#define _USE_WRITE 1 /* 1: Enable disk_write function */ +#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */ + +#include "integer.h" + + +/* Status of Disk Functions */ +typedef BYTE DSTATUS; + +/* Results of Disk Functions */ +typedef enum { + RES_OK = 0, /* 0: Successful */ + RES_ERROR, /* 1: R/W Error */ + RES_WRPRT, /* 2: Write Protected */ + RES_NOTRDY, /* 3: Not Ready */ + RES_PARERR /* 4: Invalid Parameter */ +} DRESULT; + + +/*---------------------------------------*/ +/* Prototypes for disk control functions */ + + +DSTATUS disk_initialize (BYTE pdrv); +DSTATUS disk_status (BYTE pdrv); +DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count); +DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count); +DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); + + +/* Disk Status Bits (DSTATUS) */ + +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ +#define STA_PROTECT 0x04 /* Write protected */ + + +/* Command code for disk_ioctrl fucntion */ + +/* Generic command (used by FatFs) */ +#define CTRL_SYNC 0 /* Flush disk cache (for write functions) */ +#define GET_SECTOR_COUNT 1 /* Get media size (for only f_mkfs()) */ +#define GET_SECTOR_SIZE 2 /* Get sector size (for multiple sector size (_MAX_SS >= 1024)) */ +#define GET_BLOCK_SIZE 3 /* Get erase block size (for only f_mkfs()) */ +#define CTRL_ERASE_SECTOR 4 /* Force erased a block of sectors (for only _USE_ERASE) */ + +/* Generic command (not used by FatFs) */ +#define CTRL_POWER 5 /* Get/Set power status */ +#define CTRL_LOCK 6 /* Lock/Unlock media removal */ +#define CTRL_EJECT 7 /* Eject media */ +#define CTRL_FORMAT 8 /* Create physical format on the media */ + +/* MMC/SDC specific ioctl command */ +#define MMC_GET_TYPE 10 /* Get card type */ +#define MMC_GET_CSD 11 /* Get CSD */ +#define MMC_GET_CID 12 /* Get CID */ +#define MMC_GET_OCR 13 /* Get OCR */ +#define MMC_GET_SDSTAT 14 /* Get SD status */ + +/* ATA/CF specific ioctl command */ +#define ATA_GET_REV 20 /* Get F/W revision */ +#define ATA_GET_MODEL 21 /* Get model name */ +#define ATA_GET_SN 22 /* Get serial number */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/gfile/fatfs/src/ff.c b/3rdparty/fatfs-0.10b/src/ff.c similarity index 97% rename from src/gfile/fatfs/src/ff.c rename to 3rdparty/fatfs-0.10b/src/ff.c index 2edbe32a..d7d690c7 100644 --- a/src/gfile/fatfs/src/ff.c +++ b/3rdparty/fatfs-0.10b/src/ff.c @@ -1,4588 +1,4588 @@ -/*----------------------------------------------------------------------------/ -/ FatFs - FAT file system module R0.10b (C)ChaN, 2014 -/-----------------------------------------------------------------------------/ -/ FatFs module is a generic FAT file system module for small embedded systems. -/ This is a free software that opened for education, research and commercial -/ developments under license policy of following terms. -/ -/ Copyright (C) 2014, ChaN, all right reserved. -/ -/ * The FatFs module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/-----------------------------------------------------------------------------/ -/ Feb 26,'06 R0.00 Prototype. -/ -/ Apr 29,'06 R0.01 First stable version. -/ -/ Jun 01,'06 R0.02 Added FAT12 support. -/ Removed unbuffered mode. -/ Fixed a problem on small (<32M) partition. -/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM). -/ -/ Sep 22,'06 R0.03 Added f_rename(). -/ Changed option _FS_MINIMUM to _FS_MINIMIZE. -/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast. -/ Fixed f_mkdir() creates incorrect directory on FAT32. -/ -/ Feb 04,'07 R0.04 Supported multiple drive system. -/ Changed some interfaces for multiple drive system. -/ Changed f_mountdrv() to f_mount(). -/ Added f_mkfs(). -/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive. -/ Added a capability of extending file size to f_lseek(). -/ Added minimization level 3. -/ Fixed an endian sensitive code in f_mkfs(). -/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG. -/ Added FSINFO support. -/ Fixed DBCS name can result FR_INVALID_NAME. -/ Fixed short seek (<= csize) collapses the file object. -/ -/ Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs(). -/ Fixed f_mkfs() on FAT32 creates incorrect FSINFO. -/ Fixed f_mkdir() on FAT32 creates incorrect directory. -/ Feb 03,'08 R0.05a Added f_truncate() and f_utime(). -/ Fixed off by one error at FAT sub-type determination. -/ Fixed btr in f_read() can be mistruncated. -/ Fixed cached sector is not flushed when create and close without write. -/ -/ Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets(). -/ Improved performance of f_lseek() on moving to the same or following cluster. -/ -/ Apr 01,'09 R0.07 Merged Tiny-FatFs as a configuration option. (_FS_TINY) -/ Added long file name feature. -/ Added multiple code page feature. -/ Added re-entrancy for multitask operation. -/ Added auto cluster size selection to f_mkfs(). -/ Added rewind option to f_readdir(). -/ Changed result code of critical errors. -/ Renamed string functions to avoid name collision. -/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg. -/ Added multiple sector size feature. -/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error. -/ Fixed wrong cache control in f_lseek(). -/ Added relative path feature. -/ Added f_chdir() and f_chdrive(). -/ Added proper case conversion to extended character. -/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h. -/ Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH. -/ Fixed name matching error on the 13 character boundary. -/ Added a configuration option, _LFN_UNICODE. -/ Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. -/ -/ May 15,'10 R0.08 Added a memory configuration option. (_USE_LFN = 3) -/ Added file lock feature. (_FS_SHARE) -/ Added fast seek feature. (_USE_FASTSEEK) -/ Changed some types on the API, XCHAR->TCHAR. -/ Changed .fname in the FILINFO structure on Unicode cfg. -/ String functions support UTF-8 encoding files on Unicode cfg. -/ Aug 16,'10 R0.08a Added f_getcwd(). -/ Added sector erase feature. (_USE_ERASE) -/ Moved file lock semaphore table from fs object to the bss. -/ Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'. -/ Fixed f_mkfs() creates wrong FAT32 volume. -/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write(). -/ f_lseek() reports required table size on creating CLMP. -/ Extended format syntax of f_printf(). -/ Ignores duplicated directory separators in given path name. -/ -/ Sep 06,'11 R0.09 f_mkfs() supports multiple partition to complete the multiple partition feature. -/ Added f_fdisk(). -/ Aug 27,'12 R0.09a Changed f_open() and f_opendir() reject null object pointer to avoid crash. -/ Changed option name _FS_SHARE to _FS_LOCK. -/ Fixed assertion failure due to OS/2 EA on FAT12/16 volume. -/ Jan 24,'13 R0.09b Added f_setlabel() and f_getlabel(). -/ -/ Oct 02,'13 R0.10 Added selection of character encoding on the file. (_STRF_ENCODE) -/ Added f_closedir(). -/ Added forced full FAT scan for f_getfree(). (_FS_NOFSINFO) -/ Added forced mount feature with changes of f_mount(). -/ Improved behavior of volume auto detection. -/ Improved write throughput of f_puts() and f_printf(). -/ Changed argument of f_chdrive(), f_mkfs(), disk_read() and disk_write(). -/ Fixed f_write() can be truncated when the file size is close to 4GB. -/ Fixed f_open(), f_mkdir() and f_setlabel() can return incorrect error code. -/ Jan 15,'14 R0.10a Added arbitrary strings as drive number in the path name. (_STR_VOLUME_ID) -/ Added a configuration option of minimum sector size. (_MIN_SS) -/ 2nd argument of f_rename() can have a drive number and it will be ignored. -/ Fixed f_mount() with forced mount fails when drive number is >= 1. -/ Fixed f_close() invalidates the file object without volume lock. -/ Fixed f_closedir() returns but the volume lock is left acquired. -/ Fixed creation of an entry with LFN fails on too many SFN collisions. -/ May 19,'14 R0.10b Fixed a hard error in the disk I/O layer can collapse the directory entry. -/ Fixed LFN entry is not deleted on delete/rename an object with lossy converted SFN. -/---------------------------------------------------------------------------*/ - -#include "ff.h" /* Declarations of FatFs API */ -#include "diskio.h" /* Declarations of disk I/O functions */ - - - - -/*-------------------------------------------------------------------------- - - Module Private Definitions - ----------------------------------------------------------------------------*/ - -#if _FATFS != 8051 /* Revision ID */ -#error Wrong include file (ff.h). -#endif - - -/* Reentrancy related */ -#if _FS_REENTRANT -#if _USE_LFN == 1 -#error Static LFN work area cannot be used at thread-safe configuration. -#endif -#define ENTER_FF(fs) { if (!lock_fs(fs)) return FR_TIMEOUT; } -#define LEAVE_FF(fs, res) { unlock_fs(fs, res); return res; } -#else -#define ENTER_FF(fs) -#define LEAVE_FF(fs, res) return res -#endif - -#define ABORT(fs, res) { fp->err = (BYTE)(res); LEAVE_FF(fs, res); } - - -/* Definitions of sector size */ -#if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096) -#error Wrong sector size configuration. -#endif -#if _MAX_SS == _MIN_SS -#define SS(fs) ((UINT)_MAX_SS) /* Fixed sector size */ -#else -#define SS(fs) ((fs)->ssize) /* Variable sector size */ -#endif - - -/* File access control feature */ -#if _FS_LOCK -#if _FS_READONLY -#error _FS_LOCK must be 0 at read-only cfg. -#endif -typedef struct { - FATFS *fs; /* Object ID 1, volume (NULL:blank entry) */ - DWORD clu; /* Object ID 2, directory (0:root) */ - WORD idx; /* Object ID 3, directory index */ - WORD ctr; /* Object open counter, 0:none, 0x01..0xFF:read mode open count, 0x100:write mode */ -} FILESEM; -#endif - - - -/* DBCS code ranges and SBCS extend character conversion table */ - -#if _CODE_PAGE == 932 /* Japanese Shift-JIS */ -#define _DF1S 0x81 /* DBC 1st byte range 1 start */ -#define _DF1E 0x9F /* DBC 1st byte range 1 end */ -#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ -#define _DF2E 0xFC /* DBC 1st byte range 2 end */ -#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ -#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ -#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ -#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ - -#elif _CODE_PAGE == 936 /* Simplified Chinese GBK */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0x80 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 949 /* Korean */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x41 -#define _DS1E 0x5A -#define _DS2S 0x61 -#define _DS2E 0x7A -#define _DS3S 0x81 -#define _DS3E 0xFE - -#elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */ -#define _DF1S 0x81 -#define _DF1E 0xFE -#define _DS1S 0x40 -#define _DS1E 0x7E -#define _DS2S 0xA1 -#define _DS2E 0xFE - -#elif _CODE_PAGE == 437 /* U.S. (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F,0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 720 /* Arabic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x45,0x41,0x84,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x49,0x49,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 737 /* Greek (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ - 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xE7,0xE8,0xF1,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 775 /* Baltic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 850 /* Multilingual Latin 1 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 852 /* Latin 2 (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F,0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} - -#elif _CODE_PAGE == 855 /* Cyrillic (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F,0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ - 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ - 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 857 /* Turkish (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x98,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0x59,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 858 /* Multilingual Latin 1 + Euro (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0xDE,0x8E,0x8F,0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x59,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ - 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD1,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE7,0xE9,0xEA,0xEB,0xED,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 862 /* Hebrew (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0x21,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 866 /* Russian (OEM) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x90,0x91,0x92,0x93,0x9d,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 874 /* Thai (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1250 /* Central Europe (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xA3,0xB4,0xB5,0xB6,0xB7,0xB8,0xA5,0xAA,0xBB,0xBC,0xBD,0xBC,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1251 /* Cyrillic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x82,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x80,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x8D,0x8E,0x8F, \ - 0xA0,0xA2,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB2,0xA5,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xA3,0xBD,0xBD,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF} - -#elif _CODE_PAGE == 1252 /* Latin 1 (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0xAd,0x9B,0x8C,0x9D,0xAE,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1253 /* Greek (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xA2,0xB8,0xB9,0xBA, \ - 0xE0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xFB,0xBC,0xFD,0xBF,0xFF} - -#elif _CODE_PAGE == 1254 /* Turkish (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x8A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0x9F} - -#elif _CODE_PAGE == 1255 /* Hebrew (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1256 /* Arabic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x8C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0x41,0xE1,0x41,0xE3,0xE4,0xE5,0xE6,0x43,0x45,0x45,0x45,0x45,0xEC,0xED,0x49,0x49,0xF0,0xF1,0xF2,0xF3,0x4F,0xF5,0xF6,0xF7,0xF8,0x55,0xFA,0x55,0x55,0xFD,0xFE,0xFF} - -#elif _CODE_PAGE == 1257 /* Baltic (Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ - 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xA8,0xB9,0xAA,0xBB,0xBC,0xBD,0xBE,0xAF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xFF} - -#elif _CODE_PAGE == 1258 /* Vietnam (OEM, Windows) */ -#define _DF1S 0 -#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0xAC,0x9D,0x9E,0x9F, \ - 0xA0,0x21,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xEC,0xCD,0xCE,0xCF,0xD0,0xD1,0xF2,0xD3,0xD4,0xD5,0xD6,0xF7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xFE,0x9F} - -#elif _CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */ -#if _USE_LFN -#error Cannot use LFN feature without valid code page. -#endif -#define _DF1S 0 - -#else -#error Unknown code page - -#endif - - -/* Character code support macros */ -#define IsUpper(c) (((c)>='A')&&((c)<='Z')) -#define IsLower(c) (((c)>='a')&&((c)<='z')) -#define IsDigit(c) (((c)>='0')&&((c)<='9')) - -#if _DF1S /* Code page is DBCS */ - -#ifdef _DF2S /* Two 1st byte areas */ -#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) -#else /* One 1st byte area */ -#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) -#endif - -#ifdef _DS3S /* Three 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) -#else /* Two 2nd byte areas */ -#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) -#endif - -#else /* Code page is SBCS */ - -#define IsDBCS1(c) 0 -#define IsDBCS2(c) 0 - -#endif /* _DF1S */ - - -/* Name status flags */ -#define NS 11 /* Index of name status byte in fn[] */ -#define NS_LOSS 0x01 /* Out of 8.3 format */ -#define NS_LFN 0x02 /* Force to create LFN entry */ -#define NS_LAST 0x04 /* Last segment */ -#define NS_BODY 0x08 /* Lower case flag (body) */ -#define NS_EXT 0x10 /* Lower case flag (ext) */ -#define NS_DOT 0x20 /* Dot entry */ - - -/* FAT sub-type boundaries */ -#define MIN_FAT16 4086U /* Minimum number of clusters for FAT16 */ -#define MIN_FAT32 65526U /* Minimum number of clusters for FAT32 */ - - -/* FatFs refers the members in the FAT structures as byte array instead of -/ structure member because the structure is not binary compatible between -/ different platforms */ - -#define BS_jmpBoot 0 /* Jump instruction (3) */ -#define BS_OEMName 3 /* OEM name (8) */ -#define BPB_BytsPerSec 11 /* Sector size [byte] (2) */ -#define BPB_SecPerClus 13 /* Cluster size [sector] (1) */ -#define BPB_RsvdSecCnt 14 /* Size of reserved area [sector] (2) */ -#define BPB_NumFATs 16 /* Number of FAT copies (1) */ -#define BPB_RootEntCnt 17 /* Number of root directory entries for FAT12/16 (2) */ -#define BPB_TotSec16 19 /* Volume size [sector] (2) */ -#define BPB_Media 21 /* Media descriptor (1) */ -#define BPB_FATSz16 22 /* FAT size [sector] (2) */ -#define BPB_SecPerTrk 24 /* Track size [sector] (2) */ -#define BPB_NumHeads 26 /* Number of heads (2) */ -#define BPB_HiddSec 28 /* Number of special hidden sectors (4) */ -#define BPB_TotSec32 32 /* Volume size [sector] (4) */ -#define BS_DrvNum 36 /* Physical drive number (2) */ -#define BS_BootSig 38 /* Extended boot signature (1) */ -#define BS_VolID 39 /* Volume serial number (4) */ -#define BS_VolLab 43 /* Volume label (8) */ -#define BS_FilSysType 54 /* File system type (1) */ -#define BPB_FATSz32 36 /* FAT size [sector] (4) */ -#define BPB_ExtFlags 40 /* Extended flags (2) */ -#define BPB_FSVer 42 /* File system version (2) */ -#define BPB_RootClus 44 /* Root directory first cluster (4) */ -#define BPB_FSInfo 48 /* Offset of FSINFO sector (2) */ -#define BPB_BkBootSec 50 /* Offset of backup boot sector (2) */ -#define BS_DrvNum32 64 /* Physical drive number (2) */ -#define BS_BootSig32 66 /* Extended boot signature (1) */ -#define BS_VolID32 67 /* Volume serial number (4) */ -#define BS_VolLab32 71 /* Volume label (8) */ -#define BS_FilSysType32 82 /* File system type (1) */ -#define FSI_LeadSig 0 /* FSI: Leading signature (4) */ -#define FSI_StrucSig 484 /* FSI: Structure signature (4) */ -#define FSI_Free_Count 488 /* FSI: Number of free clusters (4) */ -#define FSI_Nxt_Free 492 /* FSI: Last allocated cluster (4) */ -#define MBR_Table 446 /* MBR: Partition table offset (2) */ -#define SZ_PTE 16 /* MBR: Size of a partition table entry */ -#define BS_55AA 510 /* Signature word (2) */ - -#define DIR_Name 0 /* Short file name (11) */ -#define DIR_Attr 11 /* Attribute (1) */ -#define DIR_NTres 12 /* NT flag (1) */ -#define DIR_CrtTimeTenth 13 /* Created time sub-second (1) */ -#define DIR_CrtTime 14 /* Created time (2) */ -#define DIR_CrtDate 16 /* Created date (2) */ -#define DIR_LstAccDate 18 /* Last accessed date (2) */ -#define DIR_FstClusHI 20 /* Higher 16-bit of first cluster (2) */ -#define DIR_WrtTime 22 /* Modified time (2) */ -#define DIR_WrtDate 24 /* Modified date (2) */ -#define DIR_FstClusLO 26 /* Lower 16-bit of first cluster (2) */ -#define DIR_FileSize 28 /* File size (4) */ -#define LDIR_Ord 0 /* LFN entry order and LLE flag (1) */ -#define LDIR_Attr 11 /* LFN attribute (1) */ -#define LDIR_Type 12 /* LFN type (1) */ -#define LDIR_Chksum 13 /* Sum of corresponding SFN entry */ -#define LDIR_FstClusLO 26 /* Filled by zero (0) */ -#define SZ_DIR 32 /* Size of a directory entry */ -#define LLE 0x40 /* Last long entry flag in LDIR_Ord */ -#define DDE 0xE5 /* Deleted directory entry mark in DIR_Name[0] */ -#define NDDE 0x05 /* Replacement of the character collides with DDE */ - - - - -/*------------------------------------------------------------*/ -/* Module private work area */ -/*------------------------------------------------------------*/ -/* Note that uninitialized variables with static duration are -/ guaranteed zero/null as initial value. If not, either the -/ linker or start-up routine is out of ANSI-C standard. -*/ - -#if _VOLUMES >= 1 || _VOLUMES <= 10 -static -FATFS *FatFs[_VOLUMES]; /* Pointer to the file system objects (logical drives) */ -#else -#error Number of volumes must be 1 to 10. -#endif - -static -WORD Fsid; /* File system mount ID */ - -#if _FS_RPATH && _VOLUMES >= 2 -static -BYTE CurrVol; /* Current drive */ -#endif - -#if _FS_LOCK -static -FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */ -#endif - -#if _USE_LFN == 0 /* No LFN feature */ -#define DEF_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) (dobj).fn = sfn -#define FREE_BUF() - -#elif _USE_LFN == 1 /* LFN feature with static working buffer */ -static -WCHAR LfnBuf[_MAX_LFN+1]; -#define DEF_NAMEBUF BYTE sfn[12] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = LfnBuf; } -#define FREE_BUF() - -#elif _USE_LFN == 2 /* LFN feature with dynamic working buffer on the stack */ -#define DEF_NAMEBUF BYTE sfn[12]; WCHAR lbuf[_MAX_LFN+1] -#define INIT_BUF(dobj) { (dobj).fn = sfn; (dobj).lfn = lbuf; } -#define FREE_BUF() - -#elif _USE_LFN == 3 /* LFN feature with dynamic working buffer on the heap */ -#define DEF_NAMEBUF BYTE sfn[12]; WCHAR *lfn -#define INIT_BUF(dobj) { lfn = ff_memalloc((_MAX_LFN + 1) * 2); \ - if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); \ - (dobj).lfn = lfn; (dobj).fn = sfn; } -#define FREE_BUF() ff_memfree(lfn) - -#else -#error Wrong LFN configuration. -#endif - - -#ifdef _EXCVT -static -const BYTE ExCvt[] = _EXCVT; /* Upper conversion table for extended characters */ -#endif - - - - - - -/*-------------------------------------------------------------------------- - - Module Private Functions - ----------------------------------------------------------------------------*/ - - -/*-----------------------------------------------------------------------*/ -/* String functions */ -/*-----------------------------------------------------------------------*/ - -/* Copy memory to memory */ -static -void mem_cpy (void* dst, const void* src, UINT cnt) { - BYTE *d = (BYTE*)dst; - const BYTE *s = (const BYTE*)src; - -#if _WORD_ACCESS == 1 - while (cnt >= sizeof (int)) { - *(int*)d = *(int*)s; - d += sizeof (int); s += sizeof (int); - cnt -= sizeof (int); - } -#endif - while (cnt--) - *d++ = *s++; -} - -/* Fill memory */ -static -void mem_set (void* dst, int val, UINT cnt) { - BYTE *d = (BYTE*)dst; - - while (cnt--) - *d++ = (BYTE)val; -} - -/* Compare memory to memory */ -static -int mem_cmp (const void* dst, const void* src, UINT cnt) { - const BYTE *d = (const BYTE *)dst, *s = (const BYTE *)src; - int r = 0; - - while (cnt-- && (r = *d++ - *s++) == 0) ; - return r; -} - -/* Check if chr is contained in the string */ -static -int chk_chr (const char* str, int chr) { - while (*str && *str != chr) str++; - return *str; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Request/Release grant to access the volume */ -/*-----------------------------------------------------------------------*/ -#if _FS_REENTRANT -static -int lock_fs ( - FATFS* fs /* File system object */ -) -{ - return ff_req_grant(fs->sobj); -} - - -static -void unlock_fs ( - FATFS* fs, /* File system object */ - FRESULT res /* Result code to be returned */ -) -{ - if (fs && - res != FR_NOT_ENABLED && - res != FR_INVALID_DRIVE && - res != FR_INVALID_OBJECT && - res != FR_TIMEOUT) { - ff_rel_grant(fs->sobj); - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* File lock control functions */ -/*-----------------------------------------------------------------------*/ -#if _FS_LOCK - -static -FRESULT chk_lock ( /* Check if the file can be accessed */ - DIR* dp, /* Directory object pointing the file to be checked */ - int acc /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i, be; - - /* Search file semaphore table */ - for (i = be = 0; i < _FS_LOCK; i++) { - if (Files[i].fs) { /* Existing entry */ - if (Files[i].fs == dp->fs && /* Check if the object matched with an open object */ - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } else { /* Blank entry */ - be = 1; - } - } - if (i == _FS_LOCK) /* The object is not opened */ - return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES; /* Is there a blank entry for new object? */ - - /* The object has been opened. Reject any open against writing file and all write mode open */ - return (acc || Files[i].ctr == 0x100) ? FR_LOCKED : FR_OK; -} - - -static -int enq_lock (void) /* Check if an entry is available for a new object */ -{ - UINT i; - - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - return (i == _FS_LOCK) ? 0 : 1; -} - - -static -UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */ - DIR* dp, /* Directory object pointing the file to register or increment */ - int acc /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */ -) -{ - UINT i; - - - for (i = 0; i < _FS_LOCK; i++) { /* Find the object */ - if (Files[i].fs == dp->fs && - Files[i].clu == dp->sclust && - Files[i].idx == dp->index) break; - } - - if (i == _FS_LOCK) { /* Not opened. Register it as new. */ - for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ; - if (i == _FS_LOCK) return 0; /* No free entry to register (int err) */ - Files[i].fs = dp->fs; - Files[i].clu = dp->sclust; - Files[i].idx = dp->index; - Files[i].ctr = 0; - } - - if (acc && Files[i].ctr) return 0; /* Access violation (int err) */ - - Files[i].ctr = acc ? 0x100 : Files[i].ctr + 1; /* Set semaphore value */ - - return i + 1; -} - - -static -FRESULT dec_lock ( /* Decrement object open counter */ - UINT i /* Semaphore index (1..) */ -) -{ - WORD n; - FRESULT res; - - - if (--i < _FS_LOCK) { /* Shift index number origin from 0 */ - n = Files[i].ctr; - if (n == 0x100) n = 0; /* If write mode open, delete the entry */ - if (n) n--; /* Decrement read mode open count */ - Files[i].ctr = n; - if (!n) Files[i].fs = 0; /* Delete the entry if open count gets zero */ - res = FR_OK; - } else { - res = FR_INT_ERR; /* Invalid index nunber */ - } - return res; -} - - -static -void clear_lock ( /* Clear lock entries of the volume */ - FATFS *fs -) -{ - UINT i; - - for (i = 0; i < _FS_LOCK; i++) { - if (Files[i].fs == fs) Files[i].fs = 0; - } -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Move/Flush disk access window in the file system object */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_window ( - FATFS* fs /* File system object */ -) -{ - DWORD wsect; - UINT nf; - - - if (fs->wflag) { /* Write back the sector if it is dirty */ - wsect = fs->winsect; /* Current sector number */ - if (disk_write(fs->drv, fs->win, wsect, 1)) - return FR_DISK_ERR; - fs->wflag = 0; - if (wsect - fs->fatbase < fs->fsize) { /* Is it in the FAT area? */ - for (nf = fs->n_fats; nf >= 2; nf--) { /* Reflect the change to all FAT copies */ - wsect += fs->fsize; - disk_write(fs->drv, fs->win, wsect, 1); - } - } - } - return FR_OK; -} -#endif - - -static -FRESULT move_window ( - FATFS* fs, /* File system object */ - DWORD sector /* Sector number to make appearance in the fs->win[] */ -) -{ - if (sector != fs->winsect) { /* Changed current window */ -#if !_FS_READONLY - if (sync_window(fs) != FR_OK) - return FR_DISK_ERR; -#endif - if (disk_read(fs->drv, fs->win, sector, 1)) - return FR_DISK_ERR; - fs->winsect = sector; - } - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize file system and strage device */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT sync_fs ( /* FR_OK: successful, FR_DISK_ERR: failed */ - FATFS* fs /* File system object */ -) -{ - FRESULT res; - - - res = sync_window(fs); - if (res == FR_OK) { - /* Update FSINFO sector if needed */ - if (fs->fs_type == FS_FAT32 && fs->fsi_flag == 1) { - /* Create FSINFO structure */ - mem_set(fs->win, 0, SS(fs)); - ST_WORD(fs->win+BS_55AA, 0xAA55); - ST_DWORD(fs->win+FSI_LeadSig, 0x41615252); - ST_DWORD(fs->win+FSI_StrucSig, 0x61417272); - ST_DWORD(fs->win+FSI_Free_Count, fs->free_clust); - ST_DWORD(fs->win+FSI_Nxt_Free, fs->last_clust); - /* Write it into the FSINFO sector */ - fs->winsect = fs->volbase + 1; - disk_write(fs->drv, fs->win, fs->winsect, 1); - fs->fsi_flag = 0; - } - /* Make sure that no pending write process in the physical drive */ - if (disk_ioctl(fs->drv, CTRL_SYNC, 0) != RES_OK) - res = FR_DISK_ERR; - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Get sector# from cluster# */ -/*-----------------------------------------------------------------------*/ - - -DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to be converted */ -) -{ - clst -= 2; - if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ - return clst * fs->csize + fs->database; -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Read value of a FAT entry */ -/*-----------------------------------------------------------------------*/ - - -DWORD get_fat ( /* 0xFFFFFFFF:Disk error, 1:Internal error, Else:Cluster status */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to get the link information */ -) -{ - UINT wc, bc; - BYTE *p; - - - if (clst < 2 || clst >= fs->n_fatent) /* Check range */ - return 1; - - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - if (move_window(fs, fs->fatbase + (bc / SS(fs)))) break; - wc = fs->win[bc % SS(fs)]; bc++; - if (move_window(fs, fs->fatbase + (bc / SS(fs)))) break; - wc |= fs->win[bc % SS(fs)] << 8; - return clst & 1 ? wc >> 4 : (wc & 0xFFF); - - case FS_FAT16 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 2)))) break; - p = &fs->win[clst * 2 % SS(fs)]; - return LD_WORD(p); - - case FS_FAT32 : - if (move_window(fs, fs->fatbase + (clst / (SS(fs) / 4)))) break; - p = &fs->win[clst * 4 % SS(fs)]; - return LD_DWORD(p) & 0x0FFFFFFF; - - default: - return 1; - } - - return 0xFFFFFFFF; /* An error occurred at the disk I/O layer */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* FAT access - Change value of a FAT entry */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY - -FRESULT put_fat ( - FATFS* fs, /* File system object */ - DWORD clst, /* Cluster# to be changed in range of 2 to fs->n_fatent - 1 */ - DWORD val /* New value to mark the cluster */ -) -{ - UINT bc; - BYTE *p; - FRESULT res; - - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - switch (fs->fs_type) { - case FS_FAT12 : - bc = (UINT)clst; bc += bc / 2; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? ((*p & 0x0F) | ((BYTE)val << 4)) : (BYTE)val; - bc++; - fs->wflag = 1; - res = move_window(fs, fs->fatbase + (bc / SS(fs))); - if (res != FR_OK) break; - p = &fs->win[bc % SS(fs)]; - *p = (clst & 1) ? (BYTE)(val >> 4) : ((*p & 0xF0) | ((BYTE)(val >> 8) & 0x0F)); - break; - - case FS_FAT16 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 2))); - if (res != FR_OK) break; - p = &fs->win[clst * 2 % SS(fs)]; - ST_WORD(p, (WORD)val); - break; - - case FS_FAT32 : - res = move_window(fs, fs->fatbase + (clst / (SS(fs) / 4))); - if (res != FR_OK) break; - p = &fs->win[clst * 4 % SS(fs)]; - val |= LD_DWORD(p) & 0xF0000000; - ST_DWORD(p, val); - break; - - default : - res = FR_INT_ERR; - } - fs->wflag = 1; - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Remove a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT remove_chain ( - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to remove a chain from */ -) -{ - FRESULT res; - DWORD nxt; -#if _USE_ERASE - DWORD scl = clst, ecl = clst, rt[2]; -#endif - - if (clst < 2 || clst >= fs->n_fatent) { /* Check range */ - res = FR_INT_ERR; - - } else { - res = FR_OK; - while (clst < fs->n_fatent) { /* Not a last link? */ - nxt = get_fat(fs, clst); /* Get cluster status */ - if (nxt == 0) break; /* Empty cluster? */ - if (nxt == 1) { res = FR_INT_ERR; break; } /* Internal error? */ - if (nxt == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } /* Disk error? */ - res = put_fat(fs, clst, 0); /* Mark the cluster "empty" */ - if (res != FR_OK) break; - if (fs->free_clust != 0xFFFFFFFF) { /* Update FSINFO */ - fs->free_clust++; - fs->fsi_flag |= 1; - } -#if _USE_ERASE - if (ecl + 1 == nxt) { /* Is next cluster contiguous? */ - ecl = nxt; - } else { /* End of contiguous clusters */ - rt[0] = clust2sect(fs, scl); /* Start sector */ - rt[1] = clust2sect(fs, ecl) + fs->csize - 1; /* End sector */ - disk_ioctl(fs->drv, CTRL_ERASE_SECTOR, rt); /* Erase the block */ - scl = ecl = nxt; - } -#endif - clst = nxt; /* Next cluster */ - } - } - - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Stretch or Create a cluster chain */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -DWORD create_chain ( /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */ - FATFS* fs, /* File system object */ - DWORD clst /* Cluster# to stretch. 0 means create a new chain. */ -) -{ - DWORD cs, ncl, scl; - FRESULT res; - - - if (clst == 0) { /* Create a new chain */ - scl = fs->last_clust; /* Get suggested start point */ - if (!scl || scl >= fs->n_fatent) scl = 1; - } - else { /* Stretch the current chain */ - cs = get_fat(fs, clst); /* Check the cluster status */ - if (cs < 2) return 1; /* Invalid value */ - if (cs == 0xFFFFFFFF) return cs; /* A disk error occurred */ - if (cs < fs->n_fatent) return cs; /* It is already followed by next cluster */ - scl = clst; - } - - ncl = scl; /* Start cluster */ - for (;;) { - ncl++; /* Next cluster */ - if (ncl >= fs->n_fatent) { /* Check wrap around */ - ncl = 2; - if (ncl > scl) return 0; /* No free cluster */ - } - cs = get_fat(fs, ncl); /* Get the cluster status */ - if (cs == 0) break; /* Found a free cluster */ - if (cs == 0xFFFFFFFF || cs == 1)/* An error occurred */ - return cs; - if (ncl == scl) return 0; /* No free cluster */ - } - - res = put_fat(fs, ncl, 0x0FFFFFFF); /* Mark the new cluster "last link" */ - if (res == FR_OK && clst != 0) { - res = put_fat(fs, clst, ncl); /* Link it to the previous one if needed */ - } - if (res == FR_OK) { - fs->last_clust = ncl; /* Update FSINFO */ - if (fs->free_clust != 0xFFFFFFFF) { - fs->free_clust--; - fs->fsi_flag |= 1; - } - } else { - ncl = (res == FR_DISK_ERR) ? 0xFFFFFFFF : 1; - } - - return ncl; /* Return new cluster number or error code */ -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* FAT handling - Convert offset into cluster with link map table */ -/*-----------------------------------------------------------------------*/ - -#if _USE_FASTSEEK -static -DWORD clmt_clust ( /* <2:Error, >=2:Cluster number */ - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File offset to be converted to cluster# */ -) -{ - DWORD cl, ncl, *tbl; - - - tbl = fp->cltbl + 1; /* Top of CLMT */ - cl = ofs / SS(fp->fs) / fp->fs->csize; /* Cluster order from top of the file */ - for (;;) { - ncl = *tbl++; /* Number of cluters in the fragment */ - if (!ncl) return 0; /* End of table? (error) */ - if (cl < ncl) break; /* In this fragment? */ - cl -= ncl; tbl++; /* Next fragment */ - } - return cl + *tbl; /* Return the cluster number */ -} -#endif /* _USE_FASTSEEK */ - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Set directory index */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_sdi ( - DIR* dp, /* Pointer to directory object */ - UINT idx /* Index of directory table */ -) -{ - DWORD clst, sect; - UINT ic; - - - dp->index = (WORD)idx; /* Current index */ - clst = dp->sclust; /* Table start cluster (0:root) */ - if (clst == 1 || clst >= dp->fs->n_fatent) /* Check start cluster range */ - return FR_INT_ERR; - if (!clst && dp->fs->fs_type == FS_FAT32) /* Replace cluster# 0 with root cluster# if in FAT32 */ - clst = dp->fs->dirbase; - - if (clst == 0) { /* Static table (root-directory in FAT12/16) */ - if (idx >= dp->fs->n_rootdir) /* Is index out of range? */ - return FR_INT_ERR; - sect = dp->fs->dirbase; - } - else { /* Dynamic table (root-directory in FAT32 or sub-directory) */ - ic = SS(dp->fs) / SZ_DIR * dp->fs->csize; /* Entries per cluster */ - while (idx >= ic) { /* Follow cluster chain */ - clst = get_fat(dp->fs, clst); /* Get next cluster */ - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; /* Disk error */ - if (clst < 2 || clst >= dp->fs->n_fatent) /* Reached to end of table or internal error */ - return FR_INT_ERR; - idx -= ic; - } - sect = clust2sect(dp->fs, clst); - } - dp->clust = clst; /* Current cluster# */ - if (!sect) return FR_INT_ERR; - dp->sect = sect + idx / (SS(dp->fs) / SZ_DIR); /* Sector# of the directory entry */ - dp->dir = dp->fs->win + (idx % (SS(dp->fs) / SZ_DIR)) * SZ_DIR; /* Ptr to the entry in the sector */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Move directory table index next */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */ - DIR* dp, /* Pointer to the directory object */ - int stretch /* 0: Do not stretch table, 1: Stretch table if needed */ -) -{ - DWORD clst; - UINT i; - - - i = dp->index + 1; - if (!(i & 0xFFFF) || !dp->sect) /* Report EOT when index has reached 65535 */ - return FR_NO_FILE; - - if (!(i % (SS(dp->fs) / SZ_DIR))) { /* Sector changed? */ - dp->sect++; /* Next sector */ - - if (!dp->clust) { /* Static table */ - if (i >= dp->fs->n_rootdir) /* Report EOT if it reached end of static table */ - return FR_NO_FILE; - } - else { /* Dynamic table */ - if (((i / (SS(dp->fs) / SZ_DIR)) & (dp->fs->csize - 1)) == 0) { /* Cluster changed? */ - clst = get_fat(dp->fs, dp->clust); /* Get next cluster */ - if (clst <= 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - if (clst >= dp->fs->n_fatent) { /* If it reached end of dynamic table, */ -#if !_FS_READONLY - UINT c; - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT */ - clst = create_chain(dp->fs, dp->clust); /* Stretch cluster chain */ - if (clst == 0) return FR_DENIED; /* No free cluster */ - if (clst == 1) return FR_INT_ERR; - if (clst == 0xFFFFFFFF) return FR_DISK_ERR; - /* Clean-up stretched table */ - if (sync_window(dp->fs)) return FR_DISK_ERR;/* Flush disk access window */ - mem_set(dp->fs->win, 0, SS(dp->fs)); /* Clear window buffer */ - dp->fs->winsect = clust2sect(dp->fs, clst); /* Cluster start sector */ - for (c = 0; c < dp->fs->csize; c++) { /* Fill the new cluster with 0 */ - dp->fs->wflag = 1; - if (sync_window(dp->fs)) return FR_DISK_ERR; - dp->fs->winsect++; - } - dp->fs->winsect -= c; /* Rewind window offset */ -#else - if (!stretch) return FR_NO_FILE; /* If do not stretch, report EOT (this is to suppress warning) */ - return FR_NO_FILE; /* Report EOT */ -#endif - } - dp->clust = clst; /* Initialize data for new cluster */ - dp->sect = clust2sect(dp->fs, clst); - } - } - } - - dp->index = (WORD)i; /* Current index */ - dp->dir = dp->fs->win + (i % (SS(dp->fs) / SZ_DIR)) * SZ_DIR; /* Current entry in the window */ - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Reserve directory entry */ -/*-----------------------------------------------------------------------*/ - -#if !_FS_READONLY -static -FRESULT dir_alloc ( - DIR* dp, /* Pointer to the directory object */ - UINT nent /* Number of contiguous entries to allocate (1-21) */ -) -{ - FRESULT res; - UINT n; - - - res = dir_sdi(dp, 0); - if (res == FR_OK) { - n = 0; - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - if (dp->dir[0] == DDE || dp->dir[0] == 0) { /* Is it a blank entry? */ - if (++n == nent) break; /* A block of contiguous entries is found */ - } else { - n = 0; /* Not a blank entry. Restart to search */ - } - res = dir_next(dp, 1); /* Next entry with table stretch enabled */ - } while (res == FR_OK); - } - if (res == FR_NO_FILE) res = FR_DENIED; /* No directory entry to allocate */ - return res; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Load/Store start cluster number */ -/*-----------------------------------------------------------------------*/ - -static -DWORD ld_clust ( - FATFS* fs, /* Pointer to the fs object */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - DWORD cl; - - cl = LD_WORD(dir+DIR_FstClusLO); - if (fs->fs_type == FS_FAT32) - cl |= (DWORD)LD_WORD(dir+DIR_FstClusHI) << 16; - - return cl; -} - - -#if !_FS_READONLY -static -void st_clust ( - BYTE* dir, /* Pointer to the directory entry */ - DWORD cl /* Value to be set */ -) -{ - ST_WORD(dir+DIR_FstClusLO, cl); - ST_WORD(dir+DIR_FstClusHI, cl >> 16); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30}; /* Offset of LFN characters in the directory entry */ - - -static -int cmp_lfn ( /* 1:Matched, 0:Not matched */ - WCHAR* lfnbuf, /* Pointer to the LFN to be compared */ - BYTE* dir /* Pointer to the directory entry containing a part of LFN */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & ~LLE) - 1) * 13; /* Get offset in the LFN buffer */ - s = 0; wc = 1; - do { - uc = LD_WORD(dir+LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - wc = ff_wtoupper(uc); /* Convert it to upper case */ - if (i >= _MAX_LFN || wc != ff_wtoupper(lfnbuf[i++])) /* Compare it */ - return 0; /* Not matched */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Repeat until all characters in the entry are checked */ - - if ((dir[LDIR_Ord] & LLE) && wc && lfnbuf[i]) /* Last segment matched but different length */ - return 0; - - return 1; /* The part of LFN matched */ -} - - - -static -int pick_lfn ( /* 1:Succeeded, 0:Buffer overflow */ - WCHAR* lfnbuf, /* Pointer to the Unicode-LFN buffer */ - BYTE* dir /* Pointer to the directory entry */ -) -{ - UINT i, s; - WCHAR wc, uc; - - - i = ((dir[LDIR_Ord] & 0x3F) - 1) * 13; /* Offset in the LFN buffer */ - - s = 0; wc = 1; - do { - uc = LD_WORD(dir+LfnOfs[s]); /* Pick an LFN character from the entry */ - if (wc) { /* Last character has not been processed */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i++] = wc = uc; /* Store it */ - } else { - if (uc != 0xFFFF) return 0; /* Check filler */ - } - } while (++s < 13); /* Read all character in the entry */ - - if (dir[LDIR_Ord] & LLE) { /* Put terminator if it is the last LFN part */ - if (i >= _MAX_LFN) return 0; /* Buffer overflow? */ - lfnbuf[i] = 0; - } - - return 1; -} - - -#if !_FS_READONLY -static -void fit_lfn ( - const WCHAR* lfnbuf, /* Pointer to the LFN buffer */ - BYTE* dir, /* Pointer to the directory entry */ - BYTE ord, /* LFN order (1-20) */ - BYTE sum /* SFN sum */ -) -{ - UINT i, s; - WCHAR wc; - - - dir[LDIR_Chksum] = sum; /* Set check sum */ - dir[LDIR_Attr] = AM_LFN; /* Set attribute. LFN entry */ - dir[LDIR_Type] = 0; - ST_WORD(dir+LDIR_FstClusLO, 0); - - i = (ord - 1) * 13; /* Get offset in the LFN buffer */ - s = wc = 0; - do { - if (wc != 0xFFFF) wc = lfnbuf[i++]; /* Get an effective character */ - ST_WORD(dir+LfnOfs[s], wc); /* Put it */ - if (!wc) wc = 0xFFFF; /* Padding characters following last character */ - } while (++s < 13); - if (wc == 0xFFFF || !lfnbuf[i]) ord |= LLE; /* Bottom LFN part is the start of LFN sequence */ - dir[LDIR_Ord] = ord; /* Set the LFN order */ -} - -#endif -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Create numbered name */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -void gen_numname ( - BYTE* dst, /* Pointer to the buffer to store numbered SFN */ - const BYTE* src, /* Pointer to SFN */ - const WCHAR* lfn, /* Pointer to LFN */ - UINT seq /* Sequence number */ -) -{ - BYTE ns[8], c; - UINT i, j; - - - mem_cpy(dst, src, 11); - - if (seq > 5) { /* On many collisions, generate a hash number instead of sequential number */ - WCHAR wc; - DWORD sr = seq; - - while (*lfn) { /* Create a CRC */ - wc = *lfn++; - for (i = 0; i < 16; i++) { - sr = (sr << 1) + (wc & 1); - wc >>= 1; - if (sr & 0x10000) sr ^= 0x11021; - } - } - seq = (UINT)sr; - } - - /* itoa (hexdecimal) */ - i = 7; - do { - c = (seq % 16) + '0'; - if (c > '9') c += 7; - ns[i--] = c; - seq /= 16; - } while (seq); - ns[i] = '~'; - - /* Append the number */ - for (j = 0; j < i && dst[j] != ' '; j++) { - if (IsDBCS1(dst[j])) { - if (j == i - 1) break; - j++; - } - } - do { - dst[j++] = (i < 8) ? ns[i++] : ' '; - } while (j < 8); -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Calculate sum of an SFN */ -/*-----------------------------------------------------------------------*/ -#if _USE_LFN -static -BYTE sum_sfn ( - const BYTE* dir /* Pointer to the SFN entry */ -) -{ - BYTE sum = 0; - UINT n = 11; - - do sum = (sum >> 1) + (sum << 7) + *dir++; while (--n); - return sum; -} -#endif - - - - -/*-----------------------------------------------------------------------*/ -/* Directory handling - Find an object in the directory */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT dir_find ( - DIR* dp /* Pointer to the directory object linked to the file name */ -) -{ - FRESULT res; - BYTE c, *dir; -#if _USE_LFN - BYTE a, ord, sum; -#endif - - res = dir_sdi(dp, 0); /* Rewind directory object */ - if (res != FR_OK) return res; - -#if _USE_LFN - ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ -#endif - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ -#if _USE_LFN /* LFN configuration */ - a = dir[DIR_Attr] & AM_MASK; - if (c == DDE || ((a & AM_VOL) && a != AM_LFN)) { /* An entry without valid data */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (dp->lfn) { - if (c & LLE) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLE; ord = c; /* LFN start order */ - dp->lfn_idx = dp->index; /* Start index of LFN */ - } - /* Check validity of the LFN entry and compare it with given name */ - ord = (c == ord && sum == dir[LDIR_Chksum] && cmp_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } - } else { /* An SFN entry is found */ - if (!ord && sum == sum_sfn(dir)) break; /* LFN matched? */ - if (!(dp->fn[NS] & NS_LOSS) && !mem_cmp(dir, dp->fn, 11)) break; /* SFN matched? */ - ord = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */ - } - } -#else /* Non LFN configuration */ - if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dp->fn, 11)) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 -static -FRESULT dir_read ( - DIR* dp, /* Pointer to the directory object */ - int vol /* Filtered by 0:file/directory or 1:volume label */ -) -{ - FRESULT res; - BYTE a, c, *dir; -#if _USE_LFN - BYTE ord = 0xFF, sum = 0xFF; -#endif - - res = FR_NO_FILE; - while (dp->sect) { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - dir = dp->dir; /* Ptr to the directory entry of current index */ - c = dir[DIR_Name]; - if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ - a = dir[DIR_Attr] & AM_MASK; -#if _USE_LFN /* LFN configuration */ - if (c == DDE || (!_FS_RPATH && c == '.') || (int)(a == AM_VOL) != vol) { /* An entry without valid data */ - ord = 0xFF; - } else { - if (a == AM_LFN) { /* An LFN entry is found */ - if (c & LLE) { /* Is it start of LFN sequence? */ - sum = dir[LDIR_Chksum]; - c &= ~LLE; ord = c; - dp->lfn_idx = dp->index; - } - /* Check LFN validity and capture it */ - ord = (c == ord && sum == dir[LDIR_Chksum] && pick_lfn(dp->lfn, dir)) ? ord - 1 : 0xFF; - } else { /* An SFN entry is found */ - if (ord || sum != sum_sfn(dir)) /* Is there a valid LFN? */ - dp->lfn_idx = 0xFFFF; /* It has no LFN. */ - break; - } - } -#else /* Non LFN configuration */ - if (c != DDE && (_FS_RPATH || c != '.') && a != AM_LFN && (int)(a == AM_VOL) == vol) /* Is it a valid entry? */ - break; -#endif - res = dir_next(dp, 0); /* Next entry */ - if (res != FR_OK) break; - } - - if (res != FR_OK) dp->sect = 0; - - return res; -} -#endif /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */ - - - - -/*-----------------------------------------------------------------------*/ -/* Register an object to the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY -static -FRESULT dir_register ( /* FR_OK:Successful, FR_DENIED:No free entry or too many SFN collision, FR_DISK_ERR:Disk error */ - DIR* dp /* Target directory with object name to be created */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT n, nent; - BYTE sn[12], *fn, sum; - WCHAR *lfn; - - - fn = dp->fn; lfn = dp->lfn; - mem_cpy(sn, fn, 12); - - if (_FS_RPATH && (sn[NS] & NS_DOT)) /* Cannot create dot entry */ - return FR_INVALID_NAME; - - if (sn[NS] & NS_LOSS) { /* When LFN is out of 8.3 format, generate a numbered name */ - fn[NS] = 0; dp->lfn = 0; /* Find only SFN */ - for (n = 1; n < 100; n++) { - gen_numname(fn, sn, lfn, n); /* Generate a numbered name */ - res = dir_find(dp); /* Check if the name collides with existing SFN */ - if (res != FR_OK) break; - } - if (n == 100) return FR_DENIED; /* Abort if too many collisions */ - if (res != FR_NO_FILE) return res; /* Abort if the result is other than 'not collided' */ - fn[NS] = sn[NS]; dp->lfn = lfn; - } - - if (sn[NS] & NS_LFN) { /* When LFN is to be created, allocate entries for an SFN + LFNs. */ - for (n = 0; lfn[n]; n++) ; - nent = (n + 25) / 13; - } else { /* Otherwise allocate an entry for an SFN */ - nent = 1; - } - res = dir_alloc(dp, nent); /* Allocate entries */ - - if (res == FR_OK && --nent) { /* Set LFN entry if needed */ - res = dir_sdi(dp, dp->index - nent); - if (res == FR_OK) { - sum = sum_sfn(dp->fn); /* Sum value of the SFN tied to the LFN */ - do { /* Store LFN entries in bottom first */ - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - fit_lfn(dp->lfn, dp->dir, (BYTE)nent, sum); - dp->fs->wflag = 1; - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK && --nent); - } - } -#else /* Non LFN configuration */ - res = dir_alloc(dp, 1); /* Allocate an entry for SFN */ -#endif - - if (res == FR_OK) { /* Set SFN entry */ - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIR); /* Clean the entry */ - mem_cpy(dp->dir, dp->fn, 11); /* Put SFN */ -#if _USE_LFN - dp->dir[DIR_NTres] = dp->fn[NS] & (NS_BODY | NS_EXT); /* Put NT flag */ -#endif - dp->fs->wflag = 1; - } - } - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Remove an object from the directory */ -/*-----------------------------------------------------------------------*/ -#if !_FS_READONLY && !_FS_MINIMIZE -static -FRESULT dir_remove ( /* FR_OK: Successful, FR_DISK_ERR: A disk error */ - DIR* dp /* Directory object pointing the entry to be removed */ -) -{ - FRESULT res; -#if _USE_LFN /* LFN configuration */ - UINT i; - - i = dp->index; /* SFN index */ - res = dir_sdi(dp, (dp->lfn_idx == 0xFFFF) ? i : dp->lfn_idx); /* Goto the SFN or top of the LFN entries */ - if (res == FR_OK) { - do { - res = move_window(dp->fs, dp->sect); - if (res != FR_OK) break; - mem_set(dp->dir, 0, SZ_DIR); /* Clear and mark the entry "deleted" */ - *dp->dir = DDE; - dp->fs->wflag = 1; - if (dp->index >= i) break; /* When reached SFN, all entries of the object has been deleted. */ - res = dir_next(dp, 0); /* Next entry */ - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR; - } - -#else /* Non LFN configuration */ - res = dir_sdi(dp, dp->index); - if (res == FR_OK) { - res = move_window(dp->fs, dp->sect); - if (res == FR_OK) { - mem_set(dp->dir, 0, SZ_DIR); /* Clear and mark the entry "deleted" */ - *dp->dir = DDE; - dp->fs->wflag = 1; - } - } -#endif - - return res; -} -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Get file information from directory entry */ -/*-----------------------------------------------------------------------*/ -#if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 -static -void get_fileinfo ( /* No return code */ - DIR* dp, /* Pointer to the directory object */ - FILINFO* fno /* Pointer to the file information to be filled */ -) -{ - UINT i; - TCHAR *p, c; - - - p = fno->fname; - if (dp->sect) { /* Get SFN */ - BYTE *dir = dp->dir; - - i = 0; - while (i < 11) { /* Copy name body and extension */ - c = (TCHAR)dir[i++]; - if (c == ' ') continue; /* Skip padding spaces */ - if (c == NDDE) c = (TCHAR)DDE; /* Restore replaced DDE character */ - if (i == 9) *p++ = '.'; /* Insert a . if extension is exist */ -#if _USE_LFN - if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY))) - c += 0x20; /* To lower */ -#if _LFN_UNICODE - if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i])) - c = c << 8 | dir[i++]; - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#endif - *p++ = c; - } - fno->fattrib = dir[DIR_Attr]; /* Attribute */ - fno->fsize = LD_DWORD(dir+DIR_FileSize); /* Size */ - fno->fdate = LD_WORD(dir+DIR_WrtDate); /* Date */ - fno->ftime = LD_WORD(dir+DIR_WrtTime); /* Time */ - } - *p = 0; /* Terminate SFN string by a \0 */ - -#if _USE_LFN - if (fno->lfname) { - WCHAR w, *lfn; - - i = 0; p = fno->lfname; - if (dp->sect && fno->lfsize && dp->lfn_idx != 0xFFFF) { /* Get LFN if available */ - lfn = dp->lfn; - while ((w = *lfn++) != 0) { /* Get an LFN character */ -#if !_LFN_UNICODE - w = ff_convert(w, 0); /* Unicode -> OEM */ - if (!w) { i = 0; break; } /* No LFN if it could not be converted */ - if (_DF1S && w >= 0x100) /* Put 1st byte if it is a DBC (always false on SBCS cfg) */ - p[i++] = (TCHAR)(w >> 8); -#endif - if (i >= fno->lfsize - 1) { i = 0; break; } /* No LFN if buffer overflow */ - p[i++] = (TCHAR)w; - } - } - p[i] = 0; /* Terminate LFN string by a \0 */ - } -#endif -} -#endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2*/ - - - - -/*-----------------------------------------------------------------------*/ -/* Pick a segment and create the object name in directory form */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT create_name ( - DIR* dp, /* Pointer to the directory object */ - const TCHAR** path /* Pointer to pointer to the segment in the path string */ -) -{ -#if _USE_LFN /* LFN configuration */ - BYTE b, cf; - WCHAR w, *lfn; - UINT i, ni, si, di; - const TCHAR *p; - - /* Create LFN in Unicode */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - lfn = dp->lfn; - si = di = 0; - for (;;) { - w = p[si++]; /* Get a character */ - if (w < ' ' || w == '/' || w == '\\') break; /* Break on end of segment */ - if (di >= _MAX_LFN) /* Reject too long name */ - return FR_INVALID_NAME; -#if !_LFN_UNICODE - w &= 0xFF; - if (IsDBCS1(w)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - b = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(b)) - return FR_INVALID_NAME; /* Reject invalid sequence */ - w = (w << 8) + b; /* Create a DBC */ - } - w = ff_convert(w, 1); /* Convert ANSI/OEM to Unicode */ - if (!w) return FR_INVALID_NAME; /* Reject invalid code */ -#endif - if (w < 0x80 && chk_chr("\"*:<>\?|\x7F", w)) /* Reject illegal characters for LFN */ - return FR_INVALID_NAME; - lfn[di++] = w; /* Store the Unicode character */ - } - *path = &p[si]; /* Return pointer to the next segment */ - cf = (w < ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ -#if _FS_RPATH - if ((di == 1 && lfn[di-1] == '.') || /* Is this a dot entry? */ - (di == 2 && lfn[di-1] == '.' && lfn[di-2] == '.')) { - lfn[di] = 0; - for (i = 0; i < 11; i++) - dp->fn[i] = (i < di) ? '.' : ' '; - dp->fn[i] = cf | NS_DOT; /* This is a dot entry */ - return FR_OK; - } -#endif - while (di) { /* Strip trailing spaces and dots */ - w = lfn[di-1]; - if (w != ' ' && w != '.') break; - di--; - } - if (!di) return FR_INVALID_NAME; /* Reject nul string */ - - lfn[di] = 0; /* LFN is created */ - - /* Create SFN in directory form */ - mem_set(dp->fn, ' ', 11); - for (si = 0; lfn[si] == ' ' || lfn[si] == '.'; si++) ; /* Strip leading spaces and dots */ - if (si) cf |= NS_LOSS | NS_LFN; - while (di && lfn[di - 1] != '.') di--; /* Find extension (di<=si: no extension) */ - - b = i = 0; ni = 8; - for (;;) { - w = lfn[si++]; /* Get an LFN character */ - if (!w) break; /* Break on end of the LFN */ - if (w == ' ' || (w == '.' && si != di)) { /* Remove spaces and dots */ - cf |= NS_LOSS | NS_LFN; continue; - } - - if (i >= ni || si == di) { /* Extension or end of SFN */ - if (ni == 11) { /* Long extension */ - cf |= NS_LOSS | NS_LFN; break; - } - if (si != di) cf |= NS_LOSS | NS_LFN; /* Out of 8.3 format */ - if (si > di) break; /* No extension */ - si = di; i = 8; ni = 11; /* Enter extension section */ - b <<= 2; continue; - } - - if (w >= 0x80) { /* Non ASCII character */ -#ifdef _EXCVT - w = ff_convert(w, 0); /* Unicode -> OEM code */ - if (w) w = ExCvt[w - 0x80]; /* Convert extended character to upper (SBCS) */ -#else - w = ff_convert(ff_wtoupper(w), 0); /* Upper converted Unicode -> OEM code */ -#endif - cf |= NS_LFN; /* Force create LFN entry */ - } - - if (_DF1S && w >= 0x100) { /* Double byte character (always false on SBCS cfg) */ - if (i >= ni - 1) { - cf |= NS_LOSS | NS_LFN; i = ni; continue; - } - dp->fn[i++] = (BYTE)(w >> 8); - } else { /* Single byte character */ - if (!w || chk_chr("+,;=[]", w)) { /* Replace illegal characters for SFN */ - w = '_'; cf |= NS_LOSS | NS_LFN;/* Lossy conversion */ - } else { - if (IsUpper(w)) { /* ASCII large capital */ - b |= 2; - } else { - if (IsLower(w)) { /* ASCII small capital */ - b |= 1; w -= 0x20; - } - } - } - } - dp->fn[i++] = (BYTE)w; - } - - if (dp->fn[0] == DDE) dp->fn[0] = NDDE; /* If the first character collides with deleted mark, replace it with 0x05 */ - - if (ni == 8) b <<= 2; - if ((b & 0x0C) == 0x0C || (b & 0x03) == 0x03) /* Create LFN entry when there are composite capitals */ - cf |= NS_LFN; - if (!(cf & NS_LFN)) { /* When LFN is in 8.3 format without extended character, NT flags are created */ - if ((b & 0x03) == 0x01) cf |= NS_EXT; /* NT flag (Extension has only small capital) */ - if ((b & 0x0C) == 0x04) cf |= NS_BODY; /* NT flag (Filename has only small capital) */ - } - - dp->fn[NS] = cf; /* SFN is created */ - - return FR_OK; - - -#else /* Non-LFN configuration */ - BYTE b, c, d, *sfn; - UINT ni, si, i; - const char *p; - - /* Create file name in directory form */ - for (p = *path; *p == '/' || *p == '\\'; p++) ; /* Strip duplicated separator */ - sfn = dp->fn; - mem_set(sfn, ' ', 11); - si = i = b = 0; ni = 8; -#if _FS_RPATH - if (p[si] == '.') { /* Is this a dot entry? */ - for (;;) { - c = (BYTE)p[si++]; - if (c != '.' || si >= 3) break; - sfn[i++] = c; - } - if (c != '/' && c != '\\' && c > ' ') return FR_INVALID_NAME; - *path = &p[si]; /* Return pointer to the next segment */ - sfn[NS] = (c <= ' ') ? NS_LAST | NS_DOT : NS_DOT; /* Set last segment flag if end of path */ - return FR_OK; - } -#endif - for (;;) { - c = (BYTE)p[si++]; - if (c <= ' ' || c == '/' || c == '\\') break; /* Break on end of segment */ - if (c == '.' || i >= ni) { - if (ni != 8 || c != '.') return FR_INVALID_NAME; - i = 8; ni = 11; - b <<= 2; continue; - } - if (c >= 0x80) { /* Extended character? */ - b |= 3; /* Eliminate NT flag */ -#ifdef _EXCVT - c = ExCvt[c - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else -#if !_DF1S - return FR_INVALID_NAME; /* Reject extended characters (ASCII cfg) */ -#endif -#endif - } - if (IsDBCS1(c)) { /* Check if it is a DBC 1st byte (always false on SBCS cfg) */ - d = (BYTE)p[si++]; /* Get 2nd byte */ - if (!IsDBCS2(d) || i >= ni - 1) /* Reject invalid DBC */ - return FR_INVALID_NAME; - sfn[i++] = c; - sfn[i++] = d; - } else { /* Single byte code */ - if (chk_chr("\"*+,:;<=>\?[]|\x7F", c)) /* Reject illegal chrs for SFN */ - return FR_INVALID_NAME; - if (IsUpper(c)) { /* ASCII large capital? */ - b |= 2; - } else { - if (IsLower(c)) { /* ASCII small capital? */ - b |= 1; c -= 0x20; - } - } - sfn[i++] = c; - } - } - *path = &p[si]; /* Return pointer to the next segment */ - c = (c <= ' ') ? NS_LAST : 0; /* Set last segment flag if end of path */ - - if (!i) return FR_INVALID_NAME; /* Reject nul string */ - if (sfn[0] == DDE) sfn[0] = NDDE; /* When first character collides with DDE, replace it with 0x05 */ - - if (ni == 8) b <<= 2; - if ((b & 0x03) == 0x01) c |= NS_EXT; /* NT flag (Name extension has only small capital) */ - if ((b & 0x0C) == 0x04) c |= NS_BODY; /* NT flag (Name body has only small capital) */ - - sfn[NS] = c; /* Store NT flag, File name is created */ - - return FR_OK; -#endif -} - - - - -/*-----------------------------------------------------------------------*/ -/* Follow a file path */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ - DIR* dp, /* Directory object to return last directory and found object */ - const TCHAR* path /* Full-path string to find a file or directory */ -) -{ - FRESULT res; - BYTE *dir, ns; - - -#if _FS_RPATH - if (*path == '/' || *path == '\\') { /* There is a heading separator */ - path++; dp->sclust = 0; /* Strip it and start from the root directory */ - } else { /* No heading separator */ - dp->sclust = dp->fs->cdir; /* Start from the current directory */ - } -#else - if (*path == '/' || *path == '\\') /* Strip heading separator if exist */ - path++; - dp->sclust = 0; /* Always start from the root directory */ -#endif - - if ((UINT)*path < ' ') { /* Null path name is the origin directory itself */ - res = dir_sdi(dp, 0); - dp->dir = 0; - } else { /* Follow path */ - for (;;) { - res = create_name(dp, &path); /* Get a segment name of the path */ - if (res != FR_OK) break; - res = dir_find(dp); /* Find an object with the sagment name */ - ns = dp->fn[NS]; - if (res != FR_OK) { /* Failed to find the object */ - if (res == FR_NO_FILE) { /* Object is not found */ - if (_FS_RPATH && (ns & NS_DOT)) { /* If dot entry is not exist, */ - dp->sclust = 0; dp->dir = 0; /* it is the root directory and stay there */ - if (!(ns & NS_LAST)) continue; /* Continue to follow if not last segment */ - res = FR_OK; /* Ended at the root directroy. Function completed. */ - } else { /* Could not find the object */ - if (!(ns & NS_LAST)) res = FR_NO_PATH; /* Adjust error code if not last segment */ - } - } - break; - } - if (ns & NS_LAST) break; /* Last segment matched. Function completed. */ - dir = dp->dir; /* Follow the sub-directory */ - if (!(dir[DIR_Attr] & AM_DIR)) { /* It is not a sub-directory and cannot follow */ - res = FR_NO_PATH; break; - } - dp->sclust = ld_clust(dp->fs, dir); - } - } - - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Get logical drive number from path name */ -/*-----------------------------------------------------------------------*/ - -static -int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ - const TCHAR** path /* Pointer to pointer to the path name */ -) -{ - const TCHAR *tp, *tt; - UINT i; - int vol = -1; - - - if (*path) { /* If the pointer is not a null */ - for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ; /* Find ':' in the path */ - if (*tt == ':') { /* If a ':' is exist in the path name */ - tp = *path; - i = *tp++ - '0'; - if (i < 10 && tp == tt) { /* Is there a numeric drive id? */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = ++tt; - } - } else { /* No numeric drive number */ -#if _STR_VOLUME_ID /* Find string drive id */ - static const char* const str[] = {_VOLUME_STRS}; - const char *sp; - char c; - TCHAR tc; - - i = 0; tt++; - do { - sp = str[i]; tp = *path; - do { /* Compare a string drive id with path name */ - c = *sp++; tc = *tp++; - if (IsLower(tc)) tc -= 0x20; - } while (c && (TCHAR)c == tc); - } while ((c || tp != tt) && ++i < _VOLUMES); /* Repeat for each id until pattern match */ - if (i < _VOLUMES) { /* If a drive id is found, get the value and strip it */ - vol = (int)i; - *path = tt; - } -#endif - } - return vol; - } -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - return vol; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load a sector and check if it is an FAT boot sector */ -/*-----------------------------------------------------------------------*/ - -static -BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a boot sector, 3:Disk error */ - FATFS* fs, /* File system object */ - DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ -) -{ - fs->wflag = 0; fs->winsect = 0xFFFFFFFF; /* Invaidate window */ - if (move_window(fs, sect) != FR_OK) /* Load boot record */ - return 3; - - if (LD_WORD(&fs->win[BS_55AA]) != 0xAA55) /* Check boot record signature (always placed at offset 510 even if the sector size is >512) */ - return 2; - - if ((LD_DWORD(&fs->win[BS_FilSysType]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - if ((LD_DWORD(&fs->win[BS_FilSysType32]) & 0xFFFFFF) == 0x544146) /* Check "FAT" string */ - return 0; - - return 1; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Find logical drive and check if the volume is mounted */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ - FATFS** rfs, /* Pointer to pointer to the found file system object */ - const TCHAR** path, /* Pointer to pointer to the path name (drive number) */ - BYTE wmode /* !=0: Check write protection for write access */ -) -{ - BYTE fmt; - int vol; - DSTATUS stat; - DWORD bsect, fasize, tsect, sysect, nclst, szbfat; - WORD nrsv; - FATFS *fs; - - - /* Get logical drive number from the path name */ - *rfs = 0; - vol = get_ldnumber(path); - if (vol < 0) return FR_INVALID_DRIVE; - - /* Check if the file system object is valid or not */ - fs = FatFs[vol]; /* Get pointer to the file system object */ - if (!fs) return FR_NOT_ENABLED; /* Is the file system object available? */ - - ENTER_FF(fs); /* Lock the volume */ - *rfs = fs; /* Return pointer to the file system object */ - - if (fs->fs_type) { /* If the volume has been mounted */ - stat = disk_status(fs->drv); - if (!(stat & STA_NOINIT)) { /* and the physical drive is kept initialized */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check write protection if needed */ - return FR_WRITE_PROTECTED; - return FR_OK; /* The file system object is valid */ - } - } - - /* The file system object is not valid. */ - /* Following code attempts to mount the volume. (analyze BPB and initialize the fs object) */ - - fs->fs_type = 0; /* Clear the file system object */ - fs->drv = LD2PD(vol); /* Bind the logical drive and a physical drive */ - stat = disk_initialize(fs->drv); /* Initialize the physical drive */ - if (stat & STA_NOINIT) /* Check if the initialization succeeded */ - return FR_NOT_READY; /* Failed to initialize due to no medium or hard error */ - if (!_FS_READONLY && wmode && (stat & STA_PROTECT)) /* Check disk write protection if needed */ - return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get sector size (multiple sector size cfg only) */ - if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK - || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR; -#endif - /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */ - bsect = 0; - fmt = check_fs(fs, bsect); /* Load sector 0 and check if it is an FAT boot sector as SFD */ - if (fmt == 1 || (!fmt && (LD2PT(vol)))) { /* Not an FAT boot sector or forced partition number */ - UINT i; - DWORD br[4]; - - for (i = 0; i < 4; i++) { /* Get partition offset */ - BYTE *pt = fs->win+MBR_Table + i * SZ_PTE; - br[i] = pt[4] ? LD_DWORD(&pt[8]) : 0; - } - i = LD2PT(vol); /* Partition number: 0:auto, 1-4:forced */ - if (i) i--; - do { /* Find an FAT volume */ - bsect = br[i]; - fmt = bsect ? check_fs(fs, bsect) : 2; /* Check the partition */ - } while (!LD2PT(vol) && fmt && ++i < 4); - } - if (fmt == 3) return FR_DISK_ERR; /* An error occured in the disk I/O layer */ - if (fmt) return FR_NO_FILESYSTEM; /* No FAT volume is found */ - - /* An FAT volume is found. Following code initializes the file system object */ - - if (LD_WORD(fs->win+BPB_BytsPerSec) != SS(fs)) /* (BPB_BytsPerSec must be equal to the physical sector size) */ - return FR_NO_FILESYSTEM; - - fasize = LD_WORD(fs->win+BPB_FATSz16); /* Number of sectors per FAT */ - if (!fasize) fasize = LD_DWORD(fs->win+BPB_FATSz32); - fs->fsize = fasize; - - fs->n_fats = fs->win[BPB_NumFATs]; /* Number of FAT copies */ - if (fs->n_fats != 1 && fs->n_fats != 2) /* (Must be 1 or 2) */ - return FR_NO_FILESYSTEM; - fasize *= fs->n_fats; /* Number of sectors for FAT area */ - - fs->csize = fs->win[BPB_SecPerClus]; /* Number of sectors per cluster */ - if (!fs->csize || (fs->csize & (fs->csize - 1))) /* (Must be power of 2) */ - return FR_NO_FILESYSTEM; - - fs->n_rootdir = LD_WORD(fs->win+BPB_RootEntCnt); /* Number of root directory entries */ - if (fs->n_rootdir % (SS(fs) / SZ_DIR)) /* (Must be sector aligned) */ - return FR_NO_FILESYSTEM; - - tsect = LD_WORD(fs->win+BPB_TotSec16); /* Number of sectors on the volume */ - if (!tsect) tsect = LD_DWORD(fs->win+BPB_TotSec32); - - nrsv = LD_WORD(fs->win+BPB_RsvdSecCnt); /* Number of reserved sectors */ - if (!nrsv) return FR_NO_FILESYSTEM; /* (Must not be 0) */ - - /* Determine the FAT sub type */ - sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIR); /* RSV+FAT+DIR */ - if (tsect < sysect) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - nclst = (tsect - sysect) / fs->csize; /* Number of clusters */ - if (!nclst) return FR_NO_FILESYSTEM; /* (Invalid volume size) */ - fmt = FS_FAT12; - if (nclst >= MIN_FAT16) fmt = FS_FAT16; - if (nclst >= MIN_FAT32) fmt = FS_FAT32; - - /* Boundaries and Limits */ - fs->n_fatent = nclst + 2; /* Number of FAT entries */ - fs->volbase = bsect; /* Volume start sector */ - fs->fatbase = bsect + nrsv; /* FAT start sector */ - fs->database = bsect + sysect; /* Data start sector */ - if (fmt == FS_FAT32) { - if (fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must be 0) */ - fs->dirbase = LD_DWORD(fs->win+BPB_RootClus); /* Root directory start cluster */ - szbfat = fs->n_fatent * 4; /* (Needed FAT size) */ - } else { - if (!fs->n_rootdir) return FR_NO_FILESYSTEM; /* (BPB_RootEntCnt must not be 0) */ - fs->dirbase = fs->fatbase + fasize; /* Root directory start sector */ - szbfat = (fmt == FS_FAT16) ? /* (Needed FAT size) */ - fs->n_fatent * 2 : fs->n_fatent * 3 / 2 + (fs->n_fatent & 1); - } - if (fs->fsize < (szbfat + (SS(fs) - 1)) / SS(fs)) /* (BPB_FATSz must not be less than needed) */ - return FR_NO_FILESYSTEM; - -#if !_FS_READONLY - /* Initialize cluster allocation information */ - fs->last_clust = fs->free_clust = 0xFFFFFFFF; - - /* Get fsinfo if available */ - fs->fsi_flag = 0x80; -#if (_FS_NOFSINFO & 3) != 3 - if (fmt == FS_FAT32 /* Enable FSINFO only if FAT32 and BPB_FSInfo is 1 */ - && LD_WORD(fs->win+BPB_FSInfo) == 1 - && move_window(fs, bsect + 1) == FR_OK) - { - fs->fsi_flag = 0; - if (LD_WORD(fs->win+BS_55AA) == 0xAA55 /* Load FSINFO data if available */ - && LD_DWORD(fs->win+FSI_LeadSig) == 0x41615252 - && LD_DWORD(fs->win+FSI_StrucSig) == 0x61417272) - { -#if (_FS_NOFSINFO & 1) == 0 - fs->free_clust = LD_DWORD(fs->win+FSI_Free_Count); -#endif -#if (_FS_NOFSINFO & 2) == 0 - fs->last_clust = LD_DWORD(fs->win+FSI_Nxt_Free); -#endif - } - } -#endif -#endif - fs->fs_type = fmt; /* FAT sub-type */ - fs->id = ++Fsid; /* File system mount ID */ -#if _FS_RPATH - fs->cdir = 0; /* Set current directory to root */ -#endif -#if _FS_LOCK /* Clear file lock semaphores */ - clear_lock(fs); -#endif - - return FR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Check if the file/directory object is valid or not */ -/*-----------------------------------------------------------------------*/ - -static -FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ - void* obj /* Pointer to the object FIL/DIR to check validity */ -) -{ - FIL *fil = (FIL*)obj; /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */ - - - if (!fil || !fil->fs || !fil->fs->fs_type || fil->fs->id != fil->id) - return FR_INVALID_OBJECT; - - ENTER_FF(fil->fs); /* Lock file system */ - - if (disk_status(fil->fs->drv) & STA_NOINIT) - return FR_NOT_READY; - - return FR_OK; -} - - - - -/*-------------------------------------------------------------------------- - - Public Functions - ---------------------------------------------------------------------------*/ - - - -/*-----------------------------------------------------------------------*/ -/* Mount/Unmount a Logical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mount ( - FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ - BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ -) -{ - FATFS *cfs; - int vol; - FRESULT res; - const TCHAR *rp = path; - - - vol = get_ldnumber(&rp); - if (vol < 0) return FR_INVALID_DRIVE; - cfs = FatFs[vol]; /* Pointer to fs object */ - - if (cfs) { -#if _FS_LOCK - clear_lock(cfs); -#endif -#if _FS_REENTRANT /* Discard sync object of the current volume */ - if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR; -#endif - cfs->fs_type = 0; /* Clear old fs object */ - } - - if (fs) { - fs->fs_type = 0; /* Clear new fs object */ -#if _FS_REENTRANT /* Create sync object for the new volume */ - if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR; -#endif - } - FatFs[vol] = fs; /* Register new fs object */ - - if (!fs || opt != 1) return FR_OK; /* Do not mount now, it will be mounted later */ - - res = find_volume(&fs, &path, 0); /* Force mounted the volume */ - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Open or Create a File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_open ( - FIL* fp, /* Pointer to the blank file object */ - const TCHAR* path, /* Pointer to the file name */ - BYTE mode /* Access mode and file open mode flags */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEF_NAMEBUF; - - - if (!fp) return FR_INVALID_OBJECT; - fp->fs = 0; /* Clear file object */ - - /* Get logical drive number */ -#if !_FS_READONLY - mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW; - res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ)); -#else - mode &= FA_READ; - res = find_volume(&dj.fs, &path, 0); -#endif - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - dir = dj.dir; -#if !_FS_READONLY /* R/W configuration */ - if (res == FR_OK) { - if (!dir) /* Default directory itself */ - res = FR_INVALID_NAME; -#if _FS_LOCK - else - res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0); -#endif - } - /* Create or Open a file */ - if (mode & (FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW)) { - DWORD dw, cl; - - if (res != FR_OK) { /* No file, create new */ - if (res == FR_NO_FILE) /* There is no file to open, create a new entry */ -#if _FS_LOCK - res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES; -#else - res = dir_register(&dj); -#endif - mode |= FA_CREATE_ALWAYS; /* File is created */ - dir = dj.dir; /* New entry */ - } - else { /* Any object is already existing */ - if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) { /* Cannot overwrite it (R/O or DIR) */ - res = FR_DENIED; - } else { - if (mode & FA_CREATE_NEW) /* Cannot create as new file */ - res = FR_EXIST; - } - } - if (res == FR_OK && (mode & FA_CREATE_ALWAYS)) { /* Truncate it if overwrite mode */ - dw = get_fattime(); /* Created time */ - ST_DWORD(dir+DIR_CrtTime, dw); - dir[DIR_Attr] = 0; /* Reset attribute */ - ST_DWORD(dir+DIR_FileSize, 0); /* size = 0 */ - cl = ld_clust(dj.fs, dir); /* Get start cluster */ - st_clust(dir, 0); /* cluster = 0 */ - dj.fs->wflag = 1; - if (cl) { /* Remove the cluster chain if exist */ - dw = dj.fs->winsect; - res = remove_chain(dj.fs, cl); - if (res == FR_OK) { - dj.fs->last_clust = cl - 1; /* Reuse the cluster hole */ - res = move_window(dj.fs, dw); - } - } - } - } - else { /* Open an existing file */ - if (res == FR_OK) { /* Follow succeeded */ - if (dir[DIR_Attr] & AM_DIR) { /* It is a directory */ - res = FR_NO_FILE; - } else { - if ((mode & FA_WRITE) && (dir[DIR_Attr] & AM_RDO)) /* R/O violation */ - res = FR_DENIED; - } - } - } - if (res == FR_OK) { - if (mode & FA_CREATE_ALWAYS) /* Set file change flag if created or overwritten */ - mode |= FA__WRITTEN; - fp->dir_sect = dj.fs->winsect; /* Pointer to the directory entry */ - fp->dir_ptr = dir; -#if _FS_LOCK - fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0); - if (!fp->lockid) res = FR_INT_ERR; -#endif - } - -#else /* R/O configuration */ - if (res == FR_OK) { /* Follow succeeded */ - dir = dj.dir; - if (!dir) { /* Current directory itself */ - res = FR_INVALID_NAME; - } else { - if (dir[DIR_Attr] & AM_DIR) /* It is a directory */ - res = FR_NO_FILE; - } - } -#endif - FREE_BUF(); - - if (res == FR_OK) { - fp->flag = mode; /* File access mode */ - fp->err = 0; /* Clear error flag */ - fp->sclust = ld_clust(dj.fs, dir); /* File start cluster */ - fp->fsize = LD_DWORD(dir+DIR_FileSize); /* File size */ - fp->fptr = 0; /* File pointer */ - fp->dsect = 0; -#if _USE_FASTSEEK - fp->cltbl = 0; /* Normal seek mode */ -#endif - fp->fs = dj.fs; /* Validate file object */ - fp->id = fp->fs->id; - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_read ( - FIL* fp, /* Pointer to the file object */ - void* buff, /* Pointer to data buffer */ - UINT btr, /* Number of bytes to read */ - UINT* br /* Pointer to number of bytes read */ -) -{ - FRESULT res; - DWORD clst, sect, remain; - UINT rcnt, cc; - BYTE csect, *rbuff = (BYTE*)buff; - - - *br = 0; /* Clear read byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - remain = fp->fsize - fp->fptr; - if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ - - for ( ; btr; /* Repeat until all data read */ - rbuff += rcnt, fp->fptr += rcnt, *br += rcnt, btr -= rcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = get_fat(fp->fs, fp->clust); /* Follow cluster chain on the FAT */ - } - if (clst < 2) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btr / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Read maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_read(fp->fs->drv, rbuff, sect, cc)) - ABORT(fp->fs, FR_DISK_ERR); -#if !_FS_READONLY && _FS_MINIMIZE <= 2 /* Replace one of the read sectors with cached data if it contains a dirty sector */ -#if _FS_TINY - if (fp->fs->wflag && fp->fs->winsect - sect < cc) - mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs)); -#else - if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc) - mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs)); -#endif -#endif - rcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if !_FS_TINY - if (fp->dsect != sect) { /* Load data sector if not in cache */ -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, sect, 1)) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs)); /* Get partial sector data from sector buffer */ - if (rcnt > btr) rcnt = btr; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect)) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(rbuff, &fp->fs->win[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#else - mem_cpy(rbuff, &fp->buf[fp->fptr % SS(fp->fs)], rcnt); /* Pick partial sector */ -#endif - } - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Write File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_write ( - FIL* fp, /* Pointer to the file object */ - const void *buff, /* Pointer to the data to be written */ - UINT btw, /* Number of bytes to write */ - UINT* bw /* Pointer to number of bytes written */ -) -{ - FRESULT res; - DWORD clst, sect; - UINT wcnt, cc; - const BYTE *wbuff = (const BYTE*)buff; - BYTE csect; - - - *bw = 0; /* Clear write byte counter */ - - res = validate(fp); /* Check validity */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - if (fp->fptr + btw < fp->fptr) btw = 0; /* File size cannot reach 4GB */ - - for ( ; btw; /* Repeat until all data written */ - wbuff += wcnt, fp->fptr += wcnt, *bw += wcnt, btw -= wcnt) { - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if (!csect) { /* On the cluster boundary? */ - if (fp->fptr == 0) { /* On the top of the file? */ - clst = fp->sclust; /* Follow from the origin */ - if (clst == 0) /* When no cluster is allocated, */ - clst = create_chain(fp->fs, 0); /* Create a new cluster chain */ - } else { /* Middle or end of the file */ -#if _USE_FASTSEEK - if (fp->cltbl) - clst = clmt_clust(fp, fp->fptr); /* Get cluster# from the CLMT */ - else -#endif - clst = create_chain(fp->fs, fp->clust); /* Follow or stretch cluster chain on the FAT */ - } - if (clst == 0) break; /* Could not allocate a new cluster (disk full) */ - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */ - } -#if _FS_TINY - if (fp->fs->winsect == fp->dsect && sync_window(fp->fs)) /* Write-back sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#else - if (fp->flag & FA__DIRTY) { /* Write-back sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - sect = clust2sect(fp->fs, fp->clust); /* Get current sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - cc = btw / SS(fp->fs); /* When remaining bytes >= sector size, */ - if (cc) { /* Write maximum contiguous sectors directly */ - if (csect + cc > fp->fs->csize) /* Clip at cluster boundary */ - cc = fp->fs->csize - csect; - if (disk_write(fp->fs->drv, wbuff, sect, cc)) - ABORT(fp->fs, FR_DISK_ERR); -#if _FS_MINIMIZE <= 2 -#if _FS_TINY - if (fp->fs->winsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->fs->wflag = 0; - } -#else - if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */ - mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs)); - fp->flag &= ~FA__DIRTY; - } -#endif -#endif - wcnt = SS(fp->fs) * cc; /* Number of bytes transferred */ - continue; - } -#if _FS_TINY - if (fp->fptr >= fp->fsize) { /* Avoid silly cache filling at growing edge */ - if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR); - fp->fs->winsect = sect; - } -#else - if (fp->dsect != sect) { /* Fill sector cache with file data */ - if (fp->fptr < fp->fsize && - disk_read(fp->fs->drv, fp->buf, sect, 1)) - ABORT(fp->fs, FR_DISK_ERR); - } -#endif - fp->dsect = sect; - } - wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */ - if (wcnt > btw) wcnt = btw; -#if _FS_TINY - if (move_window(fp->fs, fp->dsect)) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - mem_cpy(&fp->fs->win[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->fs->wflag = 1; -#else - mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt); /* Fit partial sector */ - fp->flag |= FA__DIRTY; -#endif - } - - if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */ - fp->flag |= FA__WRITTEN; /* Set file change flag */ - - LEAVE_FF(fp->fs, FR_OK); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Synchronize the File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_sync ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD tm; - BYTE *dir; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->flag & FA__WRITTEN) { /* Has the file been written? */ - /* Write-back dirty buffer */ -#if !_FS_TINY - if (fp->flag & FA__DIRTY) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - LEAVE_FF(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - /* Update the directory entry */ - res = move_window(fp->fs, fp->dir_sect); - if (res == FR_OK) { - dir = fp->dir_ptr; - dir[DIR_Attr] |= AM_ARC; /* Set archive bit */ - ST_DWORD(dir+DIR_FileSize, fp->fsize); /* Update file size */ - st_clust(dir, fp->sclust); /* Update start cluster */ - tm = get_fattime(); /* Update updated time */ - ST_DWORD(dir+DIR_WrtTime, tm); - ST_WORD(dir+DIR_LstAccDate, 0); - fp->flag &= ~FA__WRITTEN; - fp->fs->wflag = 1; - res = sync_fs(fp->fs); - } - } - } - - LEAVE_FF(fp->fs, res); -} - -#endif /* !_FS_READONLY */ - - - - -/*-----------------------------------------------------------------------*/ -/* Close File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_close ( - FIL *fp /* Pointer to the file object to be closed */ -) -{ - FRESULT res; - - -#if !_FS_READONLY - res = f_sync(fp); /* Flush cached data */ - if (res == FR_OK) -#endif - { - res = validate(fp); /* Lock volume */ - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = fp->fs; -#endif -#if _FS_LOCK - res = dec_lock(fp->lockid); /* Decrement file open counter */ - if (res == FR_OK) -#endif - fp->fs = 0; /* Invalidate file object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Current Directory or Current Drive, Get Current Directory */ -/*-----------------------------------------------------------------------*/ - -#if _FS_RPATH >= 1 -#if _VOLUMES >= 2 -FRESULT f_chdrive ( - const TCHAR* path /* Drive number */ -) -{ - int vol; - - - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - - CurrVol = (BYTE)vol; - - return FR_OK; -} -#endif - - -FRESULT f_chdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the path */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (!dj.dir) { - dj.fs->cdir = dj.sclust; /* Start directory itself */ - } else { - if (dj.dir[DIR_Attr] & AM_DIR) /* Reached to the directory */ - dj.fs->cdir = ld_clust(dj.fs, dj.dir); - else - res = FR_NO_PATH; /* Reached but a file */ - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - - LEAVE_FF(dj.fs, res); -} - - -#if _FS_RPATH >= 2 -FRESULT f_getcwd ( - TCHAR* buff, /* Pointer to the directory path */ - UINT len /* Size of path */ -) -{ - FRESULT res; - DIR dj; - UINT i, n; - DWORD ccl; - TCHAR *tp; - FILINFO fno; - DEF_NAMEBUF; - - - *buff = 0; - /* Get logical drive number */ - res = find_volume(&dj.fs, (const TCHAR**)&buff, 0); /* Get current volume */ - if (res == FR_OK) { - INIT_BUF(dj); - i = len; /* Bottom of buffer (directory stack base) */ - dj.sclust = dj.fs->cdir; /* Start to follow upper directory from current directory */ - while ((ccl = dj.sclust) != 0) { /* Repeat while current directory is a sub-directory */ - res = dir_sdi(&dj, 1); /* Get parent directory */ - if (res != FR_OK) break; - res = dir_read(&dj, 0); - if (res != FR_OK) break; - dj.sclust = ld_clust(dj.fs, dj.dir); /* Goto parent directory */ - res = dir_sdi(&dj, 0); - if (res != FR_OK) break; - do { /* Find the entry links to the child directory */ - res = dir_read(&dj, 0); - if (res != FR_OK) break; - if (ccl == ld_clust(dj.fs, dj.dir)) break; /* Found the entry */ - res = dir_next(&dj, 0); - } while (res == FR_OK); - if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */ - if (res != FR_OK) break; -#if _USE_LFN - fno.lfname = buff; - fno.lfsize = i; -#endif - get_fileinfo(&dj, &fno); /* Get the directory name and push it to the buffer */ - tp = fno.fname; -#if _USE_LFN - if (*buff) tp = buff; -#endif - for (n = 0; tp[n]; n++) ; - if (i < n + 3) { - res = FR_NOT_ENOUGH_CORE; break; - } - while (n) buff[--i] = tp[--n]; - buff[--i] = '/'; - } - tp = buff; - if (res == FR_OK) { -#if _VOLUMES >= 2 - *tp++ = '0' + CurrVol; /* Put drive number */ - *tp++ = ':'; -#endif - if (i == len) { /* Root-directory */ - *tp++ = '/'; - } else { /* Sub-directroy */ - do /* Add stacked path str */ - *tp++ = buff[i++]; - while (i < len); - } - } - *tp = 0; - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} -#endif /* _FS_RPATH >= 2 */ -#endif /* _FS_RPATH >= 1 */ - - - -#if _FS_MINIMIZE <= 2 -/*-----------------------------------------------------------------------*/ -/* Seek File R/W Pointer */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_lseek ( - FIL* fp, /* Pointer to the file object */ - DWORD ofs /* File pointer from top of file */ -) -{ - FRESULT res; - - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - -#if _USE_FASTSEEK - if (fp->cltbl) { /* Fast seek */ - DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl; - - if (ofs == CREATE_LINKMAP) { /* Create CLMT */ - tbl = fp->cltbl; - tlen = *tbl++; ulen = 2; /* Given table size and required table size */ - cl = fp->sclust; /* Top of the chain */ - if (cl) { - do { - /* Get a fragment */ - tcl = cl; ncl = 0; ulen += 2; /* Top, length and used items */ - do { - pcl = cl; ncl++; - cl = get_fat(fp->fs, cl); - if (cl <= 1) ABORT(fp->fs, FR_INT_ERR); - if (cl == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - } while (cl == pcl + 1); - if (ulen <= tlen) { /* Store the length and top of the fragment */ - *tbl++ = ncl; *tbl++ = tcl; - } - } while (cl < fp->fs->n_fatent); /* Repeat until end of chain */ - } - *fp->cltbl = ulen; /* Number of items used */ - if (ulen <= tlen) - *tbl = 0; /* Terminate table */ - else - res = FR_NOT_ENOUGH_CORE; /* Given table size is smaller than required */ - - } else { /* Fast seek */ - if (ofs > fp->fsize) /* Clip offset at the file size */ - ofs = fp->fsize; - fp->fptr = ofs; /* Set file pointer */ - if (ofs) { - fp->clust = clmt_clust(fp, ofs - 1); - dsc = clust2sect(fp->fs, fp->clust); - if (!dsc) ABORT(fp->fs, FR_INT_ERR); - dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1); - if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) { /* Refill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, dsc, 1)) /* Load current sector */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = dsc; - } - } - } - } else -#endif - - /* Normal Seek */ - { - DWORD clst, bcs, nsect, ifptr; - - if (ofs > fp->fsize /* In read-only mode, clip offset with the file size */ -#if !_FS_READONLY - && !(fp->flag & FA_WRITE) -#endif - ) ofs = fp->fsize; - - ifptr = fp->fptr; - fp->fptr = nsect = 0; - if (ofs) { - bcs = (DWORD)fp->fs->csize * SS(fp->fs); /* Cluster size (byte) */ - if (ifptr > 0 && - (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ - fp->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ - ofs -= fp->fptr; - clst = fp->clust; - } else { /* When seek to back cluster, */ - clst = fp->sclust; /* start from the first cluster */ -#if !_FS_READONLY - if (clst == 0) { /* If no cluster chain, create a new chain */ - clst = create_chain(fp->fs, 0); - if (clst == 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->sclust = clst; - } -#endif - fp->clust = clst; - } - if (clst != 0) { - while (ofs > bcs) { /* Cluster following loop */ -#if !_FS_READONLY - if (fp->flag & FA_WRITE) { /* Check if in write mode or not */ - clst = create_chain(fp->fs, clst); /* Force stretch if in write mode */ - if (clst == 0) { /* When disk gets full, clip file size */ - ofs = bcs; break; - } - } else -#endif - clst = get_fat(fp->fs, clst); /* Follow cluster chain if not in write mode */ - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - if (clst <= 1 || clst >= fp->fs->n_fatent) ABORT(fp->fs, FR_INT_ERR); - fp->clust = clst; - fp->fptr += bcs; - ofs -= bcs; - } - fp->fptr += ofs; - if (ofs % SS(fp->fs)) { - nsect = clust2sect(fp->fs, clst); /* Current sector */ - if (!nsect) ABORT(fp->fs, FR_INT_ERR); - nsect += ofs / SS(fp->fs); - } - } - } - if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) { /* Fill sector cache if needed */ -#if !_FS_TINY -#if !_FS_READONLY - if (fp->flag & FA__DIRTY) { /* Write-back dirty sector cache */ - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - ABORT(fp->fs, FR_DISK_ERR); - fp->flag &= ~FA__DIRTY; - } -#endif - if (disk_read(fp->fs->drv, fp->buf, nsect, 1)) /* Fill sector cache */ - ABORT(fp->fs, FR_DISK_ERR); -#endif - fp->dsect = nsect; - } -#if !_FS_READONLY - if (fp->fptr > fp->fsize) { /* Set file change flag if the file size is extended */ - fp->fsize = fp->fptr; - fp->flag |= FA__WRITTEN; - } -#endif - } - - LEAVE_FF(fp->fs, res); -} - - - -#if _FS_MINIMIZE <= 1 -/*-----------------------------------------------------------------------*/ -/* Create a Directory Object */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_opendir ( - DIR* dp, /* Pointer to directory object to create */ - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - FATFS* fs; - DEF_NAMEBUF; - - - if (!dp) return FR_INVALID_OBJECT; - - /* Get logical drive number */ - res = find_volume(&fs, &path, 0); - if (res == FR_OK) { - dp->fs = fs; - INIT_BUF(*dp); - res = follow_path(dp, path); /* Follow the path to the directory */ - FREE_BUF(); - if (res == FR_OK) { /* Follow completed */ - if (dp->dir) { /* It is not the origin directory itself */ - if (dp->dir[DIR_Attr] & AM_DIR) /* The object is a sub directory */ - dp->sclust = ld_clust(fs, dp->dir); - else /* The object is a file */ - res = FR_NO_PATH; - } - if (res == FR_OK) { - dp->id = fs->id; - res = dir_sdi(dp, 0); /* Rewind directory */ -#if _FS_LOCK - if (res == FR_OK) { - if (dp->sclust) { - dp->lockid = inc_lock(dp, 0); /* Lock the sub directory */ - if (!dp->lockid) - res = FR_TOO_MANY_OPEN_FILES; - } else { - dp->lockid = 0; /* Root directory need not to be locked */ - } - } -#endif - } - } - if (res == FR_NO_FILE) res = FR_NO_PATH; - } - if (res != FR_OK) dp->fs = 0; /* Invalidate the directory object if function faild */ - - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Close Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_closedir ( - DIR *dp /* Pointer to the directory object to be closed */ -) -{ - FRESULT res; - - - res = validate(dp); - if (res == FR_OK) { -#if _FS_REENTRANT - FATFS *fs = dp->fs; -#endif -#if _FS_LOCK - if (dp->lockid) /* Decrement sub-directory open counter */ - res = dec_lock(dp->lockid); - if (res == FR_OK) -#endif - dp->fs = 0; /* Invalidate directory object */ -#if _FS_REENTRANT - unlock_fs(fs, FR_OK); /* Unlock volume */ -#endif - } - return res; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Read Directory Entries in Sequence */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_readdir ( - DIR* dp, /* Pointer to the open directory object */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DEF_NAMEBUF; - - - res = validate(dp); /* Check validity of the object */ - if (res == FR_OK) { - if (!fno) { - res = dir_sdi(dp, 0); /* Rewind the directory object */ - } else { - INIT_BUF(*dp); - res = dir_read(dp, 0); /* Read an item */ - if (res == FR_NO_FILE) { /* Reached end of directory */ - dp->sect = 0; - res = FR_OK; - } - if (res == FR_OK) { /* A valid entry is found */ - get_fileinfo(dp, fno); /* Get the object information */ - res = dir_next(dp, 0); /* Increment index for next */ - if (res == FR_NO_FILE) { - dp->sect = 0; - res = FR_OK; - } - } - FREE_BUF(); - } - } - - LEAVE_FF(dp->fs, res); -} - - - -#if _FS_MINIMIZE == 0 -/*-----------------------------------------------------------------------*/ -/* Get File Status */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_stat ( - const TCHAR* path, /* Pointer to the file path */ - FILINFO* fno /* Pointer to file information to return */ -) -{ - FRESULT res; - DIR dj; - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) { /* Follow completed */ - if (dj.dir) { /* Found an object */ - if (fno) get_fileinfo(&dj, fno); - } else { /* It is root directory */ - res = FR_INVALID_NAME; - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Get Number of Free Clusters */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ - DWORD* nclst, /* Pointer to a variable to return number of free clusters */ - FATFS** fatfs /* Pointer to return pointer to corresponding file system object */ -) -{ - FRESULT res; - FATFS *fs; - DWORD n, clst, sect, stat; - UINT i; - BYTE fat, *p; - - - /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); - fs = *fatfs; - if (res == FR_OK) { - /* If free_clust is valid, return it without full cluster scan */ - if (fs->free_clust <= fs->n_fatent - 2) { - *nclst = fs->free_clust; - } else { - /* Get number of free clusters */ - fat = fs->fs_type; - n = 0; - if (fat == FS_FAT12) { - clst = 2; - do { - stat = get_fat(fs, clst); - if (stat == 0xFFFFFFFF) { res = FR_DISK_ERR; break; } - if (stat == 1) { res = FR_INT_ERR; break; } - if (stat == 0) n++; - } while (++clst < fs->n_fatent); - } else { - clst = fs->n_fatent; - sect = fs->fatbase; - i = 0; p = 0; - do { - if (!i) { - res = move_window(fs, sect++); - if (res != FR_OK) break; - p = fs->win; - i = SS(fs); - } - if (fat == FS_FAT16) { - if (LD_WORD(p) == 0) n++; - p += 2; i -= 2; - } else { - if ((LD_DWORD(p) & 0x0FFFFFFF) == 0) n++; - p += 4; i -= 4; - } - } while (--clst); - } - fs->free_clust = n; - fs->fsi_flag |= 1; - *nclst = n; - } - } - LEAVE_FF(fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Truncate File */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_truncate ( - FIL* fp /* Pointer to the file object */ -) -{ - FRESULT res; - DWORD ncl; - - - res = validate(fp); /* Check validity of the object */ - if (res == FR_OK) { - if (fp->err) { /* Check error */ - res = (FRESULT)fp->err; - } else { - if (!(fp->flag & FA_WRITE)) /* Check access mode */ - res = FR_DENIED; - } - } - if (res == FR_OK) { - if (fp->fsize > fp->fptr) { - fp->fsize = fp->fptr; /* Set file size to current R/W point */ - fp->flag |= FA__WRITTEN; - if (fp->fptr == 0) { /* When set file size to zero, remove entire cluster chain */ - res = remove_chain(fp->fs, fp->sclust); - fp->sclust = 0; - } else { /* When truncate a part of the file, remove remaining clusters */ - ncl = get_fat(fp->fs, fp->clust); - res = FR_OK; - if (ncl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (ncl == 1) res = FR_INT_ERR; - if (res == FR_OK && ncl < fp->fs->n_fatent) { - res = put_fat(fp->fs, fp->clust, 0x0FFFFFFF); - if (res == FR_OK) res = remove_chain(fp->fs, ncl); - } - } -#if !_FS_TINY - if (res == FR_OK && (fp->flag & FA__DIRTY)) { - if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1)) - res = FR_DISK_ERR; - else - fp->flag &= ~FA__DIRTY; - } -#endif - } - if (res != FR_OK) fp->err = (FRESULT)res; - } - - LEAVE_FF(fp->fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Delete a File or Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_unlink ( - const TCHAR* path /* Pointer to the file or directory path */ -) -{ - FRESULT res; - DIR dj, sdj; - BYTE *dir; - DWORD dclst; - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT)) - res = FR_INVALID_NAME; /* Cannot remove dot entry */ -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&dj, 2); /* Cannot remove open file */ -#endif - if (res == FR_OK) { /* The object is accessible */ - dir = dj.dir; - if (!dir) { - res = FR_INVALID_NAME; /* Cannot remove the start directory */ - } else { - if (dir[DIR_Attr] & AM_RDO) - res = FR_DENIED; /* Cannot remove R/O object */ - } - dclst = ld_clust(dj.fs, dir); - if (res == FR_OK && (dir[DIR_Attr] & AM_DIR)) { /* Is it a sub-dir? */ - if (dclst < 2) { - res = FR_INT_ERR; - } else { - mem_cpy(&sdj, &dj, sizeof (DIR)); /* Check if the sub-directory is empty or not */ - sdj.sclust = dclst; - res = dir_sdi(&sdj, 2); /* Exclude dot entries */ - if (res == FR_OK) { - res = dir_read(&sdj, 0); /* Read an item */ - if (res == FR_OK /* Not empty directory */ -#if _FS_RPATH - || dclst == dj.fs->cdir /* Current directory */ -#endif - ) res = FR_DENIED; - if (res == FR_NO_FILE) res = FR_OK; /* Empty */ - } - } - } - if (res == FR_OK) { - res = dir_remove(&dj); /* Remove the directory entry */ - if (res == FR_OK) { - if (dclst) /* Remove the cluster chain if exist */ - res = remove_chain(dj.fs, dclst); - if (res == FR_OK) res = sync_fs(dj.fs); - } - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create a Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_mkdir ( - const TCHAR* path /* Pointer to the directory path */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir, n; - DWORD dsc, dcl, pcl, tm = get_fattime(); - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - if (res == FR_OK) res = FR_EXIST; /* Any object with same name is already existing */ - if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NS] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_NO_FILE) { /* Can create a new directory */ - dcl = create_chain(dj.fs, 0); /* Allocate a cluster for the new directory table */ - res = FR_OK; - if (dcl == 0) res = FR_DENIED; /* No space to allocate a new cluster */ - if (dcl == 1) res = FR_INT_ERR; - if (dcl == 0xFFFFFFFF) res = FR_DISK_ERR; - if (res == FR_OK) /* Flush FAT */ - res = sync_window(dj.fs); - if (res == FR_OK) { /* Initialize the new directory table */ - dsc = clust2sect(dj.fs, dcl); - dir = dj.fs->win; - mem_set(dir, 0, SS(dj.fs)); - mem_set(dir+DIR_Name, ' ', 11); /* Create "." entry */ - dir[DIR_Name] = '.'; - dir[DIR_Attr] = AM_DIR; - ST_DWORD(dir+DIR_WrtTime, tm); - st_clust(dir, dcl); - mem_cpy(dir+SZ_DIR, dir, SZ_DIR); /* Create ".." entry */ - dir[SZ_DIR+1] = '.'; pcl = dj.sclust; - if (dj.fs->fs_type == FS_FAT32 && pcl == dj.fs->dirbase) - pcl = 0; - st_clust(dir+SZ_DIR, pcl); - for (n = dj.fs->csize; n; n--) { /* Write dot entries and clear following sectors */ - dj.fs->winsect = dsc++; - dj.fs->wflag = 1; - res = sync_window(dj.fs); - if (res != FR_OK) break; - mem_set(dir, 0, SS(dj.fs)); - } - } - if (res == FR_OK) res = dir_register(&dj); /* Register the object to the directoy */ - if (res != FR_OK) { - remove_chain(dj.fs, dcl); /* Could not register, remove cluster chain */ - } else { - dir = dj.dir; - dir[DIR_Attr] = AM_DIR; /* Attribute */ - ST_DWORD(dir+DIR_WrtTime, tm); /* Created time */ - st_clust(dir, dcl); /* Table start cluster */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - FREE_BUF(); - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Attribute */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_chmod ( - const TCHAR* path, /* Pointer to the file path */ - BYTE value, /* Attribute bits */ - BYTE mask /* Attribute mask to change */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Is it a root directory? */ - res = FR_INVALID_NAME; - } else { /* File or sub directory */ - mask &= AM_RDO|AM_HID|AM_SYS|AM_ARC; /* Valid attribute mask */ - dir[DIR_Attr] = (value & mask) | (dir[DIR_Attr] & (BYTE)~mask); /* Apply attribute change */ - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Change Timestamp */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_utime ( - const TCHAR* path, /* Pointer to the file/directory name */ - const FILINFO* fno /* Pointer to the time stamp to be set */ -) -{ - FRESULT res; - DIR dj; - BYTE *dir; - DEF_NAMEBUF; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); - if (res == FR_OK) { - INIT_BUF(dj); - res = follow_path(&dj, path); /* Follow the file path */ - FREE_BUF(); - if (_FS_RPATH && res == FR_OK && (dj.fn[NS] & NS_DOT)) - res = FR_INVALID_NAME; - if (res == FR_OK) { - dir = dj.dir; - if (!dir) { /* Root directory */ - res = FR_INVALID_NAME; - } else { /* File or sub-directory */ - ST_WORD(dir+DIR_WrtTime, fno->ftime); - ST_WORD(dir+DIR_WrtDate, fno->fdate); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - - LEAVE_FF(dj.fs, res); -} - - - - -/*-----------------------------------------------------------------------*/ -/* Rename File/Directory */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_rename ( - const TCHAR* path_old, /* Pointer to the object to be renamed */ - const TCHAR* path_new /* Pointer to the new name */ -) -{ - FRESULT res; - DIR djo, djn; - BYTE buf[21], *dir; - DWORD dw; - DEF_NAMEBUF; - - - /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); - if (res == FR_OK) { - djn.fs = djo.fs; - INIT_BUF(djo); - res = follow_path(&djo, path_old); /* Check old object */ - if (_FS_RPATH && res == FR_OK && (djo.fn[NS] & NS_DOT)) - res = FR_INVALID_NAME; -#if _FS_LOCK - if (res == FR_OK) res = chk_lock(&djo, 2); -#endif - if (res == FR_OK) { /* Old object is found */ - if (!djo.dir) { /* Is root dir? */ - res = FR_NO_FILE; - } else { - mem_cpy(buf, djo.dir+DIR_Attr, 21); /* Save the object information except name */ - mem_cpy(&djn, &djo, sizeof (DIR)); /* Duplicate the directory object */ - if (get_ldnumber(&path_new) >= 0) /* Snip drive number off and ignore it */ - res = follow_path(&djn, path_new); /* and check if new object is exist */ - else - res = FR_INVALID_DRIVE; - if (res == FR_OK) res = FR_EXIST; /* The new object name is already existing */ - if (res == FR_NO_FILE) { /* Is it a valid path and no name collision? */ -/* Start critical section that any interruption can cause a cross-link */ - res = dir_register(&djn); /* Register the new entry */ - if (res == FR_OK) { - dir = djn.dir; /* Copy object information except name */ - mem_cpy(dir+13, buf+2, 19); - dir[DIR_Attr] = buf[0] | AM_ARC; - djo.fs->wflag = 1; - if (djo.sclust != djn.sclust && (dir[DIR_Attr] & AM_DIR)) { /* Update .. entry in the directory if needed */ - dw = clust2sect(djo.fs, ld_clust(djo.fs, dir)); - if (!dw) { - res = FR_INT_ERR; - } else { - res = move_window(djo.fs, dw); - dir = djo.fs->win+SZ_DIR; /* .. entry */ - if (res == FR_OK && dir[1] == '.') { - dw = (djo.fs->fs_type == FS_FAT32 && djn.sclust == djo.fs->dirbase) ? 0 : djn.sclust; - st_clust(dir, dw); - djo.fs->wflag = 1; - } - } - } - if (res == FR_OK) { - res = dir_remove(&djo); /* Remove old entry */ - if (res == FR_OK) - res = sync_fs(djo.fs); - } - } -/* End critical section */ - } - } - } - FREE_BUF(); - } - - LEAVE_FF(djo.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _FS_MINIMIZE == 0 */ -#endif /* _FS_MINIMIZE <= 1 */ -#endif /* _FS_MINIMIZE <= 2 */ - - - -#if _USE_LABEL -/*-----------------------------------------------------------------------*/ -/* Get volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_getlabel ( - const TCHAR* path, /* Path name of the logical drive number */ - TCHAR* label, /* Pointer to a buffer to return the volume label */ - DWORD* vsn /* Pointer to a variable to return the volume serial number */ -) -{ - FRESULT res; - DIR dj; - UINT i, j; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); - - /* Get volume label */ - if (res == FR_OK && label) { - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is exist */ -#if _USE_LFN && _LFN_UNICODE - WCHAR w; - i = j = 0; - do { - w = (i < 11) ? dj.dir[i++] : ' '; - if (IsDBCS1(w) && i < 11 && IsDBCS2(dj.dir[i])) - w = w << 8 | dj.dir[i++]; - label[j++] = ff_convert(w, 1); /* OEM -> Unicode */ - } while (j < 11); -#else - mem_cpy(label, dj.dir, 11); -#endif - j = 11; - do { - label[j] = 0; - if (!j) break; - } while (label[--j] == ' '); - } - if (res == FR_NO_FILE) { /* No label, return nul string */ - label[0] = 0; - res = FR_OK; - } - } - } - - /* Get volume serial number */ - if (res == FR_OK && vsn) { - res = move_window(dj.fs, dj.fs->volbase); - if (res == FR_OK) { - i = dj.fs->fs_type == FS_FAT32 ? BS_VolID32 : BS_VolID; - *vsn = LD_DWORD(&dj.fs->win[i]); - } - } - - LEAVE_FF(dj.fs, res); -} - - - -#if !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Set volume label */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_setlabel ( - const TCHAR* label /* Pointer to the volume label to set */ -) -{ - FRESULT res; - DIR dj; - BYTE vn[11]; - UINT i, j, sl; - WCHAR w; - DWORD tm; - - - /* Get logical drive number */ - res = find_volume(&dj.fs, &label, 1); - if (res) LEAVE_FF(dj.fs, res); - - /* Create a volume label in directory form */ - vn[0] = 0; - for (sl = 0; label[sl]; sl++) ; /* Get name length */ - for ( ; sl && label[sl-1] == ' '; sl--) ; /* Remove trailing spaces */ - if (sl) { /* Create volume label in directory form */ - i = j = 0; - do { -#if _USE_LFN && _LFN_UNICODE - w = ff_convert(ff_wtoupper(label[i++]), 0); -#else - w = (BYTE)label[i++]; - if (IsDBCS1(w)) - w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0; -#if _USE_LFN - w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0); -#else - if (IsLower(w)) w -= 0x20; /* To upper ASCII characters */ -#ifdef _EXCVT - if (w >= 0x80) w = ExCvt[w - 0x80]; /* To upper extended characters (SBCS cfg) */ -#else - if (!_DF1S && w >= 0x80) w = 0; /* Reject extended characters (ASCII cfg) */ -#endif -#endif -#endif - if (!w || chk_chr("\"*+,.:;<=>\?[]|\x7F", w) || j >= (UINT)((w >= 0x100) ? 10 : 11)) /* Reject invalid characters for volume label */ - LEAVE_FF(dj.fs, FR_INVALID_NAME); - if (w >= 0x100) vn[j++] = (BYTE)(w >> 8); - vn[j++] = (BYTE)w; - } while (i < sl); - while (j < 11) vn[j++] = ' '; - } - - /* Set volume label */ - dj.sclust = 0; /* Open root directory */ - res = dir_sdi(&dj, 0); - if (res == FR_OK) { - res = dir_read(&dj, 1); /* Get an entry with AM_VOL */ - if (res == FR_OK) { /* A volume label is found */ - if (vn[0]) { - mem_cpy(dj.dir, vn, 11); /* Change the volume label name */ - tm = get_fattime(); - ST_DWORD(dj.dir+DIR_WrtTime, tm); - } else { - dj.dir[0] = DDE; /* Remove the volume label */ - } - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } else { /* No volume label is found or error */ - if (res == FR_NO_FILE) { - res = FR_OK; - if (vn[0]) { /* Create volume label as new */ - res = dir_alloc(&dj, 1); /* Allocate an entry for volume label */ - if (res == FR_OK) { - mem_set(dj.dir, 0, SZ_DIR); /* Set volume label */ - mem_cpy(dj.dir, vn, 11); - dj.dir[DIR_Attr] = AM_VOL; - tm = get_fattime(); - ST_DWORD(dj.dir+DIR_WrtTime, tm); - dj.fs->wflag = 1; - res = sync_fs(dj.fs); - } - } - } - } - } - - LEAVE_FF(dj.fs, res); -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_LABEL */ - - - -/*-----------------------------------------------------------------------*/ -/* Forward data to the stream directly (available on only tiny cfg) */ -/*-----------------------------------------------------------------------*/ -#if _USE_FORWARD && _FS_TINY - -FRESULT f_forward ( - FIL* fp, /* Pointer to the file object */ - UINT (*func)(const BYTE*,UINT), /* Pointer to the streaming function */ - UINT btf, /* Number of bytes to forward */ - UINT* bf /* Pointer to number of bytes forwarded */ -) -{ - FRESULT res; - DWORD remain, clst, sect; - UINT rcnt; - BYTE csect; - - - *bf = 0; /* Clear transfer byte counter */ - - res = validate(fp); /* Check validity of the object */ - if (res != FR_OK) LEAVE_FF(fp->fs, res); - if (fp->err) /* Check error */ - LEAVE_FF(fp->fs, (FRESULT)fp->err); - if (!(fp->flag & FA_READ)) /* Check access mode */ - LEAVE_FF(fp->fs, FR_DENIED); - - remain = fp->fsize - fp->fptr; - if (btf > remain) btf = (UINT)remain; /* Truncate btf by remaining bytes */ - - for ( ; btf && (*func)(0, 0); /* Repeat until all data transferred or stream becomes busy */ - fp->fptr += rcnt, *bf += rcnt, btf -= rcnt) { - csect = (BYTE)(fp->fptr / SS(fp->fs) & (fp->fs->csize - 1)); /* Sector offset in the cluster */ - if ((fp->fptr % SS(fp->fs)) == 0) { /* On the sector boundary? */ - if (!csect) { /* On the cluster boundary? */ - clst = (fp->fptr == 0) ? /* On the top of the file? */ - fp->sclust : get_fat(fp->fs, fp->clust); - if (clst <= 1) ABORT(fp->fs, FR_INT_ERR); - if (clst == 0xFFFFFFFF) ABORT(fp->fs, FR_DISK_ERR); - fp->clust = clst; /* Update current cluster */ - } - } - sect = clust2sect(fp->fs, fp->clust); /* Get current data sector */ - if (!sect) ABORT(fp->fs, FR_INT_ERR); - sect += csect; - if (move_window(fp->fs, sect)) /* Move sector window */ - ABORT(fp->fs, FR_DISK_ERR); - fp->dsect = sect; - rcnt = SS(fp->fs) - (WORD)(fp->fptr % SS(fp->fs)); /* Forward data from sector window */ - if (rcnt > btf) rcnt = btf; - rcnt = (*func)(&fp->fs->win[(WORD)fp->fptr % SS(fp->fs)], rcnt); - if (!rcnt) ABORT(fp->fs, FR_INT_ERR); - } - - LEAVE_FF(fp->fs, FR_OK); -} -#endif /* _USE_FORWARD */ - - - -#if _USE_MKFS && !_FS_READONLY -/*-----------------------------------------------------------------------*/ -/* Create File System on the Drive */ -/*-----------------------------------------------------------------------*/ -#define N_ROOTDIR 512 /* Number of root directory entries for FAT12/16 */ -#define N_FATS 1 /* Number of FAT copies (1 or 2) */ - - -FRESULT f_mkfs ( - const TCHAR* path, /* Logical drive number */ - BYTE sfd, /* Partitioning rule 0:FDISK, 1:SFD */ - UINT au /* Allocation unit [bytes] */ -) -{ - static const WORD vst[] = { 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 0}; - static const WORD cst[] = {32768, 16384, 8192, 4096, 2048, 16384, 8192, 4096, 2048, 1024, 512}; - int vol; - BYTE fmt, md, sys, *tbl, pdrv, part; - DWORD n_clst, vs, n, wsect; - UINT i; - DWORD b_vol, b_fat, b_dir, b_data; /* LBA */ - DWORD n_vol, n_rsv, n_fat, n_dir; /* Size */ - FATFS *fs; - DSTATUS stat; - - - /* Check mounted drive and clear work area */ - vol = get_ldnumber(&path); - if (vol < 0) return FR_INVALID_DRIVE; - if (sfd > 1) return FR_INVALID_PARAMETER; - if (au & (au - 1)) return FR_INVALID_PARAMETER; - fs = FatFs[vol]; - if (!fs) return FR_NOT_ENABLED; - fs->fs_type = 0; - pdrv = LD2PD(vol); /* Physical drive */ - part = LD2PT(vol); /* Partition (0:auto detect, 1-4:get from partition table)*/ - - /* Get disk statics */ - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; -#if _MAX_SS != _MIN_SS /* Get disk sector size */ - if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS) - return FR_DISK_ERR; -#endif - if (_MULTI_PARTITION && part) { - /* Get partition information from partition table in the MBR */ - if (disk_read(pdrv, fs->win, 0, 1)) return FR_DISK_ERR; - if (LD_WORD(fs->win+BS_55AA) != 0xAA55) return FR_MKFS_ABORTED; - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - if (!tbl[4]) return FR_MKFS_ABORTED; /* No partition? */ - b_vol = LD_DWORD(tbl+8); /* Volume start sector */ - n_vol = LD_DWORD(tbl+12); /* Volume size */ - } else { - /* Create a partition in this function */ - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) - return FR_DISK_ERR; - b_vol = (sfd) ? 0 : 63; /* Volume start sector */ - n_vol -= b_vol; /* Volume size */ - } - - if (!au) { /* AU auto selection */ - vs = n_vol / (2000 / (SS(fs) / 512)); - for (i = 0; vs < vst[i]; i++) ; - au = cst[i]; - } - au /= SS(fs); /* Number of sectors per cluster */ - if (au == 0) au = 1; - if (au > 128) au = 128; - - /* Pre-compute number of clusters and FAT sub-type */ - n_clst = n_vol / au; - fmt = FS_FAT12; - if (n_clst >= MIN_FAT16) fmt = FS_FAT16; - if (n_clst >= MIN_FAT32) fmt = FS_FAT32; - - /* Determine offset and size of FAT structure */ - if (fmt == FS_FAT32) { - n_fat = ((n_clst * 4) + 8 + SS(fs) - 1) / SS(fs); - n_rsv = 32; - n_dir = 0; - } else { - n_fat = (fmt == FS_FAT12) ? (n_clst * 3 + 1) / 2 + 3 : (n_clst * 2) + 4; - n_fat = (n_fat + SS(fs) - 1) / SS(fs); - n_rsv = 1; - n_dir = (DWORD)N_ROOTDIR * SZ_DIR / SS(fs); - } - b_fat = b_vol + n_rsv; /* FAT area start sector */ - b_dir = b_fat + n_fat * N_FATS; /* Directory area start sector */ - b_data = b_dir + n_dir; /* Data area start sector */ - if (n_vol < b_data + au - b_vol) return FR_MKFS_ABORTED; /* Too small volume */ - - /* Align data start sector to erase block boundary (for flash memory media) */ - if (disk_ioctl(pdrv, GET_BLOCK_SIZE, &n) != RES_OK || !n || n > 32768) n = 1; - n = (b_data + n - 1) & ~(n - 1); /* Next nearest erase block from current data start */ - n = (n - b_data) / N_FATS; - if (fmt == FS_FAT32) { /* FAT32: Move FAT offset */ - n_rsv += n; - b_fat += n; - } else { /* FAT12/16: Expand FAT size */ - n_fat += n; - } - - /* Determine number of clusters and final check of validity of the FAT sub-type */ - n_clst = (n_vol - n_rsv - n_fat * N_FATS - n_dir) / au; - if ( (fmt == FS_FAT16 && n_clst < MIN_FAT16) - || (fmt == FS_FAT32 && n_clst < MIN_FAT32)) - return FR_MKFS_ABORTED; - - /* Determine system ID in the partition table */ - if (fmt == FS_FAT32) { - sys = 0x0C; /* FAT32X */ - } else { - if (fmt == FS_FAT12 && n_vol < 0x10000) { - sys = 0x01; /* FAT12(<65536) */ - } else { - sys = (n_vol < 0x10000) ? 0x04 : 0x06; /* FAT16(<65536) : FAT12/16(>=65536) */ - } - } - - if (_MULTI_PARTITION && part) { - /* Update system ID in the partition table */ - tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE]; - tbl[4] = sys; - if (disk_write(pdrv, fs->win, 0, 1)) /* Write it to teh MBR */ - return FR_DISK_ERR; - md = 0xF8; - } else { - if (sfd) { /* No partition table (SFD) */ - md = 0xF0; - } else { /* Create partition table (FDISK) */ - mem_set(fs->win, 0, SS(fs)); - tbl = fs->win+MBR_Table; /* Create partition table for single partition in the drive */ - tbl[1] = 1; /* Partition start head */ - tbl[2] = 1; /* Partition start sector */ - tbl[3] = 0; /* Partition start cylinder */ - tbl[4] = sys; /* System type */ - tbl[5] = 254; /* Partition end head */ - n = (b_vol + n_vol) / 63 / 255; - tbl[6] = (BYTE)(n >> 2 | 63); /* Partition end sector */ - tbl[7] = (BYTE)n; /* End cylinder */ - ST_DWORD(tbl+8, 63); /* Partition start in LBA */ - ST_DWORD(tbl+12, n_vol); /* Partition size in LBA */ - ST_WORD(fs->win+BS_55AA, 0xAA55); /* MBR signature */ - if (disk_write(pdrv, fs->win, 0, 1)) /* Write it to the MBR */ - return FR_DISK_ERR; - md = 0xF8; - } - } - - /* Create BPB in the VBR */ - tbl = fs->win; /* Clear sector */ - mem_set(tbl, 0, SS(fs)); - mem_cpy(tbl, "\xEB\xFE\x90" "MSDOS5.0", 11);/* Boot jump code, OEM name */ - i = SS(fs); /* Sector size */ - ST_WORD(tbl+BPB_BytsPerSec, i); - tbl[BPB_SecPerClus] = (BYTE)au; /* Sectors per cluster */ - ST_WORD(tbl+BPB_RsvdSecCnt, n_rsv); /* Reserved sectors */ - tbl[BPB_NumFATs] = N_FATS; /* Number of FATs */ - i = (fmt == FS_FAT32) ? 0 : N_ROOTDIR; /* Number of root directory entries */ - ST_WORD(tbl+BPB_RootEntCnt, i); - if (n_vol < 0x10000) { /* Number of total sectors */ - ST_WORD(tbl+BPB_TotSec16, n_vol); - } else { - ST_DWORD(tbl+BPB_TotSec32, n_vol); - } - tbl[BPB_Media] = md; /* Media descriptor */ - ST_WORD(tbl+BPB_SecPerTrk, 63); /* Number of sectors per track */ - ST_WORD(tbl+BPB_NumHeads, 255); /* Number of heads */ - ST_DWORD(tbl+BPB_HiddSec, b_vol); /* Hidden sectors */ - n = get_fattime(); /* Use current time as VSN */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl+BS_VolID32, n); /* VSN */ - ST_DWORD(tbl+BPB_FATSz32, n_fat); /* Number of sectors per FAT */ - ST_DWORD(tbl+BPB_RootClus, 2); /* Root directory start cluster (2) */ - ST_WORD(tbl+BPB_FSInfo, 1); /* FSINFO record offset (VBR+1) */ - ST_WORD(tbl+BPB_BkBootSec, 6); /* Backup boot record offset (VBR+6) */ - tbl[BS_DrvNum32] = 0x80; /* Drive number */ - tbl[BS_BootSig32] = 0x29; /* Extended boot signature */ - mem_cpy(tbl+BS_VolLab32, "NO NAME " "FAT32 ", 19); /* Volume label, FAT signature */ - } else { - ST_DWORD(tbl+BS_VolID, n); /* VSN */ - ST_WORD(tbl+BPB_FATSz16, n_fat); /* Number of sectors per FAT */ - tbl[BS_DrvNum] = 0x80; /* Drive number */ - tbl[BS_BootSig] = 0x29; /* Extended boot signature */ - mem_cpy(tbl+BS_VolLab, "NO NAME " "FAT ", 19); /* Volume label, FAT signature */ - } - ST_WORD(tbl+BS_55AA, 0xAA55); /* Signature (Offset is fixed here regardless of sector size) */ - if (disk_write(pdrv, tbl, b_vol, 1)) /* Write it to the VBR sector */ - return FR_DISK_ERR; - if (fmt == FS_FAT32) /* Write backup VBR if needed (VBR+6) */ - disk_write(pdrv, tbl, b_vol + 6, 1); - - /* Initialize FAT area */ - wsect = b_fat; - for (i = 0; i < N_FATS; i++) { /* Initialize each FAT copy */ - mem_set(tbl, 0, SS(fs)); /* 1st sector of the FAT */ - n = md; /* Media descriptor byte */ - if (fmt != FS_FAT32) { - n |= (fmt == FS_FAT12) ? 0x00FFFF00 : 0xFFFFFF00; - ST_DWORD(tbl+0, n); /* Reserve cluster #0-1 (FAT12/16) */ - } else { - n |= 0xFFFFFF00; - ST_DWORD(tbl+0, n); /* Reserve cluster #0-1 (FAT32) */ - ST_DWORD(tbl+4, 0xFFFFFFFF); - ST_DWORD(tbl+8, 0x0FFFFFFF); /* Reserve cluster #2 for root directory */ - } - if (disk_write(pdrv, tbl, wsect++, 1)) - return FR_DISK_ERR; - mem_set(tbl, 0, SS(fs)); /* Fill following FAT entries with zero */ - for (n = 1; n < n_fat; n++) { /* This loop may take a time on FAT32 volume due to many single sector writes */ - if (disk_write(pdrv, tbl, wsect++, 1)) - return FR_DISK_ERR; - } - } - - /* Initialize root directory */ - i = (fmt == FS_FAT32) ? au : (UINT)n_dir; - do { - if (disk_write(pdrv, tbl, wsect++, 1)) - return FR_DISK_ERR; - } while (--i); - -#if _USE_ERASE /* Erase data area if needed */ - { - DWORD eb[2]; - - eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1; - disk_ioctl(pdrv, CTRL_ERASE_SECTOR, eb); - } -#endif - - /* Create FSINFO if needed */ - if (fmt == FS_FAT32) { - ST_DWORD(tbl+FSI_LeadSig, 0x41615252); - ST_DWORD(tbl+FSI_StrucSig, 0x61417272); - ST_DWORD(tbl+FSI_Free_Count, n_clst - 1); /* Number of free clusters */ - ST_DWORD(tbl+FSI_Nxt_Free, 2); /* Last allocated cluster# */ - ST_WORD(tbl+BS_55AA, 0xAA55); - disk_write(pdrv, tbl, b_vol + 1, 1); /* Write original (VBR+1) */ - disk_write(pdrv, tbl, b_vol + 7, 1); /* Write backup (VBR+7) */ - } - - return (disk_ioctl(pdrv, CTRL_SYNC, 0) == RES_OK) ? FR_OK : FR_DISK_ERR; -} - - - -#if _MULTI_PARTITION -/*-----------------------------------------------------------------------*/ -/* Divide Physical Drive */ -/*-----------------------------------------------------------------------*/ - -FRESULT f_fdisk ( - BYTE pdrv, /* Physical drive number */ - const DWORD szt[], /* Pointer to the size table for each partitions */ - void* work /* Pointer to the working buffer */ -) -{ - UINT i, n, sz_cyl, tot_cyl, b_cyl, e_cyl, p_cyl; - BYTE s_hd, e_hd, *p, *buf = (BYTE*)work; - DSTATUS stat; - DWORD sz_disk, sz_part, s_part; - - - stat = disk_initialize(pdrv); - if (stat & STA_NOINIT) return FR_NOT_READY; - if (stat & STA_PROTECT) return FR_WRITE_PROTECTED; - if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &sz_disk)) return FR_DISK_ERR; - - /* Determine CHS in the table regardless of the drive geometry */ - for (n = 16; n < 256 && sz_disk / n / 63 > 1024; n *= 2) ; - if (n == 256) n--; - e_hd = n - 1; - sz_cyl = 63 * n; - tot_cyl = sz_disk / sz_cyl; - - /* Create partition table */ - mem_set(buf, 0, _MAX_SS); - p = buf + MBR_Table; b_cyl = 0; - for (i = 0; i < 4; i++, p += SZ_PTE) { - p_cyl = (szt[i] <= 100U) ? (DWORD)tot_cyl * szt[i] / 100 : szt[i] / sz_cyl; - if (!p_cyl) continue; - s_part = (DWORD)sz_cyl * b_cyl; - sz_part = (DWORD)sz_cyl * p_cyl; - if (i == 0) { /* Exclude first track of cylinder 0 */ - s_hd = 1; - s_part += 63; sz_part -= 63; - } else { - s_hd = 0; - } - e_cyl = b_cyl + p_cyl - 1; - if (e_cyl >= tot_cyl) return FR_INVALID_PARAMETER; - - /* Set partition table */ - p[1] = s_hd; /* Start head */ - p[2] = (BYTE)((b_cyl >> 2) + 1); /* Start sector */ - p[3] = (BYTE)b_cyl; /* Start cylinder */ - p[4] = 0x06; /* System type (temporary setting) */ - p[5] = e_hd; /* End head */ - p[6] = (BYTE)((e_cyl >> 2) + 63); /* End sector */ - p[7] = (BYTE)e_cyl; /* End cylinder */ - ST_DWORD(p + 8, s_part); /* Start sector in LBA */ - ST_DWORD(p + 12, sz_part); /* Partition size */ - - /* Next partition */ - b_cyl += p_cyl; - } - ST_WORD(p, 0xAA55); - - /* Write it to the MBR */ - return (disk_write(pdrv, buf, 0, 1) || disk_ioctl(pdrv, CTRL_SYNC, 0)) ? FR_DISK_ERR : FR_OK; -} - - -#endif /* _MULTI_PARTITION */ -#endif /* _USE_MKFS && !_FS_READONLY */ - - - - -#if _USE_STRFUNC -/*-----------------------------------------------------------------------*/ -/* Get a string from the file */ -/*-----------------------------------------------------------------------*/ - -TCHAR* f_gets ( - TCHAR* buff, /* Pointer to the string buffer to read */ - int len, /* Size of string buffer (characters) */ - FIL* fp /* Pointer to the file object */ -) -{ - int n = 0; - TCHAR c, *p = buff; - BYTE s[2]; - UINT rc; - - - while (n < len - 1) { /* Read characters until buffer gets filled */ -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Read a character in UTF-8 */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (c >= 0x80) { - if (c < 0xC0) continue; /* Skip stray trailer */ - if (c < 0xE0) { /* Two-byte sequence */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c & 0x1F) << 6 | (s[0] & 0x3F); - if (c < 0x80) c = '?'; - } else { - if (c < 0xF0) { /* Three-byte sequence */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = c << 12 | (s[0] & 0x3F) << 6 | (s[1] & 0x3F); - if (c < 0x800) c = '?'; - } else { /* Reject four-byte sequence */ - c = '?'; - } - } - } -#elif _STRF_ENCODE == 2 /* Read a character in UTF-16BE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[1] + (s[0] << 8); -#elif _STRF_ENCODE == 1 /* Read a character in UTF-16LE */ - f_read(fp, s, 2, &rc); - if (rc != 2) break; - c = s[0] + (s[1] << 8); -#else /* Read a character in ANSI/OEM */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; - if (IsDBCS1(c)) { - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = (c << 8) + s[0]; - } - c = ff_convert(c, 1); /* OEM -> Unicode */ - if (!c) c = '?'; -#endif -#else /* Read a character without conversion */ - f_read(fp, s, 1, &rc); - if (rc != 1) break; - c = s[0]; -#endif - if (_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */ - *p++ = c; - n++; - if (c == '\n') break; /* Break on EOL */ - } - *p = 0; - return n ? buff : 0; /* When no data read (eof or error), return with error. */ -} - - - -#if !_FS_READONLY -#include -/*-----------------------------------------------------------------------*/ -/* Put a character to the file */ -/*-----------------------------------------------------------------------*/ - -typedef struct { - FIL* fp; - int idx, nchr; - BYTE buf[64]; -} putbuff; - - -static -void putc_bfd ( - putbuff* pb, - TCHAR c -) -{ - UINT bw; - int i; - - - if (_USE_STRFUNC == 2 && c == '\n') /* LF -> CRLF conversion */ - putc_bfd(pb, '\r'); - - i = pb->idx; /* Buffer write index (-1:error) */ - if (i < 0) return; - -#if _USE_LFN && _LFN_UNICODE -#if _STRF_ENCODE == 3 /* Write a character in UTF-8 */ - if (c < 0x80) { /* 7-bit */ - pb->buf[i++] = (BYTE)c; - } else { - if (c < 0x800) { /* 11-bit */ - pb->buf[i++] = (BYTE)(0xC0 | c >> 6); - } else { /* 16-bit */ - pb->buf[i++] = (BYTE)(0xE0 | c >> 12); - pb->buf[i++] = (BYTE)(0x80 | (c >> 6 & 0x3F)); - } - pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F)); - } -#elif _STRF_ENCODE == 2 /* Write a character in UTF-16BE */ - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#elif _STRF_ENCODE == 1 /* Write a character in UTF-16LE */ - pb->buf[i++] = (BYTE)c; - pb->buf[i++] = (BYTE)(c >> 8); -#else /* Write a character in ANSI/OEM */ - c = ff_convert(c, 0); /* Unicode -> OEM */ - if (!c) c = '?'; - if (c >= 0x100) - pb->buf[i++] = (BYTE)(c >> 8); - pb->buf[i++] = (BYTE)c; -#endif -#else /* Write a character without conversion */ - pb->buf[i++] = (BYTE)c; -#endif - - if (i >= (int)(sizeof pb->buf) - 3) { /* Write buffered characters to the file */ - f_write(pb->fp, pb->buf, (UINT)i, &bw); - i = (bw == (UINT)i) ? 0 : -1; - } - pb->idx = i; - pb->nchr++; -} - - - -int f_putc ( - TCHAR c, /* A character to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - putc_bfd(&pb, c); /* Put a character */ - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_puts ( - const TCHAR* str, /* Pointer to the string to be output */ - FIL* fp /* Pointer to the file object */ -) -{ - putbuff pb; - UINT nw; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - while (*str) /* Put the string */ - putc_bfd(&pb, *str++); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Put a formatted string to the file */ -/*-----------------------------------------------------------------------*/ - -int f_printf ( - FIL* fp, /* Pointer to the file object */ - const TCHAR* fmt, /* Pointer to the format string */ - ... /* Optional arguments... */ -) -{ - va_list arp; - BYTE f, r; - UINT nw, i, j, w; - DWORD v; - TCHAR c, d, s[16], *p; - putbuff pb; - - - pb.fp = fp; /* Initialize output buffer */ - pb.nchr = pb.idx = 0; - - va_start(arp, fmt); - - for (;;) { - c = *fmt++; - if (c == 0) break; /* End of string */ - if (c != '%') { /* Non escape character */ - putc_bfd(&pb, c); - continue; - } - w = f = 0; - c = *fmt++; - if (c == '0') { /* Flag: '0' padding */ - f = 1; c = *fmt++; - } else { - if (c == '-') { /* Flag: left justified */ - f = 2; c = *fmt++; - } - } - while (IsDigit(c)) { /* Precision */ - w = w * 10 + c - '0'; - c = *fmt++; - } - if (c == 'l' || c == 'L') { /* Prefix: Size is long int */ - f |= 4; c = *fmt++; - } - if (!c) break; - d = c; - if (IsLower(d)) d -= 0x20; - switch (d) { /* Type is... */ - case 'S' : /* String */ - p = va_arg(arp, TCHAR*); - for (j = 0; p[j]; j++) ; - if (!(f & 2)) { - while (j++ < w) putc_bfd(&pb, ' '); - } - while (*p) putc_bfd(&pb, *p++); - while (j++ < w) putc_bfd(&pb, ' '); - continue; - case 'C' : /* Character */ - putc_bfd(&pb, (TCHAR)va_arg(arp, int)); continue; - case 'B' : /* Binary */ - r = 2; break; - case 'O' : /* Octal */ - r = 8; break; - case 'D' : /* Signed decimal */ - case 'U' : /* Unsigned decimal */ - r = 10; break; - case 'X' : /* Hexdecimal */ - r = 16; break; - default: /* Unknown type (pass-through) */ - putc_bfd(&pb, c); continue; - } - - /* Get an argument and put it in numeral */ - v = (f & 4) ? (DWORD)va_arg(arp, long) : ((d == 'D') ? (DWORD)(long)va_arg(arp, int) : (DWORD)va_arg(arp, unsigned int)); - if (d == 'D' && (v & 0x80000000)) { - v = 0 - v; - f |= 8; - } - i = 0; - do { - d = (TCHAR)(v % r); v /= r; - if (d > 9) d += (c == 'x') ? 0x27 : 0x07; - s[i++] = d + '0'; - } while (v && i < sizeof s / sizeof s[0]); - if (f & 8) s[i++] = '-'; - j = i; d = (f & 1) ? '0' : ' '; - while (!(f & 2) && j++ < w) putc_bfd(&pb, d); - do putc_bfd(&pb, s[--i]); while (i); - while (j++ < w) putc_bfd(&pb, d); - } - - va_end(arp); - - if ( pb.idx >= 0 /* Flush buffered characters to the file */ - && f_write(pb.fp, pb.buf, (UINT)pb.idx, &nw) == FR_OK - && (UINT)pb.idx == nw) return pb.nchr; - return EOF; -} - -#endif /* !_FS_READONLY */ -#endif /* _USE_STRFUNC */ +/*----------------------------------------------------------------------------/ +/ FatFs - FAT file system module R0.10b (C)ChaN, 2014 +/-----------------------------------------------------------------------------/ +/ FatFs module is a generic FAT file system module for small embedded systems. +/ This is a free software that opened for education, research and commercial +/ developments under license policy of following terms. +/ +/ Copyright (C) 2014, ChaN, all right reserved. +/ +/ * The FatFs module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/-----------------------------------------------------------------------------/ +/ Feb 26,'06 R0.00 Prototype. +/ +/ Apr 29,'06 R0.01 First stable version. +/ +/ Jun 01,'06 R0.02 Added FAT12 support. +/ Removed unbuffered mode. +/ Fixed a problem on small (<32M) partition. +/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM). +/ +/ Sep 22,'06 R0.03 Added f_rename(). +/ Changed option _FS_MINIMUM to _FS_MINIMIZE. +/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast. +/ Fixed f_mkdir() creates incorrect directory on FAT32. +/ +/ Feb 04,'07 R0.04 Supported multiple drive system. +/ Changed some interfaces for multiple drive system. +/ Changed f_mountdrv() to f_mount(). +/ Added f_mkfs(). +/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive. +/ Added a capability of extending file size to f_lseek(). +/ Added minimization level 3. +/ Fixed an endian sensitive code in f_mkfs(). +/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG. +/ Added FSINFO support. +/ Fixed DBCS name can result FR_INVALID_NAME. +/ Fixed short seek (<= csize) collapses the file object. +/ +/ Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs(). +/ Fixed f_mkfs() on FAT32 creates incorrect FSINFO. +/ Fixed f_mkdir() on FAT32 creates incorrect directory. +/ Feb 03,'08 R0.05a Added f_truncate() and f_utime(). +/ Fixed off by one error at FAT sub-type determination. +/ Fixed btr in f_read() can be mistruncated. +/ Fixed cached sector is not flushed when create and close without write. +/ +/ Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets(). +/ Improved performance of f_lseek() on moving to the same or following cluster. +/ +/ Apr 01,'09 R0.07 Merged Tiny-FatFs as a configuration option. (_FS_TINY) +/ Added long file name feature. +/ Added multiple code page feature. +/ Added re-entrancy for multitask operation. +/ Added auto cluster size selection to f_mkfs(). +/ Added rewind option to f_readdir(). +/ Changed result code of critical errors. +/ Renamed string functions to avoid name collision. +/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg. +/ Added multiple sector size feature. +/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error. +/ Fixed wrong cache control in f_lseek(). +/ Added relative path feature. +/ Added f_chdir() and f_chdrive(). +/ Added proper case conversion to extended character. +/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h. +/ Fixed f_unlink() fails to remove a sub-directory on _FS_RPATH. +/ Fixed name matching error on the 13 character boundary. +/ Added a configuration option, _LFN_UNICODE. +/ Changed f_readdir() to return the SFN with always upper case on non-LFN cfg. +/ +/ May 15,'10 R0.08 Added a memory configuration option. (_USE_LFN = 3) +/ Added file lock feature. (_FS_SHARE) +/ Added fast seek feature. (_USE_FASTSEEK) +/ Changed some types on the API, XCHAR->TCHAR. +/ Changed .fname in the FILINFO str