UbixOS  2.0
fat_misc.c
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //-----------------------------------------------------------------------------
3 // FAT16/32 File IO Library
4 // V2.6
5 // Ultra-Embedded.com
6 // Copyright 2003 - 2012
7 //
8 // Email: admin@ultra-embedded.com
9 //
10 // License: GPL
11 // If you would like a version with a more permissive license for use in
12 // closed source commercial applications please contact me for details.
13 //-----------------------------------------------------------------------------
14 //
15 // This file is part of FAT File IO Library.
16 //
17 // FAT File IO Library is free software; you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation; either version 2 of the License, or
20 // (at your option) any later version.
21 //
22 // FAT File IO Library is distributed in the hope that it will be useful,
23 // but WITHOUT ANY WARRANTY; without even the implied warranty of
24 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 // GNU General Public License for more details.
26 //
27 // You should have received a copy of the GNU General Public License
28 // along with FAT File IO Library; if not, write to the Free Software
29 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
32 #include <string.h>
33 #include "fat_misc.h"
34 
35 //-----------------------------------------------------------------------------
36 // fatfs_lfn_cache_init: Clear long file name cache
37 //-----------------------------------------------------------------------------
38 void fatfs_lfn_cache_init(struct lfn_cache *lfn, int wipeTable) {
39  int i = 0;
40 
41  lfn->no_of_strings = 0;
42 
43 #if FATFS_INC_LFN_SUPPORT
44 
45  // Zero out buffer also
46  if (wipeTable)
47  for (i = 0; i < MAX_LONGFILENAME_ENTRIES; i++)
48  memset(lfn->String[i], 0x00, MAX_LFN_ENTRY_LENGTH);
49 #endif
50 }
51 //-----------------------------------------------------------------------------
52 // fatfs_lfn_cache_entry - Function extracts long file name text from sector
53 // at a specific offset
54 //-----------------------------------------------------------------------------
55 #if FATFS_INC_LFN_SUPPORT
56 void fatfs_lfn_cache_entry(struct lfn_cache *lfn, uint8 *entryBuffer) {
57  uint8 LFNIndex, i;
58  LFNIndex = entryBuffer[0] & 0x1F;
59 
60  // Limit file name to cache size!
61  if (LFNIndex > MAX_LONGFILENAME_ENTRIES)
62  return;
63 
64  // This is an error condition
65  if (LFNIndex == 0)
66  return;
67 
68  if (lfn->no_of_strings == 0)
69  lfn->no_of_strings = LFNIndex;
70 
71  lfn->String[LFNIndex - 1][0] = entryBuffer[1];
72  lfn->String[LFNIndex - 1][1] = entryBuffer[3];
73  lfn->String[LFNIndex - 1][2] = entryBuffer[5];
74  lfn->String[LFNIndex - 1][3] = entryBuffer[7];
75  lfn->String[LFNIndex - 1][4] = entryBuffer[9];
76  lfn->String[LFNIndex - 1][5] = entryBuffer[0x0E];
77  lfn->String[LFNIndex - 1][6] = entryBuffer[0x10];
78  lfn->String[LFNIndex - 1][7] = entryBuffer[0x12];
79  lfn->String[LFNIndex - 1][8] = entryBuffer[0x14];
80  lfn->String[LFNIndex - 1][9] = entryBuffer[0x16];
81  lfn->String[LFNIndex - 1][10] = entryBuffer[0x18];
82  lfn->String[LFNIndex - 1][11] = entryBuffer[0x1C];
83  lfn->String[LFNIndex - 1][12] = entryBuffer[0x1E];
84 
85  for (i = 0; i < MAX_LFN_ENTRY_LENGTH; i++)
86  if (lfn->String[LFNIndex - 1][i] == 0xFF)
87  lfn->String[LFNIndex - 1][i] = 0x20; // Replace with spaces
88 }
89 #endif
90 //-----------------------------------------------------------------------------
91 // fatfs_lfn_cache_get: Get a reference to the long filename
92 //-----------------------------------------------------------------------------
93 #if FATFS_INC_LFN_SUPPORT
94 char* fatfs_lfn_cache_get(struct lfn_cache *lfn) {
95  // Null terminate long filename
97  lfn->Null = '\0';
98  else if (lfn->no_of_strings)
99  lfn->String[lfn->no_of_strings][0] = '\0';
100  else
101  lfn->String[0][0] = '\0';
102 
103  return (char*) &lfn->String[0][0];
104 }
105 #endif
106 //-----------------------------------------------------------------------------
107 // fatfs_entry_lfn_text: If LFN text entry found
108 //-----------------------------------------------------------------------------
109 #if FATFS_INC_LFN_SUPPORT
111  if ((entry->Attr & FILE_ATTR_LFN_TEXT) == FILE_ATTR_LFN_TEXT)
112  return 1;
113  else
114  return 0;
115 }
116 #endif
117 //-----------------------------------------------------------------------------
118 // fatfs_entry_lfn_invalid: If SFN found not relating to LFN
119 //-----------------------------------------------------------------------------
120 #if FATFS_INC_LFN_SUPPORT
122  if ((entry->Name[0] == FILE_HEADER_BLANK) || (entry->Name[0] == FILE_HEADER_DELETED) || (entry->Attr == FILE_ATTR_VOLUME_ID) || (entry->Attr & FILE_ATTR_SYSHID))
123  return 1;
124  else
125  return 0;
126 }
127 #endif
128 //-----------------------------------------------------------------------------
129 // fatfs_entry_lfn_exists: If LFN exists and correlation SFN found
130 //-----------------------------------------------------------------------------
131 #if FATFS_INC_LFN_SUPPORT
132 int fatfs_entry_lfn_exists(struct lfn_cache *lfn, struct fat_dir_entry *entry) {
133  if ((entry->Attr != FILE_ATTR_LFN_TEXT) && (entry->Name[0] != FILE_HEADER_BLANK) && (entry->Name[0] != FILE_HEADER_DELETED) && (entry->Attr != FILE_ATTR_VOLUME_ID) && (!(entry->Attr & FILE_ATTR_SYSHID)) && (lfn->no_of_strings))
134  return 1;
135  else
136  return 0;
137 }
138 #endif
139 //-----------------------------------------------------------------------------
140 // fatfs_entry_sfn_only: If SFN only exists
141 //-----------------------------------------------------------------------------
143  if ((entry->Attr != FILE_ATTR_LFN_TEXT) && (entry->Name[0] != FILE_HEADER_BLANK) && (entry->Name[0] != FILE_HEADER_DELETED) && (entry->Attr != FILE_ATTR_VOLUME_ID) && (!(entry->Attr & FILE_ATTR_SYSHID)))
144  return 1;
145  else
146  return 0;
147 }
148 // TODO: FILE_ATTR_SYSHID ?!?!??!
149 //-----------------------------------------------------------------------------
150 // fatfs_entry_is_dir: Returns 1 if a directory
151 //-----------------------------------------------------------------------------
152 int fatfs_entry_is_dir(struct fat_dir_entry *entry) {
153  if (entry->Attr & FILE_TYPE_DIR)
154  return 1;
155  else
156  return 0;
157 }
158 //-----------------------------------------------------------------------------
159 // fatfs_entry_is_file: Returns 1 is a file entry
160 //-----------------------------------------------------------------------------
161 int fatfs_entry_is_file(struct fat_dir_entry *entry) {
162  // 2020-01-26 (MrOlsen): 0x20 = Archive so 0x0 should work too?
163  if ((entry->Attr == 0x0) || (entry->Attr & FILE_TYPE_FILE))
164  return 1;
165  else
166  return 0;
167 }
168 
169 //-----------------------------------------------------------------------------
170 // fatfs_lfn_entries_required: Calculate number of 13 characters entries
171 //-----------------------------------------------------------------------------
172 #if FATFS_INC_LFN_SUPPORT
173 int fatfs_lfn_entries_required(char *filename) {
174  int length = (int) strlen(filename);
175 
176  if (length)
177  return (length + MAX_LFN_ENTRY_LENGTH - 1) / MAX_LFN_ENTRY_LENGTH;
178  else
179  return 0;
180 }
181 #endif
182 //-----------------------------------------------------------------------------
183 // fatfs_filename_to_lfn:
184 //-----------------------------------------------------------------------------
185 #if FATFS_INC_LFN_SUPPORT
186 void fatfs_filename_to_lfn(char *filename, uint8 *buffer, int entry, uint8 sfnChk) {
187  int i;
188  int nameIndexes[MAX_LFN_ENTRY_LENGTH] = { 1, 3, 5, 7, 9, 0x0E, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1C, 0x1E };
189 
190  // 13 characters entries
191  int length = (int) strlen(filename);
192  int entriesRequired = fatfs_lfn_entries_required(filename);
193 
194  // Filename offset
195  int start = entry * MAX_LFN_ENTRY_LENGTH;
196 
197  // Initialise to zeros
199 
200  // LFN entry number
201  buffer[0] = (uint8) (((entriesRequired - 1) == entry) ? (0x40 | (entry + 1)) : (entry + 1));
202 
203  // LFN flag
204  buffer[11] = 0x0F;
205 
206  // Checksum of short filename
207  buffer[13] = sfnChk;
208 
209  // Copy to buffer
210  for (i = 0; i < MAX_LFN_ENTRY_LENGTH; i++) {
211  if ((start + i) < length)
212  buffer[nameIndexes[i]] = filename[start + i];
213  else if ((start + i) == length)
214  buffer[nameIndexes[i]] = 0x00;
215  else {
216  buffer[nameIndexes[i]] = 0xFF;
217  buffer[nameIndexes[i] + 1] = 0xFF;
218  }
219  }
220 }
221 #endif
222 //-----------------------------------------------------------------------------
223 // fatfs_sfn_create_entry: Create the short filename directory entry
224 //-----------------------------------------------------------------------------
225 #if FATFS_INC_WRITE_SUPPORT
226 void fatfs_sfn_create_entry(char *shortfilename, uint32 size, uint32 startCluster, struct fat_dir_entry *entry, int dir) {
227  int i;
228 
229  // Copy short filename
230  for (i = 0; i < FAT_SFN_SIZE_FULL; i++)
231  entry->Name[i] = shortfilename[i];
232 
233  // Unless we have a RTC we might as well set these to 1980
234  entry->CrtTimeTenth = 0x00;
235  entry->CrtTime[1] = entry->CrtTime[0] = 0x00;
236  entry->CrtDate[1] = 0x00;
237  entry->CrtDate[0] = 0x20;
238  entry->LstAccDate[1] = 0x00;
239  entry->LstAccDate[0] = 0x20;
240  entry->WrtTime[1] = entry->WrtTime[0] = 0x00;
241  entry->WrtDate[1] = 0x00;
242  entry->WrtDate[0] = 0x20;
243 
244  if (!dir)
245  entry->Attr = FILE_TYPE_FILE;
246  else
247  entry->Attr = FILE_TYPE_DIR;
248 
249  entry->NTRes = 0x00;
250 
251  entry->FstClusHI = FAT_HTONS((uint16 )((startCluster >> 16) & 0xFFFF));
252  entry->FstClusLO = FAT_HTONS((uint16 )((startCluster >> 0) & 0xFFFF));
253  entry->FileSize = FAT_HTONL(size);
254 }
255 #endif
256 //-----------------------------------------------------------------------------
257 // fatfs_lfn_create_sfn: Create a padded SFN
258 //-----------------------------------------------------------------------------
259 #if FATFS_INC_WRITE_SUPPORT
260 int fatfs_lfn_create_sfn(char *sfn_output, char *filename) {
261  int i;
262  int dotPos = -1;
263  char ext[3];
264  int pos;
265  int len = (int) strlen(filename);
266 
267  // Invalid to start with .
268  if (filename[0] == '.')
269  return 0;
270 
271  memset(sfn_output, ' ', FAT_SFN_SIZE_FULL);
272  memset(ext, ' ', 3);
273 
274  // Find dot seperator
275  for (i = 0; i < len; i++) {
276  if (filename[i] == '.')
277  dotPos = i;
278  }
279 
280  // Extract extensions
281  if (dotPos != -1) {
282  // Copy first three chars of extension
283  for (i = (dotPos + 1); i < (dotPos + 1 + 3); i++)
284  if (i < len)
285  ext[i - (dotPos + 1)] = filename[i];
286 
287  // Shorten the length to the dot position
288  len = dotPos;
289  }
290 
291  // Add filename part
292  pos = 0;
293  for (i = 0; i < len; i++) {
294  if ((filename[i] != ' ') && (filename[i] != '.')) {
295  if (filename[i] >= 'a' && filename[i] <= 'z')
296  sfn_output[pos++] = filename[i] - 'a' + 'A';
297  else
298  sfn_output[pos++] = filename[i];
299  }
300 
301  // Fill upto 8 characters
302  if (pos == FAT_SFN_SIZE_PARTIAL)
303  break;
304  }
305 
306  // Add extension part
307  for (i = FAT_SFN_SIZE_PARTIAL; i < FAT_SFN_SIZE_FULL; i++) {
308  if (ext[i - FAT_SFN_SIZE_PARTIAL] >= 'a' && ext[i - FAT_SFN_SIZE_PARTIAL] <= 'z')
309  sfn_output[i] = ext[i - FAT_SFN_SIZE_PARTIAL] - 'a' + 'A';
310  else
311  sfn_output[i] = ext[i - FAT_SFN_SIZE_PARTIAL];
312  }
313 
314  return 1;
315 }
316 //-----------------------------------------------------------------------------
317 // fatfs_itoa:
318 //-----------------------------------------------------------------------------
319 static void fatfs_itoa(uint32 num, char *s) {
320  char *cp;
321  char outbuf[12];
322  const char digits[] = "0123456789ABCDEF";
323 
324  // Build string backwards
325  cp = outbuf;
326  do {
327  *cp++ = digits[(int) (num % 10)];
328  } while ((num /= 10) > 0);
329 
330  *cp-- = 0;
331 
332  // Copy in forwards
333  while (cp >= outbuf)
334  *s++ = *cp--;
335 
336  *s = 0;
337 }
338 #endif
339 //-----------------------------------------------------------------------------
340 // fatfs_lfn_generate_tail:
341 // sfn_input = Input short filename, spaced format & in upper case
342 // sfn_output = Output short filename with tail
343 //-----------------------------------------------------------------------------
344 #if FATFS_INC_LFN_SUPPORT
345 #if FATFS_INC_WRITE_SUPPORT
346 int fatfs_lfn_generate_tail(char *sfn_output, char *sfn_input, uint32 tailNum) {
347  int tail_chars;
348  char tail_str[12];
349 
350  if (tailNum > 99999)
351  return 0;
352 
353  // Convert to number
354  memset(tail_str, 0x00, sizeof(tail_str));
355  tail_str[0] = '~';
356  fatfs_itoa(tailNum, tail_str + 1);
357 
358  // Copy in base filename
359  memcpy(sfn_output, sfn_input, FAT_SFN_SIZE_FULL);
360 
361  // Overwrite with tail
362  tail_chars = (int) strlen(tail_str);
363  memcpy(sfn_output + (FAT_SFN_SIZE_PARTIAL - tail_chars), tail_str, tail_chars);
364 
365  return 1;
366 }
367 #endif
368 #endif
369 //-----------------------------------------------------------------------------
370 // fatfs_convert_from_fat_time: Convert FAT time to h/m/s
371 //-----------------------------------------------------------------------------
372 #if FATFS_INC_TIME_DATE_SUPPORT
373 void fatfs_convert_from_fat_time(uint16 fat_time, int *hours, int *minutes, int *seconds)
374 {
375  *hours = (fat_time >> FAT_TIME_HOURS_SHIFT) & FAT_TIME_HOURS_MASK;
376  *minutes = (fat_time >> FAT_TIME_MINUTES_SHIFT) & FAT_TIME_MINUTES_MASK;
377  *seconds = (fat_time >> FAT_TIME_SECONDS_SHIFT) & FAT_TIME_SECONDS_MASK;
378  *seconds = *seconds * FAT_TIME_SECONDS_SCALE;
379 }
380 //-----------------------------------------------------------------------------
381 // fatfs_convert_from_fat_date: Convert FAT date to d/m/y
382 //-----------------------------------------------------------------------------
383 void fatfs_convert_from_fat_date(uint16 fat_date, int *day, int *month, int *year)
384 {
385  *day = (fat_date >> FAT_DATE_DAY_SHIFT) & FAT_DATE_DAY_MASK;
386  *month = (fat_date >> FAT_DATE_MONTH_SHIFT) & FAT_DATE_MONTH_MASK;
387  *year = (fat_date >> FAT_DATE_YEAR_SHIFT) & FAT_DATE_YEAR_MASK;
388  *year = *year + FAT_DATE_YEAR_OFFSET;
389 }
390 //-----------------------------------------------------------------------------
391 // fatfs_convert_to_fat_time: Convert h/m/s to FAT time
392 //-----------------------------------------------------------------------------
393 uint16 fatfs_convert_to_fat_time(int hours, int minutes, int seconds)
394 {
395  uint16 fat_time = 0;
396 
397  // Most FAT times are to a resolution of 2 seconds
398  seconds /= FAT_TIME_SECONDS_SCALE;
399 
400  fat_time = (hours & FAT_TIME_HOURS_MASK) << FAT_TIME_HOURS_SHIFT;
401  fat_time|= (minutes & FAT_TIME_MINUTES_MASK) << FAT_TIME_MINUTES_SHIFT;
402  fat_time|= (seconds & FAT_TIME_SECONDS_MASK) << FAT_TIME_SECONDS_SHIFT;
403 
404  return fat_time;
405 }
406 //-----------------------------------------------------------------------------
407 // fatfs_convert_to_fat_date: Convert d/m/y to FAT date
408 //-----------------------------------------------------------------------------
409 uint16 fatfs_convert_to_fat_date(int day, int month, int year)
410 {
411  uint16 fat_date = 0;
412 
413  // FAT dates are relative to 1980
414  if (year >= FAT_DATE_YEAR_OFFSET)
415  year -= FAT_DATE_YEAR_OFFSET;
416 
417  fat_date = (day & FAT_DATE_DAY_MASK) << FAT_DATE_DAY_SHIFT;
418  fat_date|= (month & FAT_DATE_MONTH_MASK) << FAT_DATE_MONTH_SHIFT;
419  fat_date|= (year & FAT_DATE_YEAR_MASK) << FAT_DATE_YEAR_SHIFT;
420 
421  return fat_date;
422 }
423 #endif
424 //-----------------------------------------------------------------------------
425 // fatfs_print_sector:
426 //-----------------------------------------------------------------------------
427 #ifdef FATFS_DEBUG
428 void fatfs_print_sector(uint32 sector, uint8 *data)
429 {
430  int i;
431  int j;
432 
433  FAT_PRINTF(("Sector %d:\n", sector));
434 
435  for (i=0;i<FAT_SECTOR_SIZE;i++)
436  {
437  if (!((i) % 16))
438  {
439  FAT_PRINTF((" %04d: ", i));
440  }
441 
442  FAT_PRINTF(("%02x", data[i]));
443  if (!((i+1) % 4))
444  {
445  FAT_PRINTF((" "));
446  }
447 
448  if (!((i+1) % 16))
449  {
450  FAT_PRINTF((" "));
451  for (j=0;j<16;j++)
452  {
453  char ch = data[i-15+j];
454 
455  // Is printable?
456  if (ch > 31 && ch < 127)
457  {
458  FAT_PRINTF(("%c", ch));
459  }
460  else
461  {
462  FAT_PRINTF(("."));
463  }
464  }
465 
466  FAT_PRINTF(("\n"));
467  }
468  }
469 }
470 #endif
fat_dir_entry::Name
uint8 Name[11]
Definition: fat_defs.h:114
FAT_TIME_MINUTES_MASK
#define FAT_TIME_MINUTES_MASK
Definition: fat_defs.h:93
FILE_ATTR_VOLUME_ID
#define FILE_ATTR_VOLUME_ID
Definition: fat_defs.h:78
buffer
char * buffer
Definition: shell.c:47
uint8
unsigned char uint8
Definition: fat_types.h:15
fat_dir_entry::WrtDate
uint8 WrtDate[2]
Definition: fat_defs.h:123
FILE_TYPE_DIR
#define FILE_TYPE_DIR
Definition: fat_defs.h:84
fatfs_print_sector
void fatfs_print_sector(uint32 sector, uint8 *data)
fatfs_sfn_create_entry
void fatfs_sfn_create_entry(char *shortfilename, uint32 size, uint32 startCluster, struct fat_dir_entry *entry, int dir)
Definition: fat_misc.c:226
string.h
fat_dir_entry::CrtTimeTenth
uint8 CrtTimeTenth
Definition: fat_defs.h:117
fatfs_convert_to_fat_time
uint16 fatfs_convert_to_fat_time(int hours, int minutes, int seconds)
fatfs_entry_is_file
int fatfs_entry_is_file(struct fat_dir_entry *entry)
Definition: fat_misc.c:161
fatfs_lfn_cache_get
char * fatfs_lfn_cache_get(struct lfn_cache *lfn)
Definition: fat_misc.c:94
fatfs_lfn_entries_required
int fatfs_lfn_entries_required(char *filename)
Definition: fat_misc.c:173
fatfs_convert_to_fat_date
uint16 fatfs_convert_to_fat_date(int day, int month, int year)
strlen
int strlen(const char *str)
Definition: strlen.c:55
FAT_DATE_MONTH_MASK
#define FAT_DATE_MONTH_MASK
Definition: fat_defs.h:100
fat_dir_entry::FstClusHI
uint16 FstClusHI
Definition: fat_defs.h:121
fatfs_lfn_cache_entry
void fatfs_lfn_cache_entry(struct lfn_cache *lfn, uint8 *entryBuffer)
Definition: fat_misc.c:56
FAT_TIME_SECONDS_SHIFT
#define FAT_TIME_SECONDS_SHIFT
Definition: fat_defs.h:94
FAT_DATE_YEAR_MASK
#define FAT_DATE_YEAR_MASK
Definition: fat_defs.h:98
FAT_HTONL
#define FAT_HTONL(n)
Definition: fat_types.h:46
FILE_HEADER_BLANK
#define FILE_HEADER_BLANK
Definition: fat_defs.h:82
memcpy
void * memcpy(const void *dst, const void *src, size_t length)
fatfs_entry_sfn_only
int fatfs_entry_sfn_only(struct fat_dir_entry *entry)
Definition: fat_misc.c:142
fatfs_entry_lfn_text
int fatfs_entry_lfn_text(struct fat_dir_entry *entry)
Definition: fat_misc.c:110
FAT_DIR_ENTRY_SIZE
#define FAT_DIR_ENTRY_SIZE
Definition: fat_defs.h:67
fat_dir_entry::CrtTime
uint8 CrtTime[2]
Definition: fat_defs.h:118
MAX_LONGFILENAME_ENTRIES
#define MAX_LONGFILENAME_ENTRIES
Definition: fat_misc.h:10
FAT_SFN_SIZE_FULL
#define FAT_SFN_SIZE_FULL
Definition: fat_defs.h:68
FAT_SECTOR_SIZE
#define FAT_SECTOR_SIZE
Definition: fat_opts.h:70
FAT_DATE_DAY_SHIFT
#define FAT_DATE_DAY_SHIFT
Definition: fat_defs.h:101
fat_dir_entry::LstAccDate
uint8 LstAccDate[2]
Definition: fat_defs.h:120
MAX_LFN_ENTRY_LENGTH
#define MAX_LFN_ENTRY_LENGTH
Definition: fat_misc.h:11
fat_misc.h
fatfs_convert_from_fat_time
void fatfs_convert_from_fat_time(uint16 fat_time, int *hours, int *minutes, int *seconds)
FAT_SFN_SIZE_PARTIAL
#define FAT_SFN_SIZE_PARTIAL
Definition: fat_defs.h:69
lfn_cache::no_of_strings
uint8 no_of_strings
Definition: fat_misc.h:37
lfn_cache
Definition: fat_misc.h:30
fatfs_lfn_cache_init
void fatfs_lfn_cache_init(struct lfn_cache *lfn, int wipeTable)
Definition: fat_misc.c:38
fat_dir_entry
Definition: fat_defs.h:112
fatfs_filename_to_lfn
void fatfs_filename_to_lfn(char *filename, uint8 *buffer, int entry, uint8 sfnChk)
Definition: fat_misc.c:186
FAT_HTONS
#define FAT_HTONS(n)
Definition: fat_types.h:45
fatfs_entry_lfn_invalid
int fatfs_entry_lfn_invalid(struct fat_dir_entry *entry)
Definition: fat_misc.c:121
lfn_cache::Null
uint8 Null
Definition: fat_misc.h:35
FAT_TIME_MINUTES_SHIFT
#define FAT_TIME_MINUTES_SHIFT
Definition: fat_defs.h:92
FAT_TIME_HOURS_SHIFT
#define FAT_TIME_HOURS_SHIFT
Definition: fat_defs.h:90
FILE_ATTR_SYSHID
#define FILE_ATTR_SYSHID
Definition: fat_defs.h:77
fatfs_entry_lfn_exists
int fatfs_entry_lfn_exists(struct lfn_cache *lfn, struct fat_dir_entry *entry)
Definition: fat_misc.c:132
fat_dir_entry::WrtTime
uint8 WrtTime[2]
Definition: fat_defs.h:122
FAT_TIME_HOURS_MASK
#define FAT_TIME_HOURS_MASK
Definition: fat_defs.h:91
FAT_TIME_SECONDS_MASK
#define FAT_TIME_SECONDS_MASK
Definition: fat_defs.h:95
lfn_cache::String
uint8 String[20][13]
Definition: fat_misc.h:34
FAT_PRINTF
#define FAT_PRINTF(a)
Definition: fat_opts.h:81
fat_dir_entry::NTRes
uint8 NTRes
Definition: fat_defs.h:116
memset
void * memset(void *dst, int c, size_t length)
uint16
unsigned short uint16
Definition: fat_types.h:16
FILE_HEADER_DELETED
#define FILE_HEADER_DELETED
Definition: fat_defs.h:83
fat_dir_entry::FstClusLO
uint16 FstClusLO
Definition: fat_defs.h:124
fatfs_entry_is_dir
int fatfs_entry_is_dir(struct fat_dir_entry *entry)
Definition: fat_misc.c:152
fat_dir_entry::CrtDate
uint8 CrtDate[2]
Definition: fat_defs.h:119
uint32
unsigned long uint32
Definition: fat_types.h:23
fatfs_lfn_generate_tail
int fatfs_lfn_generate_tail(char *sfn_output, char *sfn_input, uint32 tailNum)
Definition: fat_misc.c:346
fatfs_convert_from_fat_date
void fatfs_convert_from_fat_date(uint16 fat_date, int *day, int *month, int *year)
FAT_TIME_SECONDS_SCALE
#define FAT_TIME_SECONDS_SCALE
Definition: fat_defs.h:96
FAT_DATE_YEAR_SHIFT
#define FAT_DATE_YEAR_SHIFT
Definition: fat_defs.h:97
fat_dir_entry::Attr
uint8 Attr
Definition: fat_defs.h:115
FAT_DATE_YEAR_OFFSET
#define FAT_DATE_YEAR_OFFSET
Definition: fat_defs.h:103
FILE_ATTR_LFN_TEXT
#define FILE_ATTR_LFN_TEXT
Definition: fat_defs.h:81
FAT_DATE_DAY_MASK
#define FAT_DATE_DAY_MASK
Definition: fat_defs.h:102
FILE_TYPE_FILE
#define FILE_TYPE_FILE
Definition: fat_defs.h:85
FAT_DATE_MONTH_SHIFT
#define FAT_DATE_MONTH_SHIFT
Definition: fat_defs.h:99
fat_dir_entry::FileSize
uint32 FileSize
Definition: fat_defs.h:125
fatfs_lfn_create_sfn
int fatfs_lfn_create_sfn(char *sfn_output, char *filename)
Definition: fat_misc.c:260