CLEON  Version 1
Cloud-Offloaded GPS Receiver
ff.h File Reference
#include "integer.h"
#include "ffconf.h"
Include dependency graph for ff.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  FATFS
 
struct  FIL
 
struct  DIR
 
struct  FILINFO
 

Macros

#define _FATFS   4004 /* Revision ID */
 
#define LD2PD(vol)   (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */
 
#define LD2PT(vol)   0 /* Always mounts the 1st partition or in SFD */
 
#define _T(x)   x
 
#define _TEXT(x)   x
 
#define f_eof(fp)   (((fp)->fptr == (fp)->fsize) ? 1 : 0)
 
#define f_error(fp)   (((fp)->flag & FA__ERROR) ? 1 : 0)
 
#define f_tell(fp)   ((fp)->fptr)
 
#define f_size(fp)   ((fp)->fsize)
 
#define EOF   (-1)
 
#define FA_READ   0x01
 
#define FA_OPEN_EXISTING   0x00
 
#define FA__ERROR   0x80
 
#define FA_WRITE   0x02
 
#define FA_CREATE_NEW   0x04
 
#define FA_CREATE_ALWAYS   0x08
 
#define FA_OPEN_ALWAYS   0x10
 
#define FA__WRITTEN   0x20
 
#define FA__DIRTY   0x40
 
#define FS_FAT12   1
 
#define FS_FAT16   2
 
#define FS_FAT32   3
 
#define AM_RDO   0x01 /* Read only */
 
#define AM_HID   0x02 /* Hidden */
 
#define AM_SYS   0x04 /* System */
 
#define AM_VOL   0x08 /* Volume label */
 
#define AM_LFN   0x0F /* LFN entry */
 
#define AM_DIR   0x10 /* Directory */
 
#define AM_ARC   0x20 /* Archive */
 
#define AM_MASK   0x3F /* Mask of defined bits */
 
#define CREATE_LINKMAP   0xFFFFFFFF
 
#define LD_WORD(ptr)   (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))
 
#define LD_DWORD(ptr)   (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))
 
#define ST_WORD(ptr, val)   *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)
 
#define ST_DWORD(ptr, val)   *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)
 

Typedefs

typedef char TCHAR
 

Enumerations

enum  FRESULT {
  FR_OK = 0, 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_MKFS_ABORTED, FR_TIMEOUT,
  FR_LOCKED, FR_NOT_ENOUGH_CORE, FR_TOO_MANY_OPEN_FILES, FR_INVALID_PARAMETER
}
 

Functions

FRESULT f_mount (BYTE, FATFS *)
 
FRESULT f_open (FIL *, const TCHAR *, BYTE)
 
FRESULT f_read (FIL *, void *, UINT, UINT *)
 
FRESULT f_lseek (FIL *, DWORD)
 
FRESULT f_close (FIL *)
 
FRESULT f_opendir (DIR *, const TCHAR *)
 
FRESULT f_readdir (DIR *, FILINFO *)
 
FRESULT f_stat (const TCHAR *, FILINFO *)
 
FRESULT f_write (FIL *, const void *, UINT, UINT *)
 
FRESULT f_getfree (const TCHAR *, DWORD *, FATFS **)
 
FRESULT f_truncate (FIL *)
 
FRESULT f_sync (FIL *)
 
FRESULT f_unlink (const TCHAR *)
 
FRESULT f_mkdir (const TCHAR *)
 
FRESULT f_chmod (const TCHAR *, BYTE, BYTE)
 
FRESULT f_utime (const TCHAR *, const FILINFO *)
 
FRESULT f_rename (const TCHAR *, const TCHAR *)
 
FRESULT f_chdrive (BYTE)
 
FRESULT f_chdir (const TCHAR *)
 
FRESULT f_getcwd (TCHAR *, UINT)
 
FRESULT f_forward (FIL *, UINT(*)(const BYTE *, UINT), UINT, UINT *)
 
FRESULT f_mkfs (BYTE, BYTE, UINT)
 
FRESULT f_fdisk (BYTE, const DWORD[], void *)
 
int f_putc (TCHAR, FIL *)
 
int f_puts (const TCHAR *, FIL *)
 
int f_printf (FIL *, const TCHAR *,...)
 
