fs/romfs/fs_romfsutil.c
int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset,
                        char *pname)
{
  uint32_t ndx;
  uint16_t namelen;
  uint16_t chunklen;
  bool     done;

  /* Loop until the whole name is obtained or until NAME_MAX characters
   * of the name have been parsed.
   */

  offset += ROMFS_FHDR_NAME;
  for (namelen = 0, done = false; namelen < NAME_MAX && !done; )
    {
      /* Read the sector into memory */

      ndx = romfs_devcacheread(rm, offset + namelen);
      if (ndx < 0)
        {
          return ndx;
        }

      /* Is the name terminated in this 16-byte block */

      if (rm->rm_buffer[ndx + 15] == '\0')
        {
          /* Yes.. then this chunk is less than 16 */

          chunklen = strlen((char *)&rm->rm_buffer[ndx]);
          done     = true;
        }
      else
        {
          /* No.. then this chunk is 16 bytes in length */

          chunklen = 16;
        }

      /* Check if we would exceed the NAME_MAX */

      if (namelen + chunklen > NAME_MAX)
        {
          chunklen = NAME_MAX - namelen;
          done     = true;
        }

      /* Copy the chunk */

      memcpy(&pname[namelen], &rm->rm_buffer[ndx], chunklen);
      namelen += chunklen;
    }

  /* Terminate the name (NAME_MAX+1 chars total) and return success */

  pname[namelen] = '\0';

  return OK;
}
/****************************************************************************
 * Name: romfs_parsefilename
 *
 * Description:
 *   Return the filename from directory entry at this offset
 *
 ****************************************************************************/
romfs_parsefilename
Description:
Return the filename from directory entry at this offset
romfs_parsefilename Description : Return the filename from directory entry at this offset
int romfs_parsefilename(struct romfs_mountpt_s *rm, uint32_t offset,
                        char *pname)
{
  uint32_t ndx;
  uint16_t namelen;
  uint16_t chunklen;
  bool     done;
  offset += ROMFS_FHDR_NAME;
  for (namelen = 0, done = false; namelen < NAME_MAX && !done; )
    {
      ndx = romfs_devcacheread(rm, offset + namelen);
      if (ndx < 0)
        {
          return ndx;
        }
      if (rm->rm_buffer[ndx + 15] == '\0')
        {
          chunklen = strlen((char *)&rm->rm_buffer[ndx]);
          done     = true;
        }
      else
        {
          chunklen = 16;
        }
      if (namelen + chunklen > NAME_MAX)
        {
          chunklen = NAME_MAX - namelen;
          done     = true;
        }
      memcpy(&pname[namelen], &rm->rm_buffer[ndx], chunklen);
      namelen += chunklen;
    }
  pname[namelen] = '\0';
  return OK;
}
int romfs_parsefilename ( struct romfs_mountpt_s * rm , uint32_t offset , char * pname ) { uint32_t ndx ; uint16_t namelen ; uint16_t chunklen ; bool done ; offset += ROMFS_FHDR_NAME ; for ( namelen = 0 , done = false ; namelen < NAME_MAX && ! done ; ) { ndx = romfs_devcacheread ( rm , offset + namelen ) ; if ( ndx < 0 ) { return ndx ; } if ( rm -> rm_buffer [ ndx + 15 ] == ' \0 ' ) { chunklen = strlen ( ( char * ) & rm -> rm_buffer [ ndx ] ) ; done = true ; } else { chunklen = 16 ; } if ( namelen + chunklen > NAME_MAX ) { chunklen = NAME_MAX - namelen ; done = true ; } memcpy ( & pname [ namelen ] , & rm -> rm_buffer [ ndx ] , chunklen ) ; namelen += chunklen ; } pname [ namelen ] = ' \0 ' ; return OK ; }
Name: romfs_parsefilename
 Description:
   Return the filename from directory entry at this offset
Name : romfs_parsefilename Description : Return the filename from directory entry at this offset
/* Loop until the whole name is obtained or until NAME_MAX characters
   * of the name have been parsed.
   */ /* Read the sector into memory */ /* Is the name terminated in this 16-byte block */ /* Yes.. then this chunk is less than 16 */ /* No.. then this chunk is 16 bytes in length */ /* Check if we would exceed the NAME_MAX */ /* Copy the chunk */ /* Terminate the name (NAME_MAX+1 chars total) and return success */