1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
\r
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
\r
5 <meta http-equiv="Content-Style-Type" content="text/css">
\r
6 <link rel="up" title="FatFs" href="../00index_e.html">
\r
7 <link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">
\r
8 <title>FatFs - f_getfree</title>
\r
15 <p>The f_getfree function gets number of the free clusters.</p>
\r
18 const char* <em>Path</em>, /* Root directory of the drive */
\r
19 DWORD* <em>Clusters</em>, /* Pointer to the variable to store number of free clusters */
\r
20 FATFS** <em>FileSystemObject</em> /* Pointer to pointer to file system object */
\r
29 <dd>Pinter to the null-terminated string that specifies the <a href="filename.html">root directory</a> of the logical drive. Always specify a null-string for Tiny-FatFs.</dd>
\r
31 <dd>Pointer to the DWORD variable to store number of free clusters.</dd>
\r
32 <dt>FileSystemObject</dt>
\r
33 <dd>Pointer to pointer that to store a pointer to the corresponding file system object.</dd>
\r
39 <h4>Return Values</h4>
\r
42 <dd>The function succeeded. The <tt><em>*Clusters</em></tt> has number of free clusters and <tt><em>*FileSystemObject</em></tt> points the file system object.</dd>
\r
43 <dt>FR_INVALID_DRIVE</dt>
\r
44 <dd>The drive number is invalid.</dd>
\r
45 <dt>FR_NOT_READY</dt>
\r
46 <dd>The disk drive cannot work due to no medium in the drive or any other reason.</dd>
\r
47 <dt>FR_DISK_ERR</dt>
\r
48 <dd>The function failed due to an error in the disk function.</dd>
\r
50 <dd>The function failed due to a wrong FAT structure or an internal error.</dd>
\r
51 <dt>FR_NOT_ENABLED</dt>
\r
52 <dd>The logical drive has no work area.</dd>
\r
53 <dt>FR_NO_FILESYSTEM</dt>
\r
54 <dd>There is no valid FAT partition on the disk.</dd>
\r
60 <h4>Descriptions</h4>
\r
61 <p>The f_getfree function gets number of free clusters on the drive. The member <tt>csize</tt> 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.</p>
\r
62 <p>This function is not supported in read-only configuration and minimization level of >= 1.</p>
\r
73 // Get free clusters
\r
74 res = f_getfree("", &clust, &fs);
\r
78 printf("%lu KB total disk space.\n"
\r
79 "%lu KB available on the disk.\n",
\r
80 (DWORD)(fs->max_clust - 2) * fs->csize / 2,
\r
81 clust * fs->csize / 2);
\r
88 <p><tt><a href="sfatfs.html">FATFS</a></tt></p>
\r
91 <p class="foot"><a href="../00index_e.html">Return</a></p>
\r