TCHARf_gets (TCHAR *, int, FIL *)
 
FRESULT scan_files (char *path)
 
DWORD get_fattime (void)
 
WCHAR ff_convert (WCHAR, UINT)
 
WCHAR ff_wtoupper (WCHAR)
 

Macro Definition Documentation

#define _FATFS   4004 /* Revision ID */

Definition at line 18 of file ff.h.

#define _T (   x)    x

Definition at line 61 of file ff.h.

#define _TEXT (   x)    x

Definition at line 62 of file ff.h.

#define AM_ARC   0x20 /* Archive */

Definition at line 279 of file ff.h.

#define AM_DIR   0x10 /* Directory */

Definition at line 278 of file ff.h.

#define AM_HID   0x02 /* Hidden */

Definition at line 274 of file ff.h.

#define AM_LFN   0x0F /* LFN entry */

Definition at line 277 of file ff.h.

#define AM_MASK   0x3F /* Mask of defined bits */

Definition at line 280 of file ff.h.

#define AM_RDO   0x01 /* Read only */

Definition at line 273 of file ff.h.

#define AM_SYS   0x04 /* System */

Definition at line 275 of file ff.h.

#define AM_VOL   0x08 /* Volume label */

Definition at line 276 of file ff.h.

#define CREATE_LINKMAP   0xFFFFFFFF

Definition at line 283 of file ff.h.

#define EOF   (-1)

Definition at line 221 of file ff.h.

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

Definition at line 215 of file ff.h.

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

Definition at line 216 of file ff.h.

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

Definition at line 218 of file ff.h.

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

Definition at line 217 of file ff.h.

#define FA__DIRTY   0x40

Definition at line 264 of file ff.h.

#define FA__ERROR   0x80

Definition at line 256 of file ff.h.

#define FA__WRITTEN   0x20

Definition at line 263 of file ff.h.

#define FA_CREATE_ALWAYS   0x08

Definition at line 261 of file ff.h.

#define FA_CREATE_NEW   0x04

Definition at line 260 of file ff.h.

#define FA_OPEN_ALWAYS   0x10

Definition at line 262 of file ff.h.

#define FA_OPEN_EXISTING   0x00

Definition at line 255 of file ff.h.

#define FA_READ   0x01

Definition at line 254 of file ff.h.

#define FA_WRITE   0x02

Definition at line 259 of file ff.h.

#define FS_FAT12   1

Definition at line 268 of file ff.h.

#define FS_FAT16   2

Definition at line 269 of file ff.h.

#define FS_FAT32   3

Definition at line 270 of file ff.h.

#define LD2PD (   vol)    (BYTE)(vol) /* Each logical drive is bound to the same physical drive number */

Definition at line 42 of file ff.h.

#define LD2PT (   vol)    0 /* Always mounts the 1st partition or in SFD */

Definition at line 43 of file ff.h.

#define LD_DWORD (   ptr)    (DWORD)(((DWORD)*((BYTE*)(ptr)+3)<<24)|((DWORD)*((BYTE*)(ptr)+2)<<16)|((WORD)*((BYTE*)(ptr)+1)<<8)|*(BYTE*)(ptr))

Definition at line 294 of file ff.h.

#define LD_WORD (   ptr)    (WORD)(((WORD)*((BYTE*)(ptr)+1)<<8)|(WORD)*(BYTE*)(ptr))

Definition at line 293 of file ff.h.

#define ST_DWORD (   ptr,
  val 
)    *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8); *((BYTE*)(ptr)+2)=(BYTE)((DWORD)(val)>>16); *((BYTE*)(ptr)+3)=(BYTE)((DWORD)(val)>>24)

Definition at line 296 of file ff.h.

#define ST_WORD (   ptr,
  val 
)    *(BYTE*)(ptr)=(BYTE)(val); *((BYTE*)(ptr)+1)=(BYTE)((WORD)(val)>>8)

Definition at line 295 of file ff.h.

Typedef Documentation

typedef char TCHAR

Definition at line 60 of file ff.h.

Enumeration Type Documentation

enum FRESULT
Enumerator:
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_MKFS_ABORTED 
FR_TIMEOUT 
FR_LOCKED 
FR_NOT_ENOUGH_CORE 
FR_TOO_MANY_OPEN_FILES 
FR_INVALID_PARAMETER 

