From 6e5baa0aa7413733caafaa1e33395c36a941d5dc Mon Sep 17 00:00:00 2001 From: Terraneo Federico <fede.tft@hotmail.it> Date: Mon, 23 Dec 2013 18:26:47 +0000 Subject: [PATCH] Removed drive numbering scheme from FatFs --- miosix/filesystem/fat32/fat32.cpp | 5 +- miosix/filesystem/fat32/ff.cpp | 80 ++++++++++++------------ miosix/filesystem/fat32/ff.h | 4 +- miosix/filesystem/fat32/wtoupper.cpp | 2 + miosix_np_2/nbproject/configurations.xml | 6 ++ 5 files changed, 53 insertions(+), 44 deletions(-) diff --git a/miosix/filesystem/fat32/fat32.cpp b/miosix/filesystem/fat32/fat32.cpp index 17f331bc..09265a46 100644 --- a/miosix/filesystem/fat32/fat32.cpp +++ b/miosix/filesystem/fat32/fat32.cpp @@ -338,8 +338,7 @@ Fat32File::~Fat32File() Fat32Fs::Fat32Fs() : mutex(FastMutex::RECURSIVE), failed(true) { if(!Disk::isAvailable()) return; - TCHAR nul=0; - failed=f_mount(&filesystem,&nul,1)!=FR_OK; + failed=f_mount(&filesystem,1)!=FR_OK; } int Fat32Fs::open(intrusive_ref_ptr<FileBase>& file, StringPart& name, @@ -489,7 +488,7 @@ int Fat32Fs::rmdir(StringPart& name) Fat32Fs::~Fat32Fs() { if(failed) return; - f_mount(0,0,0); //TODO: what to do with error code? + f_mount(0,0); //TODO: what to do with error code? Disk::sync(); } diff --git a/miosix/filesystem/fat32/ff.cpp b/miosix/filesystem/fat32/ff.cpp index 27dd9bf2..a70fba4c 100644 --- a/miosix/filesystem/fat32/ff.cpp +++ b/miosix/filesystem/fat32/ff.cpp @@ -2020,30 +2020,32 @@ void get_fileinfo ( /* No return code */ /* 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 */ -) -{ - int vol = -1; - - - if (*path) { - vol = (*path)[0] - '0'; - if ((UINT)vol < 9 && (*path)[1] == ':') { /* There is a drive number */ - *path += 2; /* Get value and strip it */ - if (vol >= _VOLUMES) vol = -1; /* Check if the drive number is valid */ - } else { /* No drive number use default drive */ -#if _FS_RPATH && _VOLUMES >= 2 - vol = CurrVol; /* Current drive */ -#else - vol = 0; /* Drive 0 */ -#endif - } - } - - return vol; -} +//By TFT: We don't want this reminiscence of microsoft OSes identifying +//drive numbers with 0:/path/to/file +// static +// int get_ldnumber ( /* Returns logical drive number (-1:invalid drive) */ +// const TCHAR** path /* Pointer to pointer to the path name */ +// ) +// { +// int vol = -1; +// +// +// if (*path) { +// vol = (*path)[0] - '0'; +// if ((UINT)vol < 9 && (*path)[1] == ':') { /* There is a drive number */ +// *path += 2; /* Get value and strip it */ +// if (vol >= _VOLUMES) vol = -1; /* Check if the drive number is valid */ +// } else { /* No drive number use default drive */ +// #if _FS_RPATH && _VOLUMES >= 2 +// vol = CurrVol; /* Current drive */ +// #else +// vol = 0; /* Drive 0 */ +// #endif +// } +// } +// +// return vol; +// } @@ -2145,7 +2147,7 @@ BYTE check_fs ( /* 0:FAT boor sector, 1:Valid boor sector but not FAT, 2:Not a b 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) */ + /*const TCHAR** path,*/ /* Pointer to pointer to the path name (drive number) */ BYTE wmode /* !=0: Check write protection for write access */ ) { @@ -2159,7 +2161,7 @@ FRESULT find_volume ( /* FR_OK(0): successful, !=0: any error occurred */ /* Get logical drive number from the path name */ *rfs = 0; - vol = get_ldnumber(path); + vol = 0;//get_ldnumber(path); if (vol < 0) return FR_INVALID_DRIVE; /* Check if the file system object is valid or not */ @@ -2345,7 +2347,7 @@ FRESULT validate ( /* FR_OK(0): The object is valid, !=0: Invalid */ FRESULT f_mount ( FATFS* fs, /* Pointer to the file system object (NULL:unmount)*/ - const TCHAR* path, /* Logical drive number to be mounted/unmounted */ + /*const TCHAR* path,*/ /* Logical drive number to be mounted/unmounted */ BYTE opt /* 0:Do not mount (delayed mount), 1:Mount immediately */ ) { @@ -2354,7 +2356,7 @@ FRESULT f_mount ( FRESULT res; - vol = get_ldnumber(&path); + vol = 0;//get_ldnumber(&path); if (vol < 0) return FR_INVALID_DRIVE; cfs = FatFs[vol]; /* Pointer to fs object */ @@ -2378,7 +2380,7 @@ FRESULT f_mount ( 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 */ + res = find_volume(&fs, /*&path,*/ 0); /* Force mounted the volume */ LEAVE_FF(fs, res); } @@ -2407,7 +2409,7 @@ FRESULT f_open ( /* 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)); + res = find_volume(&dj.fs, /*&path,*/ (BYTE)(mode & ~FA_READ)); #else mode &= FA_READ; res = find_volume(&dj.fs, &path, 0); @@ -3145,7 +3147,7 @@ FRESULT f_opendir ( if (!dp) return FR_INVALID_OBJECT; /* Get logical drive number */ - res = find_volume(&fs, &path, 0); + res = find_volume(&fs, /*&path,*/ 0); if (res == FR_OK) { dp->fs = fs; INIT_BUF(*dp); @@ -3269,7 +3271,7 @@ FRESULT f_stat ( /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 0); + res = find_volume(&dj.fs, /*&path,*/ 0); if (res == FR_OK) { INIT_BUF(dj); res = follow_path(&dj, path); /* Follow the file path */ @@ -3294,7 +3296,7 @@ FRESULT f_stat ( /*-----------------------------------------------------------------------*/ FRESULT f_getfree ( - const TCHAR* path, /* Path name of the logical drive number */ + /*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 */ ) @@ -3307,7 +3309,7 @@ FRESULT f_getfree ( /* Get logical drive number */ - res = find_volume(fatfs, &path, 0); + res = find_volume(fatfs, /*&path,*/ 0); fs = *fatfs; if (res == FR_OK) { /* If free_clust is valid, return it without full cluster scan */ @@ -3428,7 +3430,7 @@ FRESULT f_unlink ( /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); + res = find_volume(&dj.fs, /*&path,*/ 1); if (res == FR_OK) { INIT_BUF(dj); res = follow_path(&dj, path); /* Follow the file path */ @@ -3498,7 +3500,7 @@ FRESULT f_mkdir ( /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); + res = find_volume(&dj.fs, /*&path,*/ 1); if (res == FR_OK) { INIT_BUF(dj); res = follow_path(&dj, path); /* Follow the file path */ @@ -3573,7 +3575,7 @@ FRESULT f_chmod ( /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); + res = find_volume(&dj.fs, /*&path,*/ 1); if (res == FR_OK) { INIT_BUF(dj); res = follow_path(&dj, path); /* Follow the file path */ @@ -3615,7 +3617,7 @@ FRESULT f_utime ( /* Get logical drive number */ - res = find_volume(&dj.fs, &path, 1); + res = find_volume(&dj.fs, /*&path,*/ 1); if (res == FR_OK) { INIT_BUF(dj); res = follow_path(&dj, path); /* Follow the file path */ @@ -3658,7 +3660,7 @@ FRESULT f_rename ( /* Get logical drive number of the source object */ - res = find_volume(&djo.fs, &path_old, 1); + res = find_volume(&djo.fs, /*&path_old,*/ 1); if (res == FR_OK) { djn.fs = djo.fs; INIT_BUF(djo); diff --git a/miosix/filesystem/fat32/ff.h b/miosix/filesystem/fat32/ff.h index 1b09f3a2..fb773d0a 100644 --- a/miosix/filesystem/fat32/ff.h +++ b/miosix/filesystem/fat32/ff.h @@ -226,10 +226,10 @@ FRESULT f_utime (const TCHAR* path, const FILINFO* fno); /* Change times-tamp FRESULT f_chdir (const TCHAR* path); /* Change current directory */ FRESULT f_chdrive (const TCHAR* path); /* Change current drive */ FRESULT f_getcwd (TCHAR* buff, UINT len); /* Get current directory */ -FRESULT f_getfree (const TCHAR* path, DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ +FRESULT f_getfree (/*const TCHAR* path,*/ DWORD* nclst, FATFS** fatfs); /* Get number of free clusters on the drive */ FRESULT f_getlabel (const TCHAR* path, TCHAR* label, DWORD* sn); /* Get volume label */ FRESULT f_setlabel (const TCHAR* label); /* Set volume label */ -FRESULT f_mount (FATFS* fs, const TCHAR* path, BYTE opt); /* Mount/Unmount a logical drive */ +FRESULT f_mount (FATFS* fs, /*const TCHAR* path,*/ BYTE opt); /* Mount/Unmount a logical drive */ FRESULT f_mkfs (const TCHAR* path, BYTE sfd, UINT au); /* Create a file system on the volume */ FRESULT f_fdisk (BYTE pdrv, const DWORD szt[], void* work); /* Divide a physical drive into some partitions */ int f_putc (TCHAR c, FIL* fp); /* Put a character to the file */ diff --git a/miosix/filesystem/fat32/wtoupper.cpp b/miosix/filesystem/fat32/wtoupper.cpp index 8cdf20cc..3b1cb6e8 100644 --- a/miosix/filesystem/fat32/wtoupper.cpp +++ b/miosix/filesystem/fat32/wtoupper.cpp @@ -1,4 +1,6 @@ +#include "ff.h" + /* * This is an alternative version of ff_wtoupper(), designed to be both smaller, * faster and to better conform to the unicode specification. diff --git a/miosix_np_2/nbproject/configurations.xml b/miosix_np_2/nbproject/configurations.xml index c88e3add..c52ff5b6 100644 --- a/miosix_np_2/nbproject/configurations.xml +++ b/miosix_np_2/nbproject/configurations.xml @@ -397,6 +397,8 @@ <in>lcd44780.h</in> <in>software_i2c.h</in> <in>software_spi.h</in> + <in>unicode.cpp</in> + <in>unicode.h</in> <in>util.cpp</in> <in>util.h</in> <in>version.cpp</in> @@ -3772,6 +3774,10 @@ </item> <item path="../miosix/util/software_spi.h" ex="false" tool="3" flavor2="0"> </item> + <item path="../miosix/util/unicode.cpp" ex="false" tool="1" flavor2="0"> + </item> + <item path="../miosix/util/unicode.h" ex="false" tool="3" flavor2="0"> + </item> <item path="../miosix/util/util.cpp" ex="false" tool="1" flavor2="0"> </item> <item path="../miosix/util/util.h" ex="false" tool="3" flavor2="0"> -- GitLab