##### Shinobi Library - Memory Card Function

# buDefragDisk

Optimizes a memory card

### FORMAT

`

  Sint32 buDefragDisk( drive, *work )
  Sint32 drive
  void *work

`

### PARAMETER

  `drive` | Extension socket number
  `*work` | Work buffer (512 bytes)

### RETURN

  BUD_ERR_OK | Processing request was received |
  BUD_ERR_BUSY | Busy - request could not be accepted |

### DESCRIPTION

  Optimizes the memory of a memory card in order to permit allocation of an area where an executable file can be written.

  The following values can be designated for "drive" that specifies extension sockets.

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

  Set aside 512 bytes as workspace for the argument `*work`.

  Use this function when you have enough free space to save an executable file, but cannot reserve a block of free space large enough to save the file.

### EXAMPLE

        Sint32 ret;
        Uint32 DefragWork[512 / sizeof(Uint32)];
        ret = buDefragDisk(BUD_DRIVE_A1, DefragWork);
        if (ret != BUD_ERR_OK)
      	return NG;
        while (buStat(BUD_DRIVE_A1) == BUD_STAT_BUSY) {
        }
        if (buGetLastError(BUD_DRIVE_A1) != BUD_ERR_OK)
      	return NG;
        return OK;

### NOTE

  Do not change the size of the work buffer (as indicated by "work") while optimization processing is in progress. In addition, "work" must specify a 512-byte buffer that begins on a four-byte boundary.

  If the memory card is removed while this function is being executed, in most cases all data will be lost. Under no circumstances insert or remove a memory card while this function is being executed for an application program.

buDefragDisk

COPYRIGHT © SEGA ENTERPRISES, LTD., 1998,1999