Add FatFs module by ChaN.
[bertos.git] / bertos / fs / fatfs / doc / en / getfree.html
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
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
9 </head>\r
10 \r
11 <body>\r
12 \r
13 <div class="para">\r
14 <h2>f_getfree</h2>\r
15 <p>The f_getfree function gets number of the free clusters.</p>\r
16 <pre>\r
17 FRESULT f_getfree (\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
21 );\r
22 </pre>\r
23 </div>\r
24 \r
25 <div class="para">\r
26 <h4>Parameters</h4>\r
27 <dl class="par">\r
28 <dt>Path</dt>\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
30 <dt>Clusters</dt>\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
34 </dl>\r
35 </div>\r
36 \r
37 \r
38 <div class="para">\r
39 <h4>Return Values</h4>\r
40 <dl class="ret">\r
41 <dt>FR_OK (0)</dt>\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
49 <dt>FR_INT_ERR</dt>\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
55 </dl>\r
56 </div>\r
57 \r
58 \r
59 <div class="para">\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 &gt;= 1.</p>\r
63 </div>\r
64 \r
65 \r
66 <div class="para">\r
67 <h4>Example</h4>\r
68 <pre>\r
69     FATFS *fs;\r
70     DWORD clust;\r
71 \r
72 \r
73     // Get free clusters\r
74     res = f_getfree("", &amp;clust, &amp;fs);\r
75     if (res) die(res);\r
76 \r
77     // Get free space\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
82 </pre>\r
83 </div>\r
84 \r
85 \r
86 <div class="para">\r
87 <h4>References</h4>\r
88 <p><tt><a href="sfatfs.html">FATFS</a></tt></p>\r
89 </div>\r
90 \r
91 <p class="foot"><a href="../00index_e.html">Return</a></p>\r
92 </body>\r
93 </html>\r