Changeset 596


Ignore:
Timestamp:
Jul 9, 2015, 2:11:16 PM (9 years ago)
Author:
guerin
Message:

fat32: properly handle short names

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_fat32/fat32.c

    r587 r596  
    701701
    702702//////////////////////////////////////////////////////
     703static inline unsigned char _to_lower(unsigned char c)
     704{
     705   if (c >= 'A' && c <= 'Z') return (c | 0x20);
     706   else                      return c;
     707}
     708
     709
     710//////////////////////////////////////////////////////
    703711static inline unsigned char _to_upper(unsigned char c)
    704712{
     
    758766                                  char*          name )   // output: name
    759767{
    760     unsigned int i   = 0;
    761     unsigned int length = get_length(DIR_NAME);
    762 
    763     while ( i < length )
    764     {
    765         name[i] = buffer[i];
    766         i++;
    767     }
    768     name[i] = 0;
     768    unsigned int i;
     769    unsigned int j = 0;
     770
     771    // get name
     772    for ( i = 0; i < 8 && buffer[i] != ' '; i++ )
     773    {
     774        name[j] = _to_lower( buffer[i] );
     775        j++;
     776    }
     777
     778    // get extension
     779    for ( i = 8; i < 8 + 3 && buffer[i] != ' '; i++ )
     780    {
     781        // we entered the loop so there is an extension. add the dot
     782        if ( i == 8 )
     783        {
     784            name[j] = '.';
     785            j++;
     786        }
     787
     788        name[j] = _to_lower( buffer[i] );
     789        j++;
     790    }
     791
     792    name[j] = '\0';
    769793}
    770794
Note: See TracChangeset for help on using the changeset viewer.