Definition at line 160 of file ff.h.

{
FR_OK = 0, /* (0) Succeeded */
FR_DISK_ERR, /* (1) A hard error occurred in the low level disk I/O layer */
FR_INT_ERR, /* (2) Assertion failed */
FR_NOT_READY, /* (3) The physical drive cannot work */
FR_NO_FILE, /* (4) Could not find the file */
FR_NO_PATH, /* (5) Could not find the path */
FR_INVALID_NAME, /* (6) The path name format is invalid */
FR_DENIED, /* (7) Access denied due to prohibited access or directory full */
FR_EXIST, /* (8) Access denied due to prohibited access */
FR_INVALID_OBJECT, /* (9) The file/directory object is invalid */
FR_WRITE_PROTECTED, /* (10) The physical drive is write protected */
FR_INVALID_DRIVE, /* (11) The logical drive number is invalid */
FR_NOT_ENABLED, /* (12) The volume has no work area */
FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */
FR_MKFS_ABORTED, /* (14) The f_mkfs() aborted due to any parameter error */
FR_TIMEOUT, /* (15) Could not get a grant to access the volume within defined period */
FR_LOCKED, /* (16) The operation is rejected according to the file sharing policy */
FR_NOT_ENOUGH_CORE, /* (17) LFN working buffer could not be allocated */
FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_SHARE */
FR_INVALID_PARAMETER /* (19) Given parameter is invalid */

Function Documentation

FRESULT f_chdir ( const TCHAR )
FRESULT f_chdrive ( BYTE  )
FRESULT f_chmod ( const TCHAR ,
BYTE  ,
BYTE   
)

Definition at line 3435 of file ff.c.

{
FRESULT res;
DIR dj;
BYTE *dir;
res = chk_mounted(&path, &dj.fs, 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))
if (res == FR_OK) {
dir = dj.dir;
if (!dir) { /* Is it a root directory? */
} 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(dj.fs);
}
}
}
LEAVE_FF(dj.fs, res);
}
FRESULT f_close ( FIL )

Definition at line 2728 of file ff.c.

{
FRESULT res;
#if _FS_READONLY
res = validate(fp);
{
#if _FS_REENTRANT
FATFS *fs = fp->fs;
#endif
if (res == FR_OK) fp->fs = 0; /* Discard file object */
LEAVE_FF(fs, res);
}
#else
res = f_sync(fp); /* Flush cached data */
#if _FS_LOCK
if (res == FR_OK) { /* Decrement open counter */
#if _FS_REENTRANT
FATFS *fs = fp->fs;;
res = validate(fp);
if (res == FR_OK) {
res = dec_lock(fp->lockid);
unlock_fs(fs, FR_OK);
}
#else
res = dec_lock(fp->lockid);
#endif
}
#endif
if (res == FR_OK) fp->fs = 0; /* Discard file object */
return res;
#endif
}

Here is the call graph for this function:

FRESULT f_fdisk ( BYTE  ,
const DWORD  [],
void *   
)
FRESULT f_forward ( FIL ,
UINT(*)(const BYTE *, UINT ,
UINT  ,
UINT  
)
FRESULT f_getcwd ( TCHAR ,
UINT   
)
FRESULT f_getfree ( const TCHAR ,
DWORD ,
FATFS **   
)

Definition at line 3177 of file ff.c.

{
FRESULT res;
FATFS *fs;
DWORD n, clst, sect, stat;
UINT i;
BYTE fat, *p;
/* Get drive number */
res = chk_mounted(&path, fatfs, 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;
if (fat == FS_FAT32) fs->fsi_flag = 1;
*nclst = n;
}
}
LEAVE_FF(fs, res);
}

Here is the call graph for this function:

TCHAR* f_gets ( TCHAR ,
int  ,
FIL  
)
FRESULT f_lseek ( FIL ,
DWORD   
)

Definition at line 2897 of file ff.c.

