1 /*****************************************************************************
2 * FullFAT - High Performance, Thread-Safe Embedded FAT File-System *
3 * Copyright (C) 2009 James Walmsley (james@worm.me.uk) *
5 * This program is free software: you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation, either version 3 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 * Alternative Licensing is available directly from the Copyright holder, *
21 * (James Walmsley). For more information consult LICENSING.TXT to obtain *
22 * a Commercial license. *
24 * See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT. *
26 * Removing the above notice is illegal and will invalidate this license. *
27 *****************************************************************************
28 * See http://worm.me.uk/fullfat for more information. *
29 * Or http://fullfat.googlecode.com/ for latest releases and the wiki. *
30 *****************************************************************************/
34 * @author James Walmsley
37 * @defgroup ERR Error Message
38 * @brief Used to return pretty strings for FullFAT error codes.
41 #include "ff_config.h"
46 const struct _FFERRTAB
48 const FF_T_INT8
* const strErrorString
;
49 const FF_T_SINT32 iErrorCode
;
51 } gcpFullFATErrorTable
[] =
53 {"Unknown or Generic Error! - Please contact FullFAT DEV - james@worm.me.uk", -1000},
54 {"No Error.", FF_ERR_NONE
},
55 {"Null Pointer provided, (probably for IOMAN).", FF_ERR_NULL_POINTER
},
56 {"Not enough memory (malloc() returned NULL).", FF_ERR_NOT_ENOUGH_MEMORY
},
57 {"Device Driver returned a FATAL error!.", FF_ERR_DEVICE_DRIVER_FAILED
},
58 {"The blocksize is not 512 multiple.", FF_ERR_IOMAN_BAD_BLKSIZE
},
59 {"The provided memory size, is not a multiple of the blocksize.", FF_ERR_IOMAN_BAD_MEMSIZE
},
60 {"Device is already registered, use FF_UnregisterBlkDevice() first.", FF_ERR_IOMAN_DEV_ALREADY_REGD
},
61 {"No mountable partition was found on the specified device.", FF_ERR_IOMAN_NO_MOUNTABLE_PARTITION
},
62 {"The format of the MBR was unrecognised.", FF_ERR_IOMAN_INVALID_FORMAT
},
63 {"The provided partition number is out-of-range (0 - 3).", FF_ERR_IOMAN_INVALID_PARTITION_NUM
},
64 {"The selected partition / volume doesn't appear to be FAT formatted.", FF_ERR_IOMAN_NOT_FAT_FORMATTED
},
65 {"Cannot register device. (BlkSize not a multiple of 512).", FF_ERR_IOMAN_DEV_INVALID_BLKSIZE
},
66 {"Cannot unregister device, a partition is still mounted.", FF_ERR_IOMAN_PARTITION_MOUNTED
},
67 {"Cannot unmount the partition while there are active FILE handles.", FF_ERR_IOMAN_ACTIVE_HANDLES
},
68 {"Cannot open the file, file already in use.", FF_ERR_FILE_ALREADY_OPEN
},
69 {"The specified file could not be found.", FF_ERR_FILE_NOT_FOUND
},
70 {"Cannot open a Directory.", FF_ERR_FILE_OBJECT_IS_A_DIR
},
71 {"Cannot open for writing: File is marked as Read-Only.", FF_ERR_FILE_IS_READ_ONLY
},
72 {"Path not found.", FF_ERR_FILE_INVALID_PATH
},
73 {"A file or folder of the same name already exists.", FF_ERR_DIR_OBJECT_EXISTS
},
74 {"FF_ERR_DIR_DIRECTORY_FULL", FF_ERR_DIR_DIRECTORY_FULL
},
75 {"FF_ERR_DIR_END_OF_DIR", FF_ERR_DIR_END_OF_DIR
},
76 {"The directory is not empty.", FF_ERR_DIR_NOT_EMPTY
},
77 {"Could not extend File or Folder - No Free Space!", FF_ERR_FAT_NO_FREE_CLUSTERS
},
78 {"Could not find the directory specified by the path.", FF_ERR_DIR_INVALID_PATH
},
79 {"The Root Dir is full, and cannot be extended on Fat12 or 16 volumes.", FF_ERR_DIR_CANT_EXTEND_ROOT_DIR
},
80 {"File operation failed - the file was not opened for writing.", FF_ERR_FILE_NOT_OPENED_IN_WRITE_MODE
},
81 {"File operation failed - the file was not opened for reading.", FF_ERR_FILE_NOT_OPENED_IN_READ_MODE
},
82 {"File operation failed - could not extend file.", FF_ERR_FILE_EXTEND_FAILED
},
83 {"Destination file already exists.", FF_ERR_FILE_DESTINATION_EXISTS
},
84 {"Source file was not found.", FF_ERR_FILE_SOURCE_NOT_FOUND
},
85 {"Destination path (dir) was not found.", FF_ERR_FILE_DIR_NOT_FOUND
},
86 {"Failed to create the directory Entry.", FF_ERR_FILE_COULD_NOT_CREATE_DIRENT
},
91 * @brief Returns a pointer to a string relating to a FullFAT error code.
93 * @param iErrorCode The error code.
95 * @return Pointer to a string describing the error.
98 const FF_T_INT8
*FF_GetErrMessage(FF_ERROR iErrorCode
) {
99 FF_T_UINT32 stCount
= sizeof (gcpFullFATErrorTable
) / sizeof ( struct _FFERRTAB
);
101 if (gcpFullFATErrorTable
[stCount
].iErrorCode
== iErrorCode
) {
102 return gcpFullFATErrorTable
[stCount
].strErrorString
;
105 return gcpFullFATErrorTable
[0].strErrorString
;