]> cloudbase.mooo.com Git - z180-stamp.git/blame - fatfs/documents/doc/getfree.html
Import fatfs R0.13b
[z180-stamp.git] / fatfs / documents / doc / getfree.html
CommitLineData
53668523
L
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">\r
2<html lang="en">\r
3<head>\r
289f6a14 4<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
53668523
L
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="alternate" hreflang="ja" title="Japanese" href="../ja/getfree.html">\r
8<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default">\r
9<title>FatFs - f_getfree</title>\r
10</head>\r
11\r
12<body>\r
13\r
14<div class="para func">\r
15<h2>f_getfree</h2>\r
16<p>The f_getfree function gets number of the free clusters on the volume.</p>\r
17<pre>\r
18FRESULT f_getfree (\r
19 const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Logical drive number */</span>\r
20 DWORD* <span class="arg">nclst</span>, <span class="c">/* [OUT] Number of free clusters */</span>\r
289f6a14 21 FATFS** <span class="arg">fatfs</span> <span class="c">/* [OUT] Corresponding filesystem object */</span>\r
53668523
L
22);\r
23</pre>\r
24</div>\r
25\r
26<div class="para arg">\r
27<h4>Parameters</h4>\r
28<dl class="par">\r
29<dt>path</dt>\r
70702af1 30<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">logical drive</a>. A null-string means the default drive.</dd>\r
53668523
L
31<dt>nclst</dt>\r
32<dd>Pointer to the <tt>DWORD</tt> variable to store number of free clusters.</dd>\r
33<dt>fatfs</dt>\r
289f6a14 34<dd>Pointer to pointer that to store a pointer to the corresponding filesystem object.</dd>\r
53668523
L
35</dl>\r
36</div>\r
37\r
38\r
39<div class="para ret">\r
40<h4>Return Values</h4>\r
41<p>\r
42<a href="rc.html#ok">FR_OK</a>,\r
43<a href="rc.html#de">FR_DISK_ERR</a>,\r
44<a href="rc.html#ie">FR_INT_ERR</a>,\r
45<a href="rc.html#nr">FR_NOT_READY</a>,\r
46<a href="rc.html#id">FR_INVALID_DRIVE</a>,\r
47<a href="rc.html#ne">FR_NOT_ENABLED</a>,\r
48<a href="rc.html#ns">FR_NO_FILESYSTEM</a>,\r
49<a href="rc.html#tm">FR_TIMEOUT</a>\r
50</p>\r
51</div>\r
52\r
53\r
54<div class="para desc">\r
55<h4>Descriptions</h4>\r
289f6a14 56<p>The <tt>f_getfree</tt> function gets number of free clusters on the volume. The member <tt>csize</tt> in the filesystem object indicates number of sectors per cluster, so that the free space in unit of sector can be calcurated with this information. When FSINFO structure on the FAT32 volume is not in sync, this function can return an incorrect free cluster count. To avoid this problem, FatFs can be forced full FAT scan by <tt><a href="config.html#fs_nofsinfo">FF_FS_NOFSINFO</a></tt> option.</p>\r
53668523
L
57</div>\r
58\r
59\r
60<div class="para comp">\r
61<h4>QuickInfo</h4>\r
289f6a14 62<p>Available when <tt><a href="config.html#fs_readonly">FF_FS_READONLY</a> == 0</tt> and <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> == 0</tt>.</p>\r
53668523
L
63</div>\r
64\r
65\r
66<div class="para use">\r
67<h4>Example</h4>\r
68<pre>\r
69 FATFS *fs;\r
70 DWORD fre_clust, fre_sect, tot_sect;\r
71\r
72\r
73 <span class="c">/* Get volume information and free clusters of drive 1 */</span>\r
289f6a14 74 res = <em>f_getfree</em>("1:", &amp;fre_clust, &amp;fs);\r
53668523
L
75 if (res) die(res);\r
76\r
77 <span class="c">/* Get total sectors and free sectors */</span>\r
78 tot_sect = (fs->n_fatent - 2) * fs->csize;\r
79 fre_sect = fre_clust * fs->csize;\r
80\r
81 <span class="c">/* Print the free space (assuming 512 bytes/sector) */</span>\r
289f6a14 82 printf("%10lu KiB total drive space.\n%10lu KiB available.\n", tot_sect / 2, fre_sect / 2);\r
53668523
L
83</pre>\r
84</div>\r
85\r
86\r
87<div class="para ref">\r
88<h4>See Also</h4>\r
89<p><tt><a href="sfatfs.html">FATFS</a></tt></p>\r
90</div>\r
91\r
92<p class="foot"><a href="../00index_e.html">Return</a></p>\r
93</body>\r
94</html>\r