fsapi.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. /*
  2. * Copyright (c) 2012, Freescale Semiconductor, Inc.
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * o Redistributions of source code must retain the above copyright notice, this list
  9. * of conditions and the following disclaimer.
  10. *
  11. * o Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
  16. * contributors may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  23. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  26. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. ////////////////////////////////////////////////////////////////////////////////
  31. //! \addtogroup os_fat
  32. //! @{
  33. //!
  34. // Copyright (c) 2005-2008 SigmaTel, Inc.
  35. //!
  36. //! \file fsapi.h
  37. //! \brief Contains the FAT file system public API. Supports FAT32 and FAT16.
  38. //!
  39. ////////////////////////////////////////////////////////////////////////////////
  40. #ifndef _FS_API_H
  41. #define _FS_API_H
  42. ////////////////////////////////////////////////////////////////////////////////
  43. // Includes
  44. ////////////////////////////////////////////////////////////////////////////////
  45. #include "sdk.h"
  46. #include "os_filesystem_errordefs.h"
  47. ////////////////////////////////////////////////////////////////////////////////
  48. // Definitions
  49. ////////////////////////////////////////////////////////////////////////////////
  50. #define FS_USE_MALLOC 1
  51. #define SEEK_SET 0
  52. #define SEEK_CUR 1
  53. #define SEEK_END 2
  54. #define INVALID_FILESYSTEM (WORD)(3)
  55. #ifndef MAX_FILENAME_LENGTH
  56. #define MAX_FILENAME_LENGTH 256
  57. #endif
  58. #define ATTR_READ_ONLY 0x01
  59. #define ATTR_HIDDEN 0x02
  60. #define ATTR_SYSTEM 0x04
  61. #define ATTR_VOLUME_ID 0x08
  62. #define ATTR_DIRECTORY 0x10
  63. #define ATTR_ARCHIVE 0x20
  64. #define ATTR_LONG_NAME (ATTR_READ_ONLY|ATTR_HIDDEN|ATTR_SYSTEM|ATTR_VOLUME_ID)
  65. #define MAX_FILESNAME 13
  66. typedef struct _FindData {
  67. uint8_t attrib;
  68. int32_t FileSize;
  69. uint8_t device;
  70. uint32_t startrecord;
  71. uint8_t name[MAX_FILESNAME];
  72. int64_t Key;
  73. } FindData_t;
  74. typedef struct {
  75. uint8_t Day;
  76. uint8_t Month;
  77. int16_t Year;
  78. } DIR_DATE;
  79. typedef struct {
  80. uint8_t Second;
  81. uint8_t Minute;
  82. uint8_t Hour;
  83. } DIR_TIME;
  84. // Use for 'crt_mod_date_time_para' parameter
  85. #define CREATION_DATE 1
  86. #define CREATION_TIME 2
  87. #define MODIFICATION_DATE 3
  88. #define MODIFICATION_TIME 4
  89. // Use for 'dirattribute' parameter
  90. #define READ_ONLY 0X01
  91. #define HIDDEN 0X02
  92. #define SYSTEM 0X04
  93. #define VOLUME_ID 0X08
  94. #define DIRECTORY 0X10
  95. #define ARCHIVE 0X20
  96. #define MAX_UNICODE_SIZE 512
  97. ////////////////////////////////////////////////////////////////////////////////
  98. // Externs
  99. ////////////////////////////////////////////////////////////////////////////////
  100. //! \brief Maximum number of drives supported by the file system.
  101. //!
  102. //! Typically, \c maxdevices is 2.
  103. extern const int32_t maxdevices;
  104. //! \brief Maximum number of handles available in the file system.
  105. //!
  106. //! The number of handles available to the user is maxhandles - 2.
  107. //! Two handles are reserved by the file system for internal use only.
  108. //! The number of handles decides the number of files, which can
  109. //! simultaneously be open. Typically, \c maxhandles is 16.
  110. extern const int32_t maxhandles;
  111. //! \brief Total number of cache buffers.
  112. //!
  113. //! Increasing the number of cache buffers improves the performance of
  114. //! the file system when several threads are accessing the file system.
  115. //! Typically, \c maxcaches is 8.
  116. extern const int32_t maxcaches;
  117. //! \brief Assigns a drive letter to a drive.
  118. //!
  119. //! For example, in the following sample code, \n
  120. //!
  121. //! \c A is assigned to drive 0,\n
  122. //! \c B is assigned to drive 1, and \n
  123. //! \c C is assigned to drive 2.
  124. //! \code
  125. //! int32_t DriveLetter[] = {'A','B','C'};
  126. //! \endcode
  127. extern const uint8_t DriveLetter[];
  128. // The cache buffers are allocated in the X buffer.
  129. //extern BYTE bufx[NUMCACHES*CACHEBUFSIZE];
  130. #ifndef _WIN32
  131. //#pragma alignvar(32)
  132. __attribute__ ((aligned(32)))
  133. #endif
  134. //! \brief X memory buffer.
  135. extern uint8_t bufx[];
  136. #ifndef _WIN32
  137. //#pragma alignvar(4)
  138. __attribute__ ((aligned(4)))
  139. #endif
  140. //! \brief Y memory buffer.
  141. extern uint8_t bufy[];
  142. ////////////////////////////////////////////////////////////////////////////////
  143. // API
  144. ////////////////////////////////////////////////////////////////////////////////
  145. #if defined(__cplusplus)
  146. extern "C" {
  147. #endif // __cplusplus
  148. ///////////////////////////////////////////////////////////////////////////////
  149. //! \brief Redirects an Fclose request
  150. //!
  151. //! \fntype Function
  152. //!
  153. //! Redirects an Fclose request to the appropriate handler based on the
  154. //! specified file handle.
  155. //!
  156. //! \param[in] handleNumber Handle of the file to close
  157. //!
  158. //! \return Value of the steering function or an error.
  159. //! \retval ERROR_OS_FILESYSTEM_NO_STEERING_FUNCTION If there is no steering function defined for \c filehandle
  160. //!
  161. //! \internal
  162. //! \see To view the function definition, see fs_steering.c.
  163. ///////////////////////////////////////////////////////////////////////////////
  164. RtStatus_t Fclose(int32_t handleNumber);
  165. ///////////////////////////////////////////////////////////////////////////////
  166. //! \brief Redirects an Fread request
  167. //!
  168. //! \fntype Function
  169. //!
  170. //! Redirects an Fread request to the appropriate handler based on the
  171. //! specified file handle.
  172. //!
  173. //! \param[in] handleNumber Handle of the file to read from
  174. //! \param[out] pBuffer Buffer in which the data to be read is placed
  175. //! \param[in] numBytesToRead Number of bytes to read from the file
  176. //!
  177. //! \return Number of bytes read if the steering function was successful or an RtStatus_t error.
  178. //! \retval ERROR_OS_FILESYSTEM_NO_STEERING_FUNCTION If there is no steering function defined for \c filehandle
  179. //!
  180. //! \internal
  181. //! \see To view the function definition, see fs_steering.c.
  182. ///////////////////////////////////////////////////////////////////////////////
  183. int32_t Fread(int32_t handleNumber, uint8_t * pBuffer, int32_t numBytesToRead);
  184. ///////////////////////////////////////////////////////////////////////////////
  185. //! \brief Redirects an Fwrite request
  186. //!
  187. //! \fntype Function
  188. //!
  189. //! Redirects an Fwrite request to the appropriate handler based on the
  190. //! specified file handle.
  191. //!
  192. //! \param[in] handleNumber Handle of the file to write to
  193. //! \param[in] pBuffer Buffer holding the data to be written
  194. //! \param[in] numBytesToWrite Number of bytes to write to the file
  195. //!
  196. //! \return Number of bytes read if the steering function was successful or an RtStatus_t error.
  197. //! \retval ERROR_OS_FILESYSTEM_NO_STEERING_FUNCTION If there is no steering function defined for \c filehandle
  198. //!
  199. //! \internal
  200. //! \see To view the function definition, see fs_steering.c.
  201. ///////////////////////////////////////////////////////////////////////////////
  202. int32_t Fwrite(int32_t handleNumber, uint8_t * pBuffer, int32_t numBytesToWrite);
  203. ///////////////////////////////////////////////////////////////////////////////
  204. //! \brief Redirects an Fseek request
  205. //!
  206. //! \fntype Function
  207. //!
  208. //! Redirects an Fseek request to the appropriate handler based on the
  209. //! specified file handle.
  210. //!
  211. //! \param[in] handleNumber Handle of the file to seek
  212. //! \param[in] numBytesToSeek Relative number of bytes to seek
  213. //! \param[in] seekPosition Value indicating where to seek from
  214. //!
  215. //! \retval ERROR_OS_FILESYSTEM_NO_STEERING_FUNCTION If there is no steering function defined for \c filehandle
  216. //! \retval RtStatus_t The return value of the steering function
  217. //! \internal
  218. //! \see To view the function definition, see fs_steering.c.
  219. ///////////////////////////////////////////////////////////////////////////////
  220. RtStatus_t Fseek(int32_t handleNumber, int32_t numBytesToSeek, int32_t seekPosition);
  221. ////////////////////////////////////////////////////////////////////////////////
  222. //!
  223. //! \brief Fopen Opens a file for subsequent access.
  224. //!
  225. //! \param[in] filepath Pointer to a null-terminated ASCII string that contains the name of the file to open.
  226. //!
  227. //! \param[in] mode Null-terminated ASCII string that specifies how the file will be accessed. It must be one of the following:
  228. //!
  229. //! - "r" = open for reading only
  230. //! - "r+" = same as "r", also allows writing
  231. //! - "w" = open for writing only, file will be created if it does
  232. //! not exist, and will be overwritten if it does exist
  233. //! - "w+" = same as "w", also allows reading
  234. //! - "a" = open for appending to end of file, upon opening
  235. //! file position is set to end-of-file
  236. //! - "a+" = same as "a", also allows reading/writing
  237. //!
  238. //!
  239. //! \param[out] handle Returns an int32_t which uniquely identifies the file while it is open, and which must be
  240. //! used on all subsequent file system calls to access this file If this value is negative, then an error occurred.
  241. //!
  242. //!
  243. //! Long file name considerations
  244. //!
  245. //!
  246. //! When creating a file (opening it with either "w" or "w+" modes) the
  247. //! FAT file system uses the following considerations to determine whether
  248. //! the file name will be stored on the media with a short name only (older
  249. //! style) or with both a short name and a long name.
  250. //!
  251. //! - The file name is parsed into 2 parts, the part before the period (filespec) and the part after (extension)
  252. //!
  253. //! - If more than one period is found during parsing, a long file name is created.
  254. //!
  255. //! - If the filespec is more than 11 characters long a long file name is created.
  256. //!
  257. //! - If the extension is more than 3 characters long a long file name is created
  258. //!
  259. //! - If the filespec or the extension contains a space character or any one of +,;=[](plus-sign,comma,semi-colon,
  260. //! equal-sign,open-brace,close-brace) then a long file name is created.
  261. //!
  262. //! - If a long file name is not used, the filepec and extension are converted
  263. //! to upper case, and the resulting short file name is created.
  264. //!
  265. //!
  266. //! \internal
  267. //!
  268. //! All of the checking listed above actually takes place in
  269. //! the function 'IsShortNameValid()' (which is in 'isshortnamevalid.c')
  270. //!
  271. ///////////////////////////////////////////////////////////////////////////////
  272. RtStatus_t Fopen(uint8_t * filepath, uint8_t * mode);
  273. ///////////////////////////////////////////////////////////////////////////////
  274. //!
  275. //! \brief Fopenw Opens a file for subsequent access.
  276. //!
  277. //! \param[in] filepath Pointer to a null-terminated UNICODE string that contains the name of the file to open.
  278. //!
  279. //! \param[in] mode Null-terminated ASCII string that specifies how the file will be accessed. It must be one of the following:
  280. //!
  281. //! - "r" = open for reading only
  282. //! - "r+" = same as "r", also allows writing
  283. //! - "w" = open for writing only, file will be created if it does
  284. //! not exist, and will be overwritten if it does exist
  285. //! - "w+" = same as "w", also allows reading
  286. //! - "a" = open for appending to end of file, upon opening
  287. //! file position is set to end-of-file
  288. //! - "a+" = same as "a", also allows reading/writing
  289. //!
  290. //!
  291. //! \param[out] handle Returns an int32_t which uniquely identifies the file while it is open, and which must be
  292. //! used on all subsequent file system calls to access this file If this value is negative, then an error occurred.
  293. //!
  294. //!
  295. //! Long file name considerations
  296. //!
  297. //! Since the input filepath is in UNICODE, this function ALWAYS creates a long file name
  298. //!
  299. RtStatus_t Fopenw(uint8_t * filepath, uint8_t * mode);
  300. RtStatus_t Fclose_FAT(int32_t HandleNumber);
  301. RtStatus_t Fgetc(int32_t HandleNumber);
  302. RtStatus_t Fputc(int32_t HandleNumber, int32_t ByteToWrite);
  303. uint8_t *Fgets(int32_t HandleNumber, int32_t NumBytes, uint8_t * Buffer);
  304. uint8_t *Fputs(int32_t HandleNumber, uint8_t * Buffer);
  305. RtStatus_t Fread_FAT(int32_t HandleNumber, uint8_t * Buffer, int32_t NumBytesToRead);
  306. RtStatus_t Fwrite_FAT(int32_t HandleNumber, uint8_t * Buffer, int32_t NumBytesToWrite);
  307. int32_t Feof(int32_t HandleNumber);
  308. int32_t Ftell(int32_t HandleNumber);
  309. int32_t Ferror(int32_t HandleNumber);
  310. RtStatus_t Fseek_FAT(int32_t HandleNumber, int32_t NumBytesToSeek, int32_t SeekPosition);
  311. RtStatus_t Fflush(int32_t HandleNumber);
  312. RtStatus_t Fremove(const uint8_t * filepath);
  313. RtStatus_t Fremovew(uint8_t * filepath);
  314. ////////////////////////////////////////////////////////////////////////////////
  315. // Miscellaneous File System Prototypes
  316. ////////////////////////////////////////////////////////////////////////////////
  317. ///////////////////////////////////////////////////////////////////////////////
  318. //! \brief Initializes the file system.
  319. //!
  320. //! \param[in] bufx Pointer to X buffer for allocation of cache buffers.
  321. //! \param[in] bufy Pointer to Y buffer for allocation of handles, descriptors, etc.
  322. //! \param[in] maxdevices Max number of internal + external media supported.
  323. //! \param[in] maxhandles Max handles supported.
  324. //! \param[in] maxcaches Max cache buffers supported.
  325. //!
  326. //! \return Status of the call.
  327. //! \retval 0 If the call was successful.
  328. ///////////////////////////////////////////////////////////////////////////////
  329. RtStatus_t FSInit(uint8_t * bufx, uint8_t * bufy, int32_t maxdevices, int32_t maxhandles,
  330. int32_t maxcaches);
  331. int32_t FSDriveInit(int32_t DeviceNumber);
  332. int32_t FSDriveShutdown(int32_t DeviceNumber);
  333. ///////////////////////////////////////////////////////////////////////////////
  334. //! \brief Determines free space by reading the all records
  335. //!
  336. //! \return Status of the call.
  337. //! \retval 0 If successful.
  338. ///////////////////////////////////////////////////////////////////////////////
  339. RtStatus_t FSShutdown(void);
  340. ///////////////////////////////////////////////////////////////////////////////
  341. //! \brief Determines total free clusters by first checking FAT type.
  342. //!
  343. //! \param[in] DeviceNumber Device number.
  344. //!
  345. //! \return Returns total number of free clusters.
  346. ///////////////////////////////////////////////////////////////////////////////
  347. int32_t Computefreecluster(int32_t DeviceNumber);
  348. ///////////////////////////////////////////////////////////////////////////////
  349. //! \brief Gets the size of the file.
  350. //!
  351. //! \param[in] HandleNumber File handle.
  352. //!
  353. //! \return Status of the call.
  354. //! \retval 0 If the call was successful.
  355. //! \retval error If an error occurred.
  356. ///////////////////////////////////////////////////////////////////////////////
  357. RtStatus_t GetFileSize(int32_t HandleNumber);
  358. ///////////////////////////////////////////////////////////////////////////////
  359. //! \brief Flushes only the dirty cache buffers that contain valid
  360. //! data to the disk, but invalidates all cache entries.
  361. //!
  362. //! \return Status of the call.
  363. ///////////////////////////////////////////////////////////////////////////////
  364. RtStatus_t FlushCache(void);
  365. ///////////////////////////////////////////////////////////////////////////////
  366. //! \brief For device "deviceNumber", flushes only the dirty cache buffers that contain valid
  367. //! data to the disk, and invalidates their cache entries.
  368. ///////////////////////////////////////////////////////////////////////////////
  369. int32_t FSFlushDriveCache(int32_t deviceNumber); //The real code calls for RtStatus_t
  370. ///////////////////////////////////////////////////////////////////////////////
  371. //! \brief Returns FAT type.
  372. //!
  373. //! \param[in] DeviceNum
  374. ///////////////////////////////////////////////////////////////////////////////
  375. int32_t FSFATType(int32_t DeviceNum);
  376. ///////////////////////////////////////////////////////////////////////////////
  377. //! \brief Returns a value that indicates whether the specified device is present.
  378. //!
  379. //! \param[in] DeviceNum Device number of the specified device.
  380. //!
  381. //! \return A value that indicates whether the device is present.
  382. ///////////////////////////////////////////////////////////////////////////////
  383. int32_t FSMediaPresent(int32_t DeviceNum);
  384. int32_t FSFreeClusters(int32_t Device);
  385. int64_t FSFreeSpace(int32_t Device);
  386. int64_t FSFreeSpaceFromHandle(int32_t HandleNumber);
  387. int32_t FSSize(int32_t DeviceNum);
  388. ////////////////////////////////////////////////////////////////////////////////
  389. // Directory API
  390. ////////////////////////////////////////////////////////////////////////////////
  391. ///////////////////////////////////////////////////////////////////////////////
  392. //! \brief Searches for the given directoy path and if the path is found
  393. //! then changes the current working directoy to the given directory path.
  394. //!
  395. //! \param[in] filepath Pointer to file name.
  396. //!
  397. //! \return Status of the call.
  398. //! \retval SUCCESS
  399. //! \retval Error If error occurs.
  400. ///////////////////////////////////////////////////////////////////////////////
  401. RtStatus_t Chdir(uint8_t * filepath);
  402. ///////////////////////////////////////////////////////////////////////////////
  403. //! \brief Searches for the given directoy path for UNICODE string and if the path is found
  404. //! then changes the current working directoy to the given directory path.
  405. //!
  406. //! \param[in] filepath Pointer to the file name.
  407. //!
  408. //! \return Status of the call.
  409. //! \retval SUCCESS
  410. //! \retval Error If error occurs.
  411. ///////////////////////////////////////////////////////////////////////////////
  412. RtStatus_t Chdirw(uint8_t * filepath);
  413. RtStatus_t Mkdir(uint8_t * filepath);
  414. RtStatus_t Mkdirw(uint8_t * filepath);
  415. ///////////////////////////////////////////////////////////////////////////////
  416. //! \brief Searches for the given directory, and if it is found, empties and
  417. //! deletes the directory.
  418. //!
  419. //! \param[in] filepath Pointer to the file name.
  420. //!
  421. //! \return Status of the call.
  422. //! \retval FS_SUCCESS If call was successful.
  423. //! \retval Error If error occurs.
  424. ///////////////////////////////////////////////////////////////////////////////
  425. RtStatus_t Rmdir(uint8_t * filepath);
  426. ///////////////////////////////////////////////////////////////////////////////
  427. //! \brief Searches for the given directory, and if it is found, empties and
  428. //! deletes the directory.
  429. //!
  430. //! \param[in] filepath Pointer to the file name.
  431. //!
  432. //! \return Status of the call.
  433. //! \retval FS_SUCCESS If call was successful.
  434. //! \retval Error If error occurs.
  435. //!
  436. //! \note This function considers the string to be Unicode.
  437. ///////////////////////////////////////////////////////////////////////////////
  438. RtStatus_t Rmdirw(uint8_t * filepath);
  439. ///////////////////////////////////////////////////////////////////////////////
  440. //! \brief Deletes all the files and directories of the specified path.
  441. //!
  442. //! \param[in] Path Pointer to the directory path.
  443. //!
  444. //! \return Status of the call.
  445. //! \retval 0 If the call was successful.
  446. //! \retval Error If an error occurs.
  447. ///////////////////////////////////////////////////////////////////////////////
  448. int32_t DeleteTree(uint8_t * Path);
  449. int32_t Frename(uint8_t * oldFilename, uint8_t * newFilename);
  450. ///////////////////////////////////////////////////////////////////////////////
  451. //! \brief Returns the pointer to the \c gCurrentWorkingdirectory string buffer.
  452. //!
  453. //! \return Pointer to current working directory buffer.
  454. ///////////////////////////////////////////////////////////////////////////////
  455. uint8_t *Getcwd(void);
  456. ///////////////////////////////////////////////////////////////////////////////
  457. //! \brief TBD
  458. //!
  459. //! \param[in] DeviceNo Device number to set the cwd handle to root dir of
  460. //!
  461. //! \retval 0 If successful
  462. ///////////////////////////////////////////////////////////////////////////////
  463. int32_t SetCWDHandle(int32_t DeviceNo);
  464. ////////////////////////////////////////////////////////////////////////////////
  465. // Find file API
  466. ////////////////////////////////////////////////////////////////////////////////
  467. ///////////////////////////////////////////////////////////////////////////////
  468. //! \brief Provides base, file name, and extension of the file to the FindNext() function.
  469. //!
  470. //! \param[in] _finddata File specification
  471. //! \param[in] FileName Pointer to the file name.
  472. //!
  473. //! \return Status of the call.
  474. //! \retval 0 If successful.
  475. //! \retval Error
  476. //!
  477. //! \note This function should not be called from multiple tasks.
  478. ///////////////////////////////////////////////////////////////////////////////
  479. RtStatus_t FindFirstLFN(FindData_t * _finddata, uint8_t * FileName, void *);
  480. RtStatus_t FindFirst(FindData_t * _finddata, uint8_t * FileName);
  481. RtStatus_t FindNextLFN(int32_t HandleNumber, FindData_t * _finddata, void *);
  482. RtStatus_t FindNext(int32_t HandleNumber, FindData_t * _finddata);
  483. RtStatus_t FindClose(int32_t HandleNumber);
  484. ////////////////////////////////////////////////////////////////////////////////
  485. // File attribute API
  486. ////////////////////////////////////////////////////////////////////////////////
  487. ///////////////////////////////////////////////////////////////////////////////
  488. //! \brief Finds the creation or modification date or time of
  489. //! the file referenced by the given handle number.
  490. //!
  491. //! \param[in] HandleNumber Handle number.
  492. //! \param[in] crt_mod_date_time_para Create-modify-date-time parameter.
  493. //! \param[in] dirdate Pointer to the DIR_DATE structure.
  494. //! \param[in] dirtime Pointer to the DIR_TIME structure.
  495. //!
  496. //! \return Status of the call.
  497. //! \retval 0 If successful.
  498. //! \retval ERROR If an error occurs.
  499. ///////////////////////////////////////////////////////////////////////////////
  500. RtStatus_t filegetdate(int32_t HandleNumber, int32_t crt_mod_date_time_para, DIR_DATE * dirdate,
  501. DIR_TIME * dirtime);
  502. ///////////////////////////////////////////////////////////////////////////////
  503. //! \brief Sets the creation or modification date or time of
  504. //! the file referenced by the given handle to the specified date or time.
  505. //!
  506. //! \param[in] FilePath Pointer to the file path.
  507. //! \param[in] crt_mod_date_time_para Create-modify-date-time parameter.
  508. //! \param[in] dirdate Pointer to the DIR_DATE structure.
  509. //! \param[in] dirtime Pointer to the DIR_TIME structure.
  510. //!
  511. //! \return Status of the call.
  512. //! \retval 0 If successful.
  513. //! \retval Error
  514. ///////////////////////////////////////////////////////////////////////////////
  515. RtStatus_t filesetdate(uint8_t * FilePath, int32_t crt_mod_date_time_para, DIR_DATE * dirdate,
  516. DIR_TIME * dirtime);
  517. ///////////////////////////////////////////////////////////////////////////////
  518. //! \brief Gets directory attributes for a file based on the file handle.
  519. //!
  520. //! \param[in] HandleNumber File Handle.
  521. //!
  522. //! \return Returns directory attributes for a file or an error Code if an error occurs.
  523. ///////////////////////////////////////////////////////////////////////////////
  524. RtStatus_t filegetattribhandle(int32_t HandleNumber);
  525. ///////////////////////////////////////////////////////////////////////////////
  526. //! \brief Gets directory attributes for a file.
  527. //!
  528. //! \param[in] FilePath Pointer to the file path.
  529. //!
  530. //! \return Returns directory attributes for a file or an error Code if an error occurs.
  531. ///////////////////////////////////////////////////////////////////////////////
  532. RtStatus_t filegetattrib(uint8_t * FilePath);
  533. ///////////////////////////////////////////////////////////////////////////////
  534. //! \brief Sets directory attributes for a file.
  535. //!
  536. //! \param[in] HandleNumber TBD
  537. //! \param[in] dirattribute TBD
  538. //!
  539. //! \return Status of the call.
  540. //! \retval SUCCESS If call was successful.
  541. //! \retval ERROR If an error occurs.
  542. ///////////////////////////////////////////////////////////////////////////////
  543. RtStatus_t filesetattrib(int32_t HandleNumber, int32_t dirattribute);
  544. ///////////////////////////////////////////////////////////////////////////////
  545. //! \brief Provides long file name.
  546. //!
  547. //! \param[in] HandleNumber TBD
  548. //! \param[in] RecordNumber TBD
  549. //! \param[in] LFNBuffer Pointer to the file name buffer.
  550. //!
  551. //! \return Returns length of the long file name string.
  552. ///////////////////////////////////////////////////////////////////////////////
  553. int32_t ConstructLongFileName(int32_t HandleNumber, int32_t RecordNumber, int8_t * LFNBuffer);
  554. #if defined(__cplusplus)
  555. } // extern "C"
  556. #endif // __cplusplus
  557. #endif //_FS_API_H
  558. ///////////////////////////////////////////////////////////////////////////////// End of file/////////////////////////////////////////////////////////////////////////////////! @}