{
FRESULT res;
res = validate(fp); /* Check validity of the object */
if (res != FR_OK) LEAVE_FF(fp->fs, res);
if (fp->flag & FA__ERROR) /* Check abort flag */
LEAVE_FF(fp->fs, FR_INT_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) != RES_OK)
ABORT(fp->fs, FR_DISK_ERR);
fp->flag &= ~FA__DIRTY;
}
#endif
if (disk_read(fp->fs->drv, fp->buf, dsc, 1) != RES_OK) /* 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 */
&& !(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) != RES_OK)
ABORT(fp->fs, FR_DISK_ERR);
fp->flag &= ~FA__DIRTY;
}
#endif
if (disk_read(fp->fs->drv, fp->buf, nsect, 1) != RES_OK) /* 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);
}

Here is the call graph for this function:

FRESULT f_mkdir ( const TCHAR )

Definition at line 3362 of file ff.c.

{
FRESULT res;
DIR dj;
BYTE *dir, n;
DWORD dsc, dcl, pcl, tim = get_fattime();
res = chk_mounted(&path, &dj.fs, 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))
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 = move_window(dj.fs, 0);
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, ' ', 8+3); /* Create "." entry */
dir[DIR_Name] = '.';
dir[DIR_Attr] = AM_DIR;
ST_DWORD(dir+DIR_WrtTime, tim);
st_clust(dir, dcl);
mem_cpy(dir+SZ_DIR, dir, SZ_DIR); /* Create ".." entry */
dir[33] = '.'; 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 = move_window(dj.fs, 0);
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, tim); /* Created time */
st_clust(dir, dcl); /* Table start cluster */
dj.fs->wflag = 1;
res = sync(dj.fs);
}
}
}
LEAVE_FF(dj.fs, res);
}

Here is the call graph for this function:

FRESULT f_mkfs ( BYTE  ,
BYTE  ,
UINT   
)
FRESULT f_mount ( BYTE  ,
FATFS  
)

Definition at line 2288 of file ff.c.

{
FATFS *rfs;
if (vol >= _VOLUMES) /* Check if the drive number is valid */
rfs = FatFs[vol]; /* Get current fs object */
if (rfs) {
#if _FS_LOCK
clear_lock(rfs);
#endif
#if _FS_REENTRANT /* Discard sync object of the current volume */
if (!ff_del_syncobj(rfs->sobj)) return FR_INT_ERR;
#endif
rfs->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(vol, &fs->sobj)) return FR_INT_ERR;
#endif
}
FatFs[vol] = fs; /* Register new fs object */
return FR_OK;
}
FRESULT f_open ( FIL ,
const TCHAR ,
BYTE   
)

Definition at line 2328 of file ff.c.

{
FRESULT res;
DIR dj;
BYTE *dir;
if (!fp) return FR_INVALID_OBJECT;
fp->fs = 0; /* Clear file object */
#if !_FS_READONLY
res = chk_mounted(&path, &dj.fs, (BYTE)(mode & ~FA_READ));
#else
mode &= FA_READ;
res = chk_mounted(&path, &dj.fs, 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) /* Current dir itself */
#if _FS_LOCK
else
res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0);
#endif
}
/* Create or Open a file */
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 */
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 dir itself */
} else {
if (dir[DIR_Attr] & AM_DIR) /* It is a directory */
res = FR_NO_FILE;
}
}
#endif
if (res == FR_OK) {
fp->flag = mode; /* File access mode */
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; fp->id = dj.fs->id; /* Validate file object */
}
}
LEAVE_FF(dj.fs, res);
}

Here is the call graph for this function:

FRESULT f_opendir ( DIR ,
const TCHAR  
)

Definition at line 3055 of file ff.c.

{
FRESULT res;
FATFS *fs;
if (!dj) return FR_INVALID_OBJECT;
res = chk_mounted(&path, &dj->fs, 0);
fs = dj->fs;
if (res == FR_OK) {
INIT_BUF(*dj);
res = follow_path(dj, path); /* Follow the path to the directory */
if (res == FR_OK) { /* Follow completed */
if (dj->dir) { /* It is not the root dir */
if (dj->dir[DIR_Attr] & AM_DIR) { /* The object is a directory */
dj->sclust = ld_clust(fs, dj->dir);
} else { /* The object is not a directory */
res = FR_NO_PATH;
}
}
if (res == FR_OK) {
dj->id = fs->id;
res = dir_sdi(dj, 0); /* Rewind dir */
}
}
if (res == FR_NO_FILE) res = FR_NO_PATH;
if (res != FR_OK) dj->fs = 0; /* Invalidate the dir object if function faild */
} else {
dj->fs = 0;
}
LEAVE_FF(fs, res);
}

