mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
[FULLFAT]
- Update FullFat to the latest SVN code on James' recommendation. - This release has many advantages over the previous, including full UTF-8 and UTF-16 support and the ability to modify attributes and timestamps. All of which are important for ros. - It currently has a few warnings (in both gcc and msc), so I've had to turn allow warnings on. svn path=/trunk/; revision=51229
This commit is contained in:
@@ -34,108 +34,138 @@
|
||||
Here you can change the configuration of FullFAT as appropriate to your
|
||||
platform.
|
||||
*/
|
||||
|
||||
//---------- ENDIANESS
|
||||
#define FF_LITTLE_ENDIAN // Choosing the Byte-order of your system is important.
|
||||
//#define FF_BIG_ENDIAN // You may be able to provide better Byte-order swapping routines to FullFAT.
|
||||
// See ff_memory.c for more information.
|
||||
#define FF_LITTLE_ENDIAN // Choosing the Byte-order of your system is important.
|
||||
//#define FF_BIG_ENDIAN // You may be able to provide better Byte-order swapping routines to FullFAT.
|
||||
// See ff_memory.c for more information.
|
||||
|
||||
|
||||
//---------- LFN (Long File-name) SUPPORT
|
||||
#define FF_LFN_SUPPORT // Comment this out if you don't want to worry about Patent Issues.
|
||||
// FullFAT works great with LFNs and without. You choose, its your project!
|
||||
#define FF_LFN_SUPPORT // Comment this out if you don't want to worry about Patent Issues.
|
||||
// FullFAT works great with LFNs and without. You choose, its your project!
|
||||
|
||||
//---------- LEGAL LFNS
|
||||
//#define FF_LEGAL_LFNS // Enabling this define causes FullFAT to not infringe on any of Microsoft's patents when making LFN names.
|
||||
// To do this, it will only create LFNs and no shortnames. Microsofts patents are only relevent when mapping
|
||||
// a shortname to a long name. This is the same way that Linux gets around the FAT legal issues:
|
||||
// see http://lkml.org/lkml/2009/6/26/314
|
||||
//
|
||||
// Enabling this may break compatibility with devices that cannot read LFN filenames.
|
||||
// Enabling this option causes no compatibility issues when reading any media.
|
||||
|
||||
//---------- TIME SUPPORT
|
||||
#define FF_TIME_SUPPORT // Should FullFAT use time stamping. Only if you have provided the relevant time drivers in ff_time.c
|
||||
// Note, by default ff_time.c is set-up for the Windows Demonstration. Please see ff_time.c to disable.
|
||||
|
||||
//---------- FILE SPACE ALLOCATION PERFORMANCE
|
||||
// Uncomment the prefered method. (Can only choose a single method).
|
||||
#define FF_ALLOC_DEFAULT // Only allocate as much as is needed. (Provides good performance, without wasting space).
|
||||
//#define FF_ALLOC_DOUBLE // Doubles the size of a file each time allocation is required. (When high-performance writing is required).
|
||||
|
||||
//---------- Use Native STDIO.h
|
||||
//#define FF_USE_NATIVE_STDIO // Makes FullFAT conform to values provided by your native STDIO.h file.
|
||||
|
||||
//---------- FREE SPACE CALCULATION
|
||||
//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting).
|
||||
// If not done in the mount, it will be done on the first call to FF_GetFreeSize() function.
|
||||
|
||||
//---------- PATH CACHE
|
||||
#define FF_PATH_CACHE // Enables a simply Path Caching mechanism that increases performance of repeated operations
|
||||
// within the same path. E.g. a copy \dir1\*.* \dir2\*.* command.
|
||||
// This command requires FF_MAX_PATH number of bytes of memory. (Defined below, default 2600).
|
||||
|
||||
//---------- BLKDEV USES SEMAPHORE
|
||||
#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked
|
||||
// See also ff_safety.c
|
||||
// (HT addition)
|
||||
//#define FF_INCLUDE_SHORT_NAME // HT addition, in 'FF_DIRENT', beside FileName, ShortName will be filled as well
|
||||
// Useful for debugging, but also some situations its useful to know both.
|
||||
//---------- SHORTNAMES CAN USE THE CASE BITS
|
||||
#define FF_SHORTNAME_CASE // Works for XP+ e.g. short.TXT or SHORT.txt.
|
||||
|
||||
|
||||
#define FF_PATH_CACHE_DEPTH 2 // The Number of PATH's to Cache.
|
||||
//---------- UNICODE SUPPORT
|
||||
//#define FF_UNICODE_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-16 formatted strings.
|
||||
// FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-16 format.
|
||||
// NOTE: This option may cause FullFAT to not "Clean-compile" when using GCC. This is because
|
||||
// pedantically GCC refuses to accept C99 library functions, unless the -std=c99 flag is used.
|
||||
// To use UNICODE (UTF-16, or UTF-32 depending on the size of wchar_t) you must have a C99 compliant
|
||||
// compiler and library.
|
||||
|
||||
//---------- DON'T USE MALLOC
|
||||
//#define FF_NO_MALLOC
|
||||
//#define FF_UNICODE_UTF8_SUPPORT // If this is defined, then all of FullFAT's API's will expect to receive UTF-8 formatted strings.
|
||||
// FF_FindFirst() and FF_FindNext() will also return Filenames in UTF-8 format.
|
||||
|
||||
#define FF_MALLOC(aSize) malloc(aSize)
|
||||
#define FF_FREE(apPtr) free(apPtr)
|
||||
|
||||
//#define FF_INLINE_MEMORY_ACCESS
|
||||
|
||||
//#define FF_INLINE static __forceinline // Keywords to inline functions (Windows)
|
||||
#define FF_INLINE static inline // Standard for GCC
|
||||
|
||||
|
||||
//---------- Hash Table Support
|
||||
//#define FF_HASH_TABLE_SUPPORT // Enable HASH to speed up file creation.
|
||||
#ifdef FF_HASH_TABLE_SUPPORT
|
||||
#define FF_HASH_FUNCTION CRC16
|
||||
//#define FF_HASH_FUNCTION CRC8
|
||||
#endif
|
||||
// Note the 2 UNICODE options are mutually exclusive. Only one can be enabled.
|
||||
|
||||
// Ensure that dirents are big enough to hold the maximum UTF-8 sequence.
|
||||
|
||||
|
||||
//---------- FAT12 SUPPORT
|
||||
#define FF_FAT12_SUPPORT // Enable FAT12 Suppport. You can reduce the code-size by commenting this out.
|
||||
// If you don't need FAT12 support, why have it. FAT12 is more complex to process,
|
||||
// therefore savings can be made by not having it.
|
||||
#define FF_FAT12_SUPPORT // Enable FAT12 Suppport. You can reduce the code-size by commenting this out.
|
||||
// If you don't need FAT12 support, why have it. FAT12 is more complex to process,
|
||||
// therefore savings can be made by not having it.
|
||||
|
||||
|
||||
//---------- TIME SUPPORT
|
||||
#define FF_TIME_SUPPORT // Should FullFAT use time stamping. Only if you have provided the relevant time drivers in ff_time.c
|
||||
// Note, by default ff_time.c is set-up for the Windows Demonstration. Please see ff_time.c to disable.
|
||||
|
||||
|
||||
//---------- FILE SPACE ALLOCATION PERFORMANCE
|
||||
// Uncomment the prefered method. (Can only choose a single method).
|
||||
#define FF_ALLOC_DEFAULT // Only allocate as much as is needed. (Provides good performance, without wasting space).
|
||||
//#define FF_ALLOC_DOUBLE // Doubles the size of a file each time allocation is required. (When high-performance writing is required).
|
||||
|
||||
|
||||
//---------- Use Native STDIO.h
|
||||
//#define FF_USE_NATIVE_STDIO // Makes FullFAT conform to values provided by your native STDIO.h file.
|
||||
|
||||
|
||||
//---------- FREE SPACE CALCULATION
|
||||
//#define FF_MOUNT_FIND_FREE // Uncomment this option to check for Freespace on a volume mount. (Performance Penalty while mounting).
|
||||
// If not done in the mount, it will be done on the first call to FF_GetFreeSize() function.
|
||||
|
||||
|
||||
//---------- FIND API WILD-CARD SUPPORT
|
||||
#define FF_FINDAPI_ALLOW_WILDCARDS // Defined to enable Wild-cards in the API. Disabling this, makes the API consistent with 1.0.x series.
|
||||
|
||||
#define FF_WILDCARD_CASE_INSENSITIVE // Alter the case insensitivity of the Wild-card checking behaviour.
|
||||
|
||||
|
||||
//---------- PATH CACHE ----------
|
||||
#define FF_PATH_CACHE // Enables a simply Path Caching mechanism that increases performance of repeated operations
|
||||
// within the same path. E.g. a copy \dir1\*.* \dir2\*.* command.
|
||||
// This command requires FF_MAX_PATH number of bytes of memory. (Defined below, default 2600).
|
||||
|
||||
#define FF_PATH_CACHE_DEPTH 5 // The Number of PATH's to Cache. (Memory Requirement ~= FF_PATH_CACHE_DEPTH * FF_MAX_PATH).
|
||||
|
||||
|
||||
//---------- HASH CACHE // Speed up File-creation with a HASH table. Provides up to 20x performance boost.
|
||||
//#define FF_HASH_CACHE // Enable HASH to speed up file creation.
|
||||
#define FF_HASH_CACHE_DEPTH 10 // Number of Directories to be Hashed. (For CRC16 memory is 8KB * DEPTH)
|
||||
#define FF_HASH_FUNCTION CRC16 // Choose a 16-bit hash.
|
||||
//#define FF_HASH_FUNCTION CRC8 // Choose an 8-bit hash.
|
||||
|
||||
|
||||
//---------- BLKDEV USES SEMAPHORE
|
||||
#define FF_BLKDEV_USES_SEM // When defined, each call to fnReadBlocks and fnWriteBlocks will be done while semaphore is locked
|
||||
// See also ff_safety.c
|
||||
// (HT addition) - Thanks to Hein Tibosch
|
||||
|
||||
|
||||
//---------- MALLOC
|
||||
// These should map on to platform specific memory allocators.
|
||||
#define FF_MALLOC(aSize) malloc(aSize)
|
||||
#define FF_FREE(apPtr) free(apPtr)
|
||||
|
||||
|
||||
//---------- IN-LINE FUNCTIONS
|
||||
//---------- INLINE KeyWord // Define FF_INLINE as your compiler's inline keyword. This is placed before the type qualifier.
|
||||
#define FF_INLINE static __forceinline // Keywords to inline functions (Windows)
|
||||
//#define FF_INLINE static inline // Standard for GCC
|
||||
|
||||
//---------- Inline Memory Independence Routines for better performance, but bigger codesize.
|
||||
//#define FF_INLINE_MEMORY_ACCESS
|
||||
//---------- Inline Block Calculation Routines for slightly better performance in critical sections.
|
||||
//#define FF_INLINE_BLOCK_CALCULATIONS
|
||||
|
||||
|
||||
//---------- 64-Bit Number Support
|
||||
#define FF_64_NUM_SUPPORT // This helps to give information about the FreeSpace and VolumeSize of a partition or volume.
|
||||
// If you cannot support 64-bit integers, then FullFAT still works, its just that the functions:
|
||||
// FF_GetFreeSize() and FF_GetVolumeSize() don't make sense when reporting sizes > 4GB.
|
||||
#define FF_64_NUM_SUPPORT // This helps to give information about the FreeSpace and VolumeSize of a partition or volume.
|
||||
// If you cannot support 64-bit integers, then FullFAT still works, its just that the functions:
|
||||
// FF_GetFreeSize() and FF_GetVolumeSize() don't make sense when reporting sizes > 4GB.
|
||||
|
||||
//---------- Driver Sleep Time // How long FullFAT should sleep the thread for in ms, if FF_ERR_DRIVER_BUSY is recieved.
|
||||
#define FF_DRIVER_BUSY_SLEEP 20
|
||||
|
||||
//---------- Debugging Features
|
||||
#define FF_DEBUG // Enable the Error Code string functions. const FF_T_INT8 *FF_GetErrMessage( FF_T_SINT32 iErrorCode);
|
||||
// Uncommenting this just stops FullFAT error strings being compiled.
|
||||
//---------- Driver Sleep Time
|
||||
#define FF_DRIVER_BUSY_SLEEP 20 // How long FullFAT should sleep the thread for in ms, if FF_ERR_DRIVER_BUSY is recieved.
|
||||
|
||||
//---------- Actively Determine if partition is FAT
|
||||
#define FF_FAT_CHECK // This is experimental, so if FullFAT won't mount your volume, comment this out
|
||||
// Also report the problem to [email protected]
|
||||
|
||||
//---------- DEBUGGING FEATURES (HELPFUL ERROR MESSAGES)
|
||||
#define FF_DEBUG // Enable the Error Code string functions. const FF_T_INT8 *FF_GetErrMessage( FF_T_SINT32 iErrorCode);
|
||||
// Uncommenting this just stops FullFAT error strings being compiled.
|
||||
// Further calls to FF_GetErrMessage() are safe, and simply returns a pointer to a NULL string. ("").
|
||||
// This should be disabled to reduce code-size dramatically.
|
||||
|
||||
|
||||
//---------- AUTOMATIC SETTINGS DO NOT EDIT -- These configure your options from above, and check sanity!
|
||||
|
||||
#ifdef FF_LFN_SUPPORT
|
||||
#define FF_MAX_FILENAME (129)
|
||||
#define FF_MAX_FILENAME (260)
|
||||
#else
|
||||
#define FF_MAX_FILENAME 13
|
||||
#define FF_MAX_FILENAME (13)
|
||||
#endif
|
||||
|
||||
#ifdef FF_USE_NATIVE_STDIO
|
||||
#ifdef MAX_PATH
|
||||
#define FF_MAX_PATH MAX_PATH
|
||||
#elif PATH_MAX
|
||||
#define FF_MAX_PATH PATH_MAX
|
||||
#else
|
||||
#define FF_MAX_PATH 2600
|
||||
#endif
|
||||
@@ -155,6 +185,16 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
#ifdef FF_UNICODE_UTF8_SUPPORT
|
||||
#error FullFAT Invalid ff_config.h file: Must choose a single UNICODE support option. FF_UNICODE_SUPPORT for UTF-16, FF_UNICODE_UTF8_SUPPORT for UTF-8.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef FF_FAT_CHECK // FF_FAT_CHECK is now forced.
|
||||
#define FF_FAT_CHECK
|
||||
#endif
|
||||
|
||||
#ifndef FF_LITTLE_ENDIAN
|
||||
#ifndef FF_BIG_ENDIAN
|
||||
#error FullFAT Invalid ff_config.h file: An ENDIANESS must be defined for your platform. See ff_config.h file.
|
||||
@@ -167,16 +207,18 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_TABLE_SUPPORT
|
||||
#ifdef FF_HASH_CACHE
|
||||
|
||||
#if FF_HASH_FUNCTION == CRC16
|
||||
#define FF_HASH_TABLE_SIZE 8192
|
||||
#elif FF_HASH_FUNCTION == CRC8
|
||||
#define FF_HASH_TABLE_SIZE 32
|
||||
#else
|
||||
#error Invalid Hashing function selected. CRC16 or CRC8!
|
||||
#error FullFAT Invalid ff_config.h file: Invalid Hashing function selected. CRC16 or CRC8!
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//---------- END-OF-CONFIGURATION
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
|
||||
FF_T_UINT8 FF_GetCRC8 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength);
|
||||
FF_T_UINT16 FF_GetCRC16 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength);
|
||||
FF_T_UINT32 FF_GetCRC32 (FF_T_UINT8 *pbyData, FF_T_UINT32 stLength);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -52,54 +52,118 @@
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
FF_T_INT8 FileName[FF_MAX_FILENAME];
|
||||
FF_T_UINT8 Attrib;
|
||||
FF_T_UINT32 ulChainLength;
|
||||
FF_T_UINT32 ulDirCluster;
|
||||
FF_T_UINT32 ulCurrentClusterLCN;
|
||||
FF_T_UINT32 ulCurrentClusterNum;
|
||||
FF_T_UINT32 ulCurrentEntry;
|
||||
FF_BUFFER *pBuffer;
|
||||
} FF_FETCH_CONTEXT;
|
||||
|
||||
typedef struct {
|
||||
FF_T_UINT32 Filesize;
|
||||
FF_T_UINT32 ObjectCluster;
|
||||
|
||||
|
||||
// Book Keeping
|
||||
FF_T_UINT32 CurrentCluster;
|
||||
FF_T_UINT32 AddrCurrentCluster;
|
||||
FF_T_UINT32 DirCluster;
|
||||
FF_T_UINT16 CurrentItem;
|
||||
// End Book Keeping
|
||||
|
||||
#ifdef FF_TIME_SUPPORT
|
||||
FF_SYSTEMTIME CreateTime; ///< Date and Time Created.
|
||||
FF_SYSTEMTIME ModifiedTime; ///< Date and Time Modified.
|
||||
FF_SYSTEMTIME AccessedTime; ///< Date of Last Access.
|
||||
#endif
|
||||
|
||||
//---- Book Keeping for FF_Find Functions
|
||||
FF_T_UINT16 CurrentItem;
|
||||
FF_T_UINT32 DirCluster;
|
||||
FF_T_UINT32 CurrentCluster;
|
||||
FF_T_UINT32 AddrCurrentCluster;
|
||||
//FF_T_UINT8 NumLFNs;
|
||||
#ifdef FF_FINDAPI_ALLOW_WILDCARDS
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_WCHAR szWildCard[FF_MAX_FILENAME];
|
||||
#else
|
||||
FF_T_INT8 szWildCard[FF_MAX_FILENAME];
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_WCHAR FileName[FF_MAX_FILENAME];
|
||||
#else
|
||||
FF_T_INT8 FileName[FF_MAX_FILENAME];
|
||||
#endif
|
||||
|
||||
#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME)
|
||||
FF_T_INT8 ShortName[13];
|
||||
#endif
|
||||
FF_T_UINT8 Attrib;
|
||||
FF_FETCH_CONTEXT FetchContext;
|
||||
} FF_DIRENT;
|
||||
|
||||
FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_T_SINT8 FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs);
|
||||
FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path);
|
||||
FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent);
|
||||
void FF_PopulateShortDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer);
|
||||
FF_T_SINT8 FF_PopulateLongDirent(FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry);
|
||||
FF_T_SINT8 FF_FetchEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer);
|
||||
FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer);
|
||||
FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer);
|
||||
FF_T_SINT8 FF_FindNextInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_T_UINT32 FF_FindEntryInDir(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent);
|
||||
FF_T_SINT8 FF_CreateShortName(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName);
|
||||
|
||||
void FF_lockDIR (FF_IOMAN *pIoman);
|
||||
void FF_unlockDIR (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent);
|
||||
FF_ERROR FF_MkDir(FF_IOMAN *pIoman, const FF_T_INT8 *Path);
|
||||
FF_T_SINT8 FF_CreateDirent(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_T_SINT8 FF_ExtendDirectory(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
|
||||
FF_T_UINT32 FF_FindDir(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen);
|
||||
|
||||
|
||||
FF_T_BOOL FF_CheckDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
|
||||
FF_T_BOOL FF_DirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
|
||||
FF_ERROR FF_AddDirentHash(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
|
||||
void FF_SetDirHashed(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
|
||||
// PUBLIC API
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_WCHAR *path);
|
||||
FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_WCHAR *Path);
|
||||
#else
|
||||
FF_ERROR FF_FindFirst (FF_IOMAN *pIoman, FF_DIRENT *pDirent, const FF_T_INT8 *path);
|
||||
FF_ERROR FF_MkDir (FF_IOMAN *pIoman, const FF_T_INT8 *Path);
|
||||
#endif
|
||||
|
||||
void FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 DirEntry);
|
||||
FF_ERROR FF_FindNext (FF_IOMAN *pIoman, FF_DIRENT *pDirent);
|
||||
|
||||
|
||||
// INTERNAL API
|
||||
FF_ERROR FF_GetEntry (FF_IOMAN *pIoman, FF_T_UINT16 nEntry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_ERROR FF_PutEntry (FF_IOMAN *pIoman, FF_T_UINT16 Entry, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_T_SINT8 FF_FindEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *Name, FF_DIRENT *pDirent, FF_T_BOOL LFNs);
|
||||
|
||||
void FF_PopulateShortDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT8 *EntryBuffer);
|
||||
FF_ERROR FF_PopulateLongDirent (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_T_UINT16 nEntry, FF_FETCH_CONTEXT *pFetchContext);
|
||||
|
||||
FF_ERROR FF_InitEntryFetch (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster, FF_FETCH_CONTEXT *pContext);
|
||||
FF_ERROR FF_FetchEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer);
|
||||
FF_ERROR FF_PushEntryWithContext (FF_IOMAN *pIoman, FF_T_UINT32 ulEntry, FF_FETCH_CONTEXT *pContext, FF_T_UINT8 *pEntryBuffer);
|
||||
void FF_CleanupEntryFetch (FF_IOMAN *pIoman, FF_FETCH_CONTEXT *pContext);
|
||||
|
||||
FF_T_SINT8 FF_PushEntry (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT16 nEntry, FF_T_UINT8 *buffer, void *pParam);
|
||||
FF_T_BOOL FF_isEndOfDir (FF_T_UINT8 *EntryBuffer);
|
||||
FF_ERROR FF_FindNextInDir (FF_IOMAN *pIoman, FF_DIRENT *pDirent, FF_FETCH_CONTEXT *pFetchContext);
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_WCHAR *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError);
|
||||
FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *ShortName, FF_T_WCHAR *LongName);
|
||||
#else
|
||||
FF_T_UINT32 FF_FindEntryInDir (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, const FF_T_INT8 *name, FF_T_UINT8 pa_Attrib, FF_DIRENT *pDirent, FF_ERROR *pError);
|
||||
FF_T_SINT8 FF_CreateShortName (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *ShortName, FF_T_INT8 *LongName);
|
||||
#endif
|
||||
|
||||
|
||||
void FF_lockDIR (FF_IOMAN *pIoman);
|
||||
void FF_unlockDIR (FF_IOMAN *pIoman);
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_WCHAR *FileName, FF_DIRENT *pDirent, FF_ERROR *pError);
|
||||
#else
|
||||
FF_T_UINT32 FF_CreateFile(FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_INT8 *FileName, FF_DIRENT *pDirent, FF_ERROR *pError);
|
||||
#endif
|
||||
|
||||
FF_ERROR FF_CreateDirent (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_DIRENT *pDirent);
|
||||
FF_ERROR FF_ExtendDirectory (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT16 pathLen, FF_ERROR *pError);
|
||||
#else
|
||||
FF_T_UINT32 FF_FindDir (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT16 pathLen, FF_ERROR *pError);
|
||||
#endif
|
||||
|
||||
#ifdef FF_HASH_CACHE
|
||||
FF_T_BOOL FF_CheckDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
|
||||
FF_T_BOOL FF_DirHashed (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster);
|
||||
FF_ERROR FF_AddDirentHash (FF_IOMAN *pIoman, FF_T_UINT32 DirCluster, FF_T_UINT32 nHash);
|
||||
FF_ERROR FF_HashDir (FF_IOMAN *pIoman, FF_T_UINT32 ulDirCluster);
|
||||
#endif
|
||||
|
||||
FF_ERROR FF_RmLFNs(FF_IOMAN *pIoman, FF_T_UINT16 usDirEntry, FF_FETCH_CONTEXT *pContext);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -40,53 +40,111 @@
|
||||
#include "ff_config.h"
|
||||
#include "ff_types.h"
|
||||
|
||||
/**
|
||||
Error codes are 32-bit numbers, and consist of three items:
|
||||
8Bits 8bits 16bits
|
||||
........ ........ ........ ........
|
||||
[ModuleID][FunctionID][-- ERROR CODE --]
|
||||
|
||||
**/
|
||||
|
||||
#define FF_GETERROR(x) (x & 0x0000FFFF)
|
||||
|
||||
#define FF_MODULE_SHIFT 24
|
||||
#define FF_FUNCTION_SHIFT 16
|
||||
|
||||
//----- FullFAT Module Identifiers
|
||||
#define FF_MODULE_IOMAN (1 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_DIR (2 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_FILE (3 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_FAT (4 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_CRC (5 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_FORMAT (6 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_HASH (7 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_MEMORY (8 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_STRING (9 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_UNICODE (10 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_SAFETY (11 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_TIME (12 << FF_MODULE_SHIFT)
|
||||
#define FF_MODULE_DRIVER (13 << FF_MODULE_SHIFT) // We can mark underlying platform error codes with this.
|
||||
|
||||
//----- FullFAT Function Identifiers (In Modular Order)
|
||||
//----- FF_IOMAN - The FullFAT I/O Manager.
|
||||
#define FF_CREATEIOMAN (1 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_DESTROYIOMAN (2 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_REGISTERBLKDEVICE (3 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_UNREGISTERBLKDEVICE (4 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_MOUNTPARTITION (5 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_UNMOUNTPARTITION (6 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_FLUSHCACHE (7 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_GETPARTITIONBLOCKSIZE (8 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_BLOCKREAD (9 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
#define FF_BLOCKWRITE (10 << FF_FUNCTION_SHIFT) | FF_MODULE_IOMAN
|
||||
|
||||
//----- FF_DIR - The FullFAT directory handling routines.
|
||||
// -- COMPLETE THESE ERROR CODES TOMORROW :P
|
||||
|
||||
|
||||
/* FullFAT defines different Error-Code spaces for each module. This ensures
|
||||
that all error codes remain unique, and their meaning can be quickly identified.
|
||||
*/
|
||||
// Global Error Codes
|
||||
#define FF_ERR_NONE 0 ///< No Error
|
||||
#define FF_ERR_NULL_POINTER -2 ///< pIoman was NULL.
|
||||
#define FF_ERR_NOT_ENOUGH_MEMORY -3 ///< malloc() failed! - Could not allocate handle memory.
|
||||
#define FF_ERR_DEVICE_DRIVER_FAILED -4 ///< The Block Device driver reported a FATAL error, cannot continue.
|
||||
#define FF_ERR_NONE 0 ///< No Error
|
||||
//#define FF_ERR_GENERIC 1 ///< BAD NEVER USE THIS!
|
||||
#define FF_ERR_NULL_POINTER 2 ///< pIoman was NULL.
|
||||
#define FF_ERR_NOT_ENOUGH_MEMORY 3 ///< malloc() failed! - Could not allocate handle memory.
|
||||
#define FF_ERR_DEVICE_DRIVER_FAILED 4 ///< The Block Device driver reported a FATAL error, cannot continue.
|
||||
|
||||
|
||||
// IOMAN Error Codes
|
||||
#define FF_ERR_IOMAN_BAD_BLKSIZE -11 ///< The provided blocksize was not a multiple of 512.
|
||||
#define FF_ERR_IOMAN_BAD_MEMSIZE -12 ///< The memory size was not a multiple of the blocksize.
|
||||
#define FF_ERR_IOMAN_DEV_ALREADY_REGD -13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device.
|
||||
#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION -14 ///< A mountable partition could not be found on the device.
|
||||
#define FF_ERR_IOMAN_INVALID_FORMAT -15 ///< The
|
||||
#define FF_ERR_IOMAN_INVALID_PARTITION_NUM -16 ///< The partition number provided was out of range.
|
||||
#define FF_ERR_IOMAN_NOT_FAT_FORMATTED -17 ///< The partition did not look like a FAT partition.
|
||||
#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE -18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver.
|
||||
#define FF_ERR_IOMAN_PARTITION_MOUNTED -19 ///< Device is in use by an actively mounted partition. Unmount the partition first.
|
||||
#define FF_ERR_IOMAN_ACTIVE_HANDLES -20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache).
|
||||
#define FF_ERR_IOMAN_BAD_BLKSIZE 11 ///< The provided blocksize was not a multiple of 512.
|
||||
#define FF_ERR_IOMAN_BAD_MEMSIZE 12 ///< The memory size was not a multiple of the blocksize.
|
||||
#define FF_ERR_IOMAN_DEV_ALREADY_REGD 13 ///< Device was already registered. Use FF_UnRegister() to re-use this IOMAN with another device.
|
||||
#define FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION 14 ///< A mountable partition could not be found on the device.
|
||||
#define FF_ERR_IOMAN_INVALID_FORMAT 15 ///< The
|
||||
#define FF_ERR_IOMAN_INVALID_PARTITION_NUM 16 ///< The partition number provided was out of range.
|
||||
#define FF_ERR_IOMAN_NOT_FAT_FORMATTED 17 ///< The partition did not look like a FAT partition.
|
||||
#define FF_ERR_IOMAN_DEV_INVALID_BLKSIZE 18 ///< IOMAN object BlkSize is not compatible with the blocksize of this device driver.
|
||||
#define FF_ERR_IOMAN_PARTITION_MOUNTED 19 ///< Device is in use by an actively mounted partition. Unmount the partition first.
|
||||
#define FF_ERR_IOMAN_ACTIVE_HANDLES 20 ///< The partition cannot be unmounted until all active file handles are closed. (There may also be active handles on the cache).
|
||||
#define FF_ERR_IOMAN_GPT_HEADER_CORRUPT 21 ///< The GPT partition table appears to be corrupt, refusing to mount.
|
||||
#define FF_ERR_IOMAN_NOT_ENOUGH_FREE_SPACE 22
|
||||
#define FF_ERR_IOMAN_OUT_OF_BOUNDS_READ 23
|
||||
#define FF_ERR_IOMAN_OUT_OF_BOUNDS_WRITE 24
|
||||
|
||||
|
||||
// File Error Codes -30 +
|
||||
#define FF_ERR_FILE_ALREADY_OPEN -30 ///< File is in use.
|
||||
#define FF_ERR_FILE_NOT_FOUND -31 ///< File was not found.
|
||||
#define FF_ERR_FILE_OBJECT_IS_A_DIR -32 ///< Tried to FF_Open() a Directory.
|
||||
#define FF_ERR_FILE_IS_READ_ONLY -33 ///< Tried to FF_Open() a file marked read only.
|
||||
#define FF_ERR_FILE_INVALID_PATH -34 ///< The path of the file was not found.
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE -35
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE -36
|
||||
#define FF_ERR_FILE_EXTEND_FAILED -37 ///< Could not extend the file.
|
||||
#define FF_ERR_FILE_DESTINATION_EXISTS -38
|
||||
#define FF_ERR_FILE_SOURCE_NOT_FOUND -39
|
||||
#define FF_ERR_FILE_DIR_NOT_FOUND -40
|
||||
#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT -41
|
||||
// File Error Codes 30 +
|
||||
#define FF_ERR_FILE_ALREADY_OPEN 30 ///< File is in use.
|
||||
#define FF_ERR_FILE_NOT_FOUND 31 ///< File was not found.
|
||||
#define FF_ERR_FILE_OBJECT_IS_A_DIR 32 ///< Tried to FF_Open() a Directory.
|
||||
#define FF_ERR_FILE_IS_READ_ONLY 33 ///< Tried to FF_Open() a file marked read only.
|
||||
#define FF_ERR_FILE_INVALID_PATH 34 ///< The path of the file was not found.
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE 35
|
||||
#define FF_ERR_FILE_NOT_OPENED_IN_READ_MODE 36
|
||||
#define FF_ERR_FILE_EXTEND_FAILED 37 ///< Could not extend the file.
|
||||
#define FF_ERR_FILE_DESTINATION_EXISTS 38
|
||||
#define FF_ERR_FILE_SOURCE_NOT_FOUND 39
|
||||
#define FF_ERR_FILE_DIR_NOT_FOUND 40
|
||||
#define FF_ERR_FILE_COULD_NOT_CREATE_DIRENT 41
|
||||
|
||||
// Directory Error Codes -50 +
|
||||
#define FF_ERR_DIR_OBJECT_EXISTS -50 ///< A file or folder of the same name already exists in the current directory.
|
||||
#define FF_ERR_DIR_DIRECTORY_FULL -51 ///< No more items could be added to the directory.
|
||||
#define FF_ERR_DIR_END_OF_DIR -52 ///
|
||||
#define FF_ERR_DIR_NOT_EMPTY -53 ///< Cannot delete a directory that contains files or folders.
|
||||
#define FF_ERR_DIR_INVALID_PATH -54 ///< Could not find the directory specified by the path.
|
||||
#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR -55 ///< Can't extend the root dir.
|
||||
// Directory Error Codes 50 +
|
||||
#define FF_ERR_DIR_OBJECT_EXISTS 50 ///< A file or folder of the same name already exists in the current directory.
|
||||
#define FF_ERR_DIR_DIRECTORY_FULL 51 ///< No more items could be added to the directory.
|
||||
#define FF_ERR_DIR_END_OF_DIR 52 ///
|
||||
#define FF_ERR_DIR_NOT_EMPTY 53 ///< Cannot delete a directory that contains files or folders.
|
||||
#define FF_ERR_DIR_INVALID_PATH 54 ///< Could not find the directory specified by the path.
|
||||
#define FF_ERR_DIR_CANT_EXTEND_ROOT_DIR 55 ///< Can't extend the root dir.
|
||||
#define FF_ERR_DIR_EXTEND_FAILED 56 ///< Not enough space to extend the directory.
|
||||
#define FF_ERR_DIR_NAME_TOO_LONG 57 ///< Name exceeds the number of allowed charachters for a filename.
|
||||
|
||||
// Fat Error Codes -70 +
|
||||
#define FF_ERR_FAT_NO_FREE_CLUSTERS -70 ///< No more free space is available on the disk.
|
||||
// Fat Error Codes 70 +
|
||||
#define FF_ERR_FAT_NO_FREE_CLUSTERS 70 ///< No more free space is available on the disk.
|
||||
|
||||
// UNICODE Error Codes 100 +
|
||||
#define FF_ERR_UNICODE_INVALID_CODE 100 ///< An invalid Unicode charachter was provided!
|
||||
#define FF_ERR_UNICODE_DEST_TOO_SMALL 101 ///< Not enough space in the UTF-16 buffer to encode the entire sequence as UTF-16.
|
||||
#define FF_ERR_UNICODE_INVALID_SEQUENCE 102 ///< An invalid UTF-16 sequence was encountered.
|
||||
#define FF_ERR_UNICODE_CONVERSION_EXCEEDED 103 ///< Filename exceeds MAX long-filename length when converted to UTF-16.
|
||||
|
||||
#ifdef FF_DEBUG
|
||||
const FF_T_INT8 *FF_GetErrMessage(FF_ERROR iErrorCode);
|
||||
|
||||
@@ -52,24 +52,23 @@
|
||||
FF_T_UINT32 FF_getRealLBA (FF_IOMAN *pIoman, FF_T_UINT32 LBA);
|
||||
FF_T_UINT32 FF_Cluster2LBA (FF_IOMAN *pIoman, FF_T_UINT32 Cluster);
|
||||
FF_T_UINT32 FF_LBA2Cluster (FF_IOMAN *pIoman, FF_T_UINT32 Address);
|
||||
FF_T_SINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster);
|
||||
FF_T_UINT32 FF_getFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_ERROR *pError);
|
||||
FF_ERROR FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value);
|
||||
FF_T_BOOL FF_isEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 fatEntry);
|
||||
FF_T_SINT8 FF_putFatEntry (FF_IOMAN *pIoman, FF_T_UINT32 nCluster, FF_T_UINT32 Value);
|
||||
FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman, FF_ERROR *pError);
|
||||
FF_T_UINT32 FF_ExtendClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT32 Count);
|
||||
FF_T_SINT8 FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count);
|
||||
FF_T_UINT32 FF_TraverseFAT (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count);
|
||||
FF_T_UINT32 FF_CreateClusterChain (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_GetChainLength (FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain);
|
||||
FF_T_UINT32 FF_FindEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 Start);
|
||||
FF_T_SINT8 FF_ClearCluster (FF_IOMAN *pIoman, FF_T_UINT32 nCluster);
|
||||
FF_ERROR FF_UnlinkClusterChain (FF_IOMAN *pIoman, FF_T_UINT32 StartCluster, FF_T_UINT16 Count);
|
||||
FF_T_UINT32 FF_TraverseFAT (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_T_UINT32 Count, FF_ERROR *pError);
|
||||
FF_T_UINT32 FF_CreateClusterChain (FF_IOMAN *pIoman, FF_ERROR *pError);
|
||||
FF_T_UINT32 FF_GetChainLength (FF_IOMAN *pIoman, FF_T_UINT32 pa_nStartCluster, FF_T_UINT32 *piEndOfChain, FF_ERROR *pError);
|
||||
FF_T_UINT32 FF_FindEndOfChain (FF_IOMAN *pIoman, FF_T_UINT32 Start, FF_ERROR *pError);
|
||||
FF_ERROR FF_ClearCluster (FF_IOMAN *pIoman, FF_T_UINT32 nCluster);
|
||||
#ifdef FF_64_NUM_SUPPORT
|
||||
FF_T_UINT64 FF_GetFreeSize (FF_IOMAN *pIoman);
|
||||
FF_T_UINT64 FF_GetFreeSize (FF_IOMAN *pIoman, FF_ERROR *pError);
|
||||
#else
|
||||
FF_T_UINT32 FF_GetFreeSize (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_GetFreeSize (FF_IOMAN *pIoman, FF_ERROR *pError);
|
||||
#endif
|
||||
FF_T_UINT32 FF_FindFreeCluster (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman);
|
||||
FF_T_UINT32 FF_CountFreeClusters (FF_IOMAN *pIoman, FF_ERROR *pError); // WARNING: If this protoype changes, it must be updated in ff_ioman.c also!
|
||||
void FF_lockFAT (FF_IOMAN *pIoman);
|
||||
void FF_unlockFAT (FF_IOMAN *pIoman);
|
||||
|
||||
|
||||
@@ -86,5 +86,20 @@
|
||||
#define FF_FAT_ATTR_ARCHIVE 0x20
|
||||
#define FF_FAT_ATTR_LFN 0x0F
|
||||
|
||||
/**
|
||||
* -- Hein_Tibosch additions for mixed case in shortnames --
|
||||
*
|
||||
* Specifically, bit 4 means lowercase extension and bit 3 lowercase basename,
|
||||
* which allows for combinations such as "example.TXT" or "HELLO.txt" but not "Mixed.txt"
|
||||
*/
|
||||
|
||||
#define FF_FAT_CASE_OFFS 0x0C ///< After NT/XP : 2 case bits
|
||||
#define FF_FAT_CASE_ATTR_BASE 0x08
|
||||
#define FF_FAT_CASE_ATTR_EXT 0x10
|
||||
|
||||
#if defined(FF_LFN_SUPPORT) && defined(FF_INCLUDE_SHORT_NAME)
|
||||
#define FF_FAT_ATTR_IS_LFN 0x40 ///< artificial attribute, for debugging only
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -75,19 +75,29 @@ typedef struct _FF_FILE {
|
||||
//---------- PROTOTYPES
|
||||
// PUBLIC (Interfaces):
|
||||
|
||||
FF_FILE *FF_Open (FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ERROR *pError);
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_WCHAR *path, FF_T_UINT8 Mode, FF_ERROR *pError);
|
||||
FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_WCHAR *Path);
|
||||
FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_WCHAR *path);
|
||||
FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_WCHAR *path);
|
||||
FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_WCHAR *szSourceFile, const FF_T_WCHAR *szDestinationFile);
|
||||
#else
|
||||
FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ERROR *pError);
|
||||
FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_INT8 *Path);
|
||||
FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_INT8 *path);
|
||||
FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_INT8 *path);
|
||||
FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile);
|
||||
#endif
|
||||
FF_ERROR FF_Close (FF_FILE *pFile);
|
||||
FF_T_SINT32 FF_GetC (FF_FILE *pFile);
|
||||
FF_T_SINT32 FF_GetLine (FF_FILE *pFile, FF_T_INT8 *szLine, FF_T_UINT32 ulLimit);
|
||||
FF_T_SINT32 FF_Read (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer);
|
||||
FF_T_SINT32 FF_Write (FF_FILE *pFile, FF_T_UINT32 ElementSize, FF_T_UINT32 Count, FF_T_UINT8 *buffer);
|
||||
FF_T_BOOL FF_isEOF (FF_FILE *pFile);
|
||||
FF_ERROR FF_Seek (FF_FILE *pFile, FF_T_SINT32 Offset, FF_T_INT8 Origin);
|
||||
FF_T_SINT32 FF_PutC (FF_FILE *pFile, FF_T_UINT8 Value);
|
||||
FF_T_UINT32 FF_Tell (FF_FILE *pFile);
|
||||
FF_ERROR FF_RmFile (FF_IOMAN *pIoman, const FF_T_INT8 *path);
|
||||
FF_ERROR FF_RmDir (FF_IOMAN *pIoman, const FF_T_INT8 *path);
|
||||
FF_T_BOOL FF_isDirEmpty (FF_IOMAN *pIoman, const FF_T_INT8 *Path);
|
||||
FF_ERROR FF_Move (FF_IOMAN *pIoman, const FF_T_INT8 *szSourceFile, const FF_T_INT8 *szDestinationFile);
|
||||
|
||||
FF_T_UINT8 FF_GetModeBits (FF_T_INT8 *Mode);
|
||||
|
||||
// Private :
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*****************************************************************************
|
||||
* FullFAT - High Performance, Thread-Safe Embedded FAT File-System *
|
||||
* Copyright (C) 2009 James Walmsley ([email protected]) *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* IMPORTANT NOTICE: *
|
||||
* ================= *
|
||||
* Alternative Licensing is available directly from the Copyright holder, *
|
||||
* (James Walmsley). For more information consult LICENSING.TXT to obtain *
|
||||
* a Commercial license. *
|
||||
* *
|
||||
* See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. *
|
||||
* *
|
||||
* Removing the above notice is illegal and will invalidate this license. *
|
||||
*****************************************************************************
|
||||
* See http://worm.me.uk/fullfat for more information. *
|
||||
* Or http://fullfat.googlecode.com/ for latest releases and the wiki. *
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file ff_format.c
|
||||
* @author James Walmsley
|
||||
* @ingroup FORMAT
|
||||
*
|
||||
**/
|
||||
|
||||
|
||||
#ifndef _FF_FORMAT_H_
|
||||
#define _FF_FORMAT_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
@@ -87,8 +87,8 @@ typedef FF_T_SINT32 (*FF_READ_BLOCKS) (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAd
|
||||
* @brief Describes the block device driver interface to FullFAT.
|
||||
**/
|
||||
typedef struct {
|
||||
FF_WRITE_BLOCKS fnWriteBlocks; ///< Function Pointer, to write a block(s) from a block device.
|
||||
FF_READ_BLOCKS fnReadBlocks; ///< Function Pointer, to read a block(s) from a block device.
|
||||
FF_WRITE_BLOCKS fnpWriteBlocks; ///< Function Pointer, to write a block(s) from a block device.
|
||||
FF_READ_BLOCKS fnpReadBlocks; ///< Function Pointer, to read a block(s) from a block device.
|
||||
FF_T_UINT16 devBlkSize; ///< Block size that the driver deals with.
|
||||
void *pParam; ///< Pointer to some parameters e.g. for a Low-Level Driver Handle
|
||||
} FF_BLK_DEVICE;
|
||||
@@ -110,14 +110,23 @@ typedef struct {
|
||||
} FF_BUFFER;
|
||||
|
||||
typedef struct {
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
FF_T_WCHAR Path[FF_MAX_PATH];
|
||||
#else
|
||||
FF_T_INT8 Path[FF_MAX_PATH];
|
||||
FF_T_UINT32 DirCluster;
|
||||
#ifdef FF_HASH_TABLE_SUPPORT
|
||||
FF_HASH_TABLE pHashTable;
|
||||
FF_T_BOOL bHashed;
|
||||
#endif
|
||||
FF_T_UINT32 DirCluster;
|
||||
} FF_PATHCACHE;
|
||||
|
||||
#ifdef FF_HASH_CACHE
|
||||
typedef struct {
|
||||
FF_T_UINT32 ulDirCluster; ///< The Starting Cluster of the dir that the hash represents.
|
||||
FF_HASH_TABLE pHashTable; ///< Pointer to the Hash Table object.
|
||||
FF_T_UINT32 ulNumHandles; ///< Number of active Handles using this hash table.
|
||||
FF_T_UINT32 ulMisses; ///< Number of times this Hash Table was missed, (i.e. how redundant it is).
|
||||
} FF_HASHCACHE;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @brief FullFAT identifies a partition with the following data.
|
||||
@@ -183,6 +192,9 @@ typedef struct {
|
||||
FF_PARTITION *pPartition; ///< Pointer to a partition description.
|
||||
FF_BUFFER *pBuffers; ///< Pointer to the first buffer description.
|
||||
void *pSemaphore; ///< Pointer to a Semaphore object. (For buffer description modifications only!).
|
||||
#ifdef FF_BLKDEV_USES_SEM
|
||||
void *pBlkDevSemaphore; ///< Semaphore to guarantee Atomic access to the underlying block device, if required.
|
||||
#endif
|
||||
void *FirstFile; ///< Pointer to the first File object.
|
||||
FF_T_UINT8 *pCacheMem; ///< Pointer to a block of memory for the cache.
|
||||
FF_T_UINT32 LastReplaced; ///< Marks which sector was last replaced in the cache.
|
||||
@@ -191,6 +203,9 @@ typedef struct {
|
||||
FF_T_UINT8 PreventFlush; ///< Flushing to disk only allowed when 0
|
||||
FF_T_UINT8 MemAllocation; ///< Bit-Mask identifying allocated pointers.
|
||||
FF_T_UINT8 Locks; ///< Lock Flag for FAT & DIR Locking etc (This must be accessed via a semaphore).
|
||||
#ifdef FF_HASH_CACHE
|
||||
FF_HASHCACHE HashCache[FF_HASH_CACHE_DEPTH];
|
||||
#endif
|
||||
} FF_IOMAN;
|
||||
|
||||
// Bit-Masks for Memory Allocation testing.
|
||||
@@ -220,6 +235,8 @@ FF_T_UINT32 FF_GetVolumeSize(FF_IOMAN *pIoman);
|
||||
#endif
|
||||
|
||||
// PUBLIC (To FullFAT Only):
|
||||
FF_T_SINT32 FF_BlockRead (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer);
|
||||
FF_T_SINT32 FF_BlockWrite (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer);
|
||||
FF_ERROR FF_IncreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count);
|
||||
FF_ERROR FF_DecreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count);
|
||||
FF_BUFFER *FF_GetBuffer (FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode);
|
||||
|
||||
@@ -76,7 +76,7 @@ typedef struct {
|
||||
|
||||
#else
|
||||
|
||||
#error Little or Big Endian?
|
||||
#error Little or Big Endian? - Please set an endianess in ff_config.h
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -44,11 +44,37 @@
|
||||
#define _FF_STRING_H_
|
||||
|
||||
#include "ff_types.h"
|
||||
#include "ff_config.h"
|
||||
#include <string.h>
|
||||
|
||||
void FF_tolower (FF_T_INT8 *string, FF_T_UINT32 strLen);
|
||||
void FF_toupper (FF_T_INT8 *string, FF_T_UINT32 strLen);
|
||||
FF_T_BOOL FF_strmatch (const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 len);
|
||||
FF_T_INT8 *FF_strtok (const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length);
|
||||
FF_T_BOOL FF_wildcompare(const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString);
|
||||
#ifdef WIN32
|
||||
#define stricmp stricmp
|
||||
#define FF_stricmp stricmp
|
||||
#else
|
||||
#define strcasecmp strcasecmp
|
||||
#define FF_stricmp strcasecmp
|
||||
#endif
|
||||
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
void FF_tolower (FF_T_WCHAR *string, FF_T_UINT32 strLen);
|
||||
void FF_toupper (FF_T_WCHAR *string, FF_T_UINT32 strLen);
|
||||
FF_T_BOOL FF_strmatch (const FF_T_WCHAR *str1, const FF_T_WCHAR *str2, FF_T_UINT16 len);
|
||||
FF_T_WCHAR *FF_strtok (const FF_T_WCHAR *string, FF_T_WCHAR *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length);
|
||||
FF_T_BOOL FF_wildcompare (const FF_T_WCHAR *pszWildCard, const FF_T_WCHAR *pszString);
|
||||
|
||||
// ASCII to UTF16 and UTF16 to ASCII routines. -- These are lossy routines, and are only for converting ASCII to UTF-16
|
||||
// and the equivalent back to ASCII. Do not use them for international text.
|
||||
void FF_cstrtowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource);
|
||||
void FF_wcstocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource);
|
||||
void FF_cstrntowcs(FF_T_WCHAR *wcsDest, const FF_T_INT8 *szpSource, FF_T_UINT32 len);
|
||||
void FF_wcsntocstr(FF_T_INT8 *szpDest, const FF_T_WCHAR *wcsSource, FF_T_UINT32 len);
|
||||
|
||||
#else
|
||||
void FF_tolower (FF_T_INT8 *string, FF_T_UINT32 strLen);
|
||||
void FF_toupper (FF_T_INT8 *string, FF_T_UINT32 strLen);
|
||||
FF_T_BOOL FF_strmatch (const FF_T_INT8 *str1, const FF_T_INT8 *str2, FF_T_UINT16 len);
|
||||
FF_T_INT8 *FF_strtok (const FF_T_INT8 *string, FF_T_INT8 *token, FF_T_UINT16 *tokenNumber, FF_T_BOOL *last, FF_T_UINT16 Length);
|
||||
FF_T_BOOL FF_wildcompare (const FF_T_INT8 *pszWildCard, const FF_T_INT8 *pszString);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -61,6 +61,11 @@ typedef long FF_T_INT32; ///< 32 bit default integer.
|
||||
typedef unsigned long FF_T_UINT32; ///< 32 bit unsigned integer.
|
||||
typedef signed long FF_T_SINT32; ///< 32 bit signed integer.
|
||||
|
||||
//---------------- Platform Integer Sizes
|
||||
typedef int FF_T_INT;
|
||||
typedef unsigned int FF_T_UINT;
|
||||
typedef signed int FF_T_SINT;
|
||||
|
||||
#ifdef FF_64_NUM_SUPPORT
|
||||
//---------------- 64 BIT INTEGERS // If you cannot define these, then make sure you see ff_config.h
|
||||
typedef long long FF_T_INT64; // about 64-bit number support.
|
||||
@@ -70,5 +75,9 @@ typedef signed long long FF_T_SINT64; // > 4GB in bytes if you cannot support 64
|
||||
#endif
|
||||
|
||||
typedef FF_T_SINT32 FF_ERROR; ///< A special error code type to ease some inconsistencies in Error reporting.
|
||||
#ifdef FF_UNICODE_SUPPORT
|
||||
#include <wchar.h>
|
||||
typedef wchar_t FF_T_WCHAR; ///< Unicode UTF-16 Charachter type, for FullFAT when UNICODE is enabled.
|
||||
#endif
|
||||
|
||||
#endif // end of include guard
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*****************************************************************************
|
||||
* FullFAT - High Performance, Thread-Safe Embedded FAT File-System *
|
||||
* Copyright (C) 2009 James Walmsley ([email protected]) *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* IMPORTANT NOTICE: *
|
||||
* ================= *
|
||||
* Alternative Licensing is available directly from the Copyright holder, *
|
||||
* (James Walmsley). For more information consult LICENSING.TXT to obtain *
|
||||
* a Commercial license. *
|
||||
* *
|
||||
* See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. *
|
||||
* *
|
||||
* Removing the above notice is illegal and will invalidate this license. *
|
||||
*****************************************************************************
|
||||
* See http://worm.me.uk/fullfat for more information. *
|
||||
* Or http://fullfat.googlecode.com/ for latest releases and the wiki. *
|
||||
*****************************************************************************/
|
||||
|
||||
/**
|
||||
* @file ff_unicode.c
|
||||
* @author James Walmsley
|
||||
* @ingroup UNICODE
|
||||
*
|
||||
**/
|
||||
|
||||
#ifndef _FF_UNICODE_H_
|
||||
#define _FF_UNICODE_H_
|
||||
|
||||
#include "ff_config.h"
|
||||
#include "ff_types.h"
|
||||
#include "ff_error.h"
|
||||
|
||||
// UTF8 / UTF16 Transformation Functions
|
||||
|
||||
FF_T_UINT FF_GetUtf16SequenceLen (FF_T_UINT16 usLeadChar);
|
||||
FF_T_SINT32 FF_Utf8ctoUtf16c (FF_T_UINT16 *utf16Dest, const FF_T_UINT8 *utf8Source, FF_T_UINT32 ulSize);
|
||||
FF_T_SINT32 FF_Utf16ctoUtf8c (FF_T_UINT8 *utf8Dest, const FF_T_UINT16 *utf16Source, FF_T_UINT32 ulSize);
|
||||
|
||||
// UTF16 / UTF32 Transformation Functions
|
||||
|
||||
FF_T_SINT32 FF_Utf16ctoUtf32c(FF_T_UINT32 *utf32Dest, const FF_T_UINT16 *utf16Source);
|
||||
FF_T_SINT32 FF_Utf32ctoUtf16c(FF_T_UINT16 *utf16Dest, FF_T_UINT32 utf32char, FF_T_UINT32 ulSize);
|
||||
|
||||
// String transformations
|
||||
FF_T_SINT32 FF_Utf32stoUtf8s(FF_T_UINT8 *Utf8String, FF_T_UINT32 *Utf32String);
|
||||
|
||||
#endif
|
||||
@@ -45,6 +45,7 @@ extern "C" {
|
||||
#include "ff_crc.h"
|
||||
#include "ff_hash.h"
|
||||
#include "ff_string.h"
|
||||
#include "ff_unicode.h"
|
||||
//#include "ff_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user