## f_getfree

The f_getfree function gets number of the free clusters.

    FRESULT f_getfree (
      const char* Path,         /* Root directory of the drive */
      DWORD* Clusters,          /* Pointer to the variable to store number of free clusters */
      FATFS** FileSystemObject  /* Pointer to pointer to file system object */
    );

#### Parameters

Path
  Pinter to the null-terminated string that specifies the root directory of the logical drive. Always specify a null-string for Tiny-FatFs.
Clusters
  Pointer to the DWORD variable to store number of free clusters.
FileSystemObject
  Pointer to pointer that to store a pointer to the corresponding file system object.

#### Return Values

FR_OK (0)
  The function succeeded. The `*Clusters` has number of free clusters and `*FileSystemObject` points the file system object.
FR_INVALID_DRIVE
  The drive number is invalid.
FR_NOT_READY
  The disk drive cannot work due to no medium in the drive or any other reason.
FR_DISK_ERR
  The function failed due to an error in the disk function.
FR_INT_ERR
  The function failed due to a wrong FAT structure or an internal error.
FR_NOT_ENABLED
  The logical drive has no work area.
FR_NO_FILESYSTEM
  There is no valid FAT partition on the disk.

#### Descriptions

The f_getfree function gets number of free clusters on the drive. The member `csize` in the file system object is refreting number of sectors per cluster, so that the free space in unit of sector can be calcurated with this. When FSInfo structure on FAT32 volume is not in sync, this function can return an incorrect free cluster count.

This function is not supported in read-only configuration and minimization level of >= 1.

#### Example

        FATFS *fs;
        DWORD clust;

        // Get free clusters
        res = f_getfree("", &clust, &fs);
        if (res) die(res);

        // Get free space
        printf("%lu KB total disk space.\n"
               "%lu KB available on the disk.\n",
               (DWORD)(fs->max_clust - 2) * fs->csize / 2,
               clust * fs->csize / 2);

#### References

`FATFS`

Return