Here is the caller graph for this function:

int f_printf ( FIL ,
const TCHAR ,
  ... 
)
int f_putc ( TCHAR  ,
FIL  
)
int f_puts ( const TCHAR ,
FIL  
)
FRESULT f_read ( FIL ,
void *  ,
UINT  ,
UINT  
)

Definition at line 2460 of file ff.c.

{
FRESULT res;
DWORD clst, sect, remain;
UINT rcnt, cc;
BYTE csect, *rbuff = buff;
*br = 0; /* Clear read byte counter */
res = validate(fp); /* Check validity */
if (res != FR_OK) LEAVE_FF(fp->fs, res);
if (fp->flag & FA__ERROR) /* Aborted file? */
LEAVE_FF(fp->fs, FR_INT_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, (BYTE)cc) != RES_OK)
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) != RES_OK)
ABORT(fp->fs, FR_DISK_ERR);
fp->flag &= ~FA__DIRTY;
}
#endif
if (disk_read(fp->fs->drv, fp->buf, sect, 1) != RES_OK) /* 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);
}

Here is the call graph for this function:

FRESULT f_readdir ( DIR ,
FILINFO  
)

Definition at line 3102 of file ff.c.

{
FRESULT res;
res = validate(dj); /* Check validity of the object */
if (res == FR_OK) {
if (!fno) {
res = dir_sdi(dj, 0); /* Rewind the directory object */
} else {
INIT_BUF(*dj);
res = dir_read(dj); /* Read an directory item */
if (res == FR_NO_FILE) { /* Reached end of dir */
dj->sect = 0;
res = FR_OK;
}
if (res == FR_OK) { /* A valid entry is found */
get_fileinfo(dj, fno); /* Get the object information */
res = dir_next(dj, 0); /* Increment index for next */
if (res == FR_NO_FILE) {
dj->sect = 0;
res = FR_OK;
}
}
}
}
LEAVE_FF(dj->fs, res);
}

Here is the caller graph for this function:

FRESULT f_rename ( const TCHAR ,
const TCHAR  
)

Definition at line 3518 of file ff.c.

{
FRESULT res;
DIR djo, djn;
BYTE buf[21], *dir;
DWORD dw;
res = chk_mounted(&path_old, &djo.fs, 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))
#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 for name */
mem_cpy(&djn, &djo, sizeof (DIR)); /* Check new object */
res = follow_path(&djn, path_new);
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 an interruption or error can cause cross-link */
res = dir_register(&djn); /* Register the new entry */
if (res == FR_OK) {
dir = djn.dir; /* Copy object information except for 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(djo.fs);
}
}
/* End critical section */
}
}
}
}
LEAVE_FF(djo.fs, res);
}

Here is the call graph for this function:

FRESULT f_stat ( const TCHAR ,
FILINFO  
)

Definition at line 3144 of file ff.c.

{
FRESULT res;
DIR dj;
res = chk_mounted(&path, &dj.fs, 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 */
get_fileinfo(&dj, fno);
else /* It is root dir */
}
}
LEAVE_FF(dj.fs, res);
}
FRESULT f_sync ( FIL )

Definition at line 2680 of file ff.c.

{
FRESULT res;
DWORD tim;
BYTE *dir;
res = validate(fp); /* Check validity of the object */
if (res == FR_OK) {
if (fp->flag & FA__WRITTEN) { /* Has the file been written? */
#if !_FS_TINY /* Write-back dirty buffer */
if (fp->flag & FA__DIRTY) {
if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
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 */
tim = get_fattime(); /* Update updated time */
ST_DWORD(dir+DIR_WrtTime, tim);
fp->flag &= ~FA__WRITTEN;
fp->fs->wflag = 1;
res = sync(fp->fs);
}
}
}
LEAVE_FF(fp->fs, res);
}

Here is the call graph for this function:

Here is the caller graph for this function:

FRESULT f_truncate ( FIL )

Definition at line 3244 of file ff.c.

