##### Shinobi Library - Memory Card Function

# buFindNextFile

Gets the name of the next file

### FORMAT

`

  Sint32 buFindNextFile( drive, *fname )
  Sint32 drive
  char *fname

`

### PARAMETER

  `drive` | Extended socket number
  `*fname` | Address that gets file name

### RETURN

  BUD_ERR_OK | Normal end |
  BUD_ERR_FILE_NOT_FOUND | File not found |
  BUD_ERR_UNFORMAT | Disk is not formatted |
  BUD_ERR_NO_DISK | No memory card found |
  BUD_ERR_BUSY | A TYPE_B function is being processed |

### DESCRIPTION

  Gets the name of the next file previously acquired from a memory card inserted in a specified extended socket.

  The following values can be designated for the argument `drive` that specifies extended sockets.

  BUD_DRIVE_A1 | Extended socket 1 on board A
  BUD_DRIVE_A2 | Extended socket 2 on board A
  BUD_DRIVE_B1 | Extended socket 1 on board B
  BUD_DRIVE_B2 | Extended socket 2 on board B
  BUD_DRIVE_C1 | Extended socket 1 on board C
  BUD_DRIVE_C2 | Extended socket 2 on board C
  BUD_DRIVE_D1 | Extended socket 1 on board D
  BUD_DRIVE_D2 | Extended socket 2 on board D

  Normally, this function is used in combination with `buFindFistFile()` function to get the names of all files in a drive.

### EXAMPLE

        Sint32 ret, files, blocks, totel;
        char fname[16];
        BUS_FILEINFO info;
        files = blocks = total = 0;
        /* Get name of first file */
        ret = buFindFirstFile(drive, fname);
        if (ret &lt; 0) {
          if (ret == BUD_ERR_FILE_NOT_FOUND) goto end;
          else goto err;
        }
        if (buGetFileInfo(drive, fname, &info) &lt; 0) goto err;
          blocks = info.blocks;
          total += blocks;
          files++;
          do {
            printf("%12s %10d bytes(%3d blocks)\n", files, blocks * 512, blocks);
            /* Get name of second and subsequent files */
            ret = buFindNextFile(drive, fname);
            if (ret &lt; 0) {
              if (ret == BUD_ERR_FILE_NOT_FOUND) goto end;
              else goto err;
            }
            if (buGetFileInfo(drive, fname, &info) &lt; 0) goto err;
            blocks = info.blocks;
            total += blocks;
            files++;
          } while (files &lt; FILE_MAX);
        end:
          return OK;
        err:
          return NG;

### NOTE

  A minimum of 13 bytes is required for the area where the file name is to be stored. If the file does not exist, then fname[0] = '\0' results.

buFindNextFile

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999