{
FRESULT res;
DWORD ncl;
if (!fp) return FR_INVALID_OBJECT;
res = validate(fp); /* Check validity of the object */
if (res == FR_OK) {
if (fp->flag & FA__ERROR) { /* Check abort flag */
res = FR_INT_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 (res != FR_OK) fp->flag |= FA__ERROR;
}
LEAVE_FF(fp->fs, res);
}

Here is the call graph for this function:

FRESULT f_unlink ( const TCHAR )

Definition at line 3294 of file ff.c.

{
FRESULT res;
DIR dj, sdj;
BYTE *dir;
DWORD dclst;
res = chk_mounted(&path, &dj.fs, 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-dir is empty or not */
sdj.sclust = dclst;
res = dir_sdi(&sdj, 2); /* Exclude dot entries */
if (res == FR_OK) {
res = dir_read(&sdj);
if (res == FR_OK /* Not empty dir */
|| dclst == dj.fs->cdir /* Current dir */
#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(dj.fs);
}
}
}
}
LEAVE_FF(dj.fs, res);
}
FRESULT f_utime ( const TCHAR ,
const FILINFO  
)

Definition at line 3477 of file ff.c.

{
FRESULT res;
DIR dj;
BYTE *dir;
res = chk_mounted(&path, &dj.fs, 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))
if (res == FR_OK) {
dir = dj.dir;
if (!dir) { /* Root directory */
} 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(dj.fs);
}
}
}
LEAVE_FF(dj.fs, res);
}
FRESULT f_write ( FIL ,
const void *  ,
UINT  ,
UINT  
)

Definition at line 2561 of file ff.c.

{
FRESULT res;
DWORD clst, sect;
UINT wcnt, cc;
const BYTE *wbuff = 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->flag & FA__ERROR) /* Aborted file? */
LEAVE_FF(fp->fs, FR_INT_ERR);
if (!(fp->flag & FA_WRITE)) /* Check access mode */
LEAVE_FF(fp->fs, FR_DENIED);
if ((DWORD)(fp->fsize + btw) < fp->fsize) 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, */
fp->sclust = 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 _FS_TINY
if (fp->fs->winsect == fp->dsect && move_window(fp->fs, 0)) /* 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) != RES_OK)
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, (BYTE)cc) != RES_OK)
ABORT(fp->fs, FR_DISK_ERR);
#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
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 (move_window(fp->fs, 0)) 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) != RES_OK)
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);
}

Here is the call graph for this function:

WCHAR ff_convert ( WCHAR  ,
UINT   
)

Definition at line 500 of file ccsbcs.c.

{
WCHAR c;
if (src < 0x80) { /* ASCII */
c = src;
} else {
if (dir) { /* OEMCP to Unicode */
c = (src >= 0x100) ? 0 : Tbl[src - 0x80];
} else { /* Unicode to OEMCP */
for (c = 0; c < 0x80; c++) {
if (src == Tbl[c]) break;
}
c = (c + 0x80) & 0xFF;
}
}
return c;
}
WCHAR ff_wtoupper ( WCHAR  )

Definition at line 527 of file ccsbcs.c.

{
static const WCHAR tbl_lower[] = { 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0xA1, 0x00A2, 0x00A3, 0x00A5, 0x00AC, 0x00AF, 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0x0FF, 0x101, 0x103, 0x105, 0x107, 0x109, 0x10B, 0x10D, 0x10F, 0x111, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129, 0x12B, 0x12D, 0x12F, 0x131, 0x133, 0x135, 0x137, 0x13A, 0x13C, 0x13E, 0x140, 0x142, 0x144, 0x146, 0x148, 0x14B, 0x14D, 0x14F, 0x151, 0x153, 0x155, 0x157, 0x159, 0x15B, 0x15D, 0x15F, 0x161, 0x163, 0x165, 0x167, 0x169, 0x16B, 0x16D, 0x16F, 0x171, 0x173, 0x175, 0x177, 0x17A, 0x17C, 0x17E, 0x192, 0x3B1, 0x3B2, 0x3B3, 0x3B4, 0x3B5, 0x3B6, 0x3B7, 0x3B8, 0x3B9, 0x3BA, 0x3BB, 0x3BC, 0x3BD, 0x3BE, 0x3BF, 0x3C0, 0x3C1, 0x3C3, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 0x3C8, 0x3C9, 0x3CA, 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437, 0x438, 0x439, 0x43A, 0x43B, 0x43C, 0x43D, 0x43E, 0x43F, 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447, 0x448, 0x449, 0x44A, 0x44B, 0x44C, 0x44D, 0x44E, 0x44F, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457, 0x458, 0x459, 0x45A, 0x45B, 0x45C, 0x45E, 0x45F, 0x2170, 0x2171, 0x2172, 0x2173, 0x2174, 0x2175, 0x2176, 0x2177, 0x2178, 0x2179, 0x217A, 0x217B, 0x217C, 0x217D, 0x217E, 0x217F, 0xFF41, 0xFF42, 0xFF43, 0xFF44, 0xFF45, 0xFF46, 0xFF47, 0xFF48, 0xFF49, 0xFF4A, 0xFF4B, 0xFF4C, 0xFF4D, 0xFF4E, 0xFF4F, 0xFF50, 0xFF51, 0xFF52, 0xFF53, 0xFF54, 0xFF55, 0xFF56, 0xFF57, 0xFF58, 0xFF59, 0xFF5A, 0 };
static const WCHAR tbl_upper[] = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x21, 0xFFE0, 0xFFE1, 0xFFE5, 0xFFE2, 0xFFE3, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0x178, 0x100, 0x102, 0x104, 0x106, 0x108, 0x10A, 0x10C, 0x10E, 0x110, 0x112, 0x114, 0x116, 0x118, 0x11A, 0x11C, 0x11E, 0x120, 0x122, 0x124, 0x126, 0x128, 0x12A, 0x12C, 0x12E, 0x130, 0x132, 0x134, 0x136, 0x139, 0x13B, 0x13D, 0x13F, 0x141, 0x143, 0x145, 0x147, 0x14A, 0x14C, 0x14E, 0x150, 0x152, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E, 0x160, 0x162, 0x164, 0x166, 0x168, 0x16A, 0x16C, 0x16E, 0x170, 0x172, 0x174, 0x176, 0x179, 0x17B, 0x17D, 0x191, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398, 0x399, 0x39A, 0x39B, 0x39C, 0x39D, 0x39E, 0x39F, 0x3A0, 0x3A1, 0x3A3, 0x3A4, 0x3A5, 0x3A6, 0x3A7, 0x3A8, 0x3A9, 0x3AA, 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417, 0x418, 0x419, 0x41A, 0x41B, 0x41C, 0x41D, 0x41E, 0x41F, 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427, 0x428, 0x429, 0x42A, 0x42B, 0x42C, 0x42D, 0x42E, 0x42F, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407, 0x408, 0x409, 0x40A, 0x40B, 0x40C, 0x40E, 0x40F, 0x2160, 0x2161, 0x2162, 0x2163, 0x2164, 0x2165, 0x2166, 0x2167, 0x2168, 0x2169, 0x216A, 0x216B, 0x216C, 0x216D, 0x216E, 0x216F, 0xFF21, 0xFF22, 0xFF23, 0xFF24, 0xFF25, 0xFF26, 0xFF27, 0xFF28, 0xFF29, 0xFF2A, 0xFF2B, 0xFF2C, 0xFF2D, 0xFF2E, 0xFF2F, 0xFF30, 0xFF31, 0xFF32, 0xFF33, 0xFF34, 0xFF35, 0xFF36, 0xFF37, 0xFF38, 0xFF39, 0xFF3A, 0 };
int i;
for (i = 0; tbl_lower[i] && chr != tbl_lower[i]; i++) ;
return tbl_lower[i] ? tbl_upper[i] : chr;
}
DWORD get_fattime ( void  )

Definition at line 35 of file diskio.c.

{
DWORD tmr;
/* Pack date and time into a DWORD variable */
tmr = (((DWORD)(HAL_GetRTCYear()-1980)) << 25)
| ((DWORD)HAL_GetRTCMon() << 21)
| ((DWORD)HAL_GetRTCDay() << 16)
| (WORD)(((unsigned char) HAL_GetRTCHour()) << 11)
| (WORD)(((unsigned char) HAL_GetRTCMin()) << 5)
| (WORD)(((unsigned char) HAL_GetRTCSec()) >> 1);
return (tmr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

FRESULT scan_files ( char *  path)

Definition at line 2242 of file ff.c.

{
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];
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);
}
}
}
return res;
}

Here is the call graph for this function:

Here is the caller graph for this function: