1e6865dcdSopenharmony_ci<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 2e6865dcdSopenharmony_ci<html lang="en"> 3e6865dcdSopenharmony_ci<head> 4e6865dcdSopenharmony_ci<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 5e6865dcdSopenharmony_ci<meta http-equiv="Content-Style-Type" content="text/css"> 6e6865dcdSopenharmony_ci<link rel="up" title="FatFs" href="../00index_e.html"> 7e6865dcdSopenharmony_ci<link rel="alternate" hreflang="ja" title="Japanese" href="../ja/stat.html"> 8e6865dcdSopenharmony_ci<link rel="stylesheet" href="../css_e.css" type="text/css" media="screen" title="ELM Default"> 9e6865dcdSopenharmony_ci<title>FatFs - f_stat</title> 10e6865dcdSopenharmony_ci</head> 11e6865dcdSopenharmony_ci 12e6865dcdSopenharmony_ci<body> 13e6865dcdSopenharmony_ci 14e6865dcdSopenharmony_ci<div class="para func"> 15e6865dcdSopenharmony_ci<h2>f_stat</h2> 16e6865dcdSopenharmony_ci<p>The f_stat function checks the existence of a file or sub-directory.</p> 17e6865dcdSopenharmony_ci<pre> 18e6865dcdSopenharmony_ciFRESULT f_stat ( 19e6865dcdSopenharmony_ci const TCHAR* <span class="arg">path</span>, <span class="c">/* [IN] Object name */</span> 20e6865dcdSopenharmony_ci FILINFO* <span class="arg">fno</span> <span class="c">/* [OUT] FILINFO structure */</span> 21e6865dcdSopenharmony_ci); 22e6865dcdSopenharmony_ci</pre> 23e6865dcdSopenharmony_ci</div> 24e6865dcdSopenharmony_ci 25e6865dcdSopenharmony_ci<div class="para arg"> 26e6865dcdSopenharmony_ci<h4>Parameters</h4> 27e6865dcdSopenharmony_ci<dl class="par"> 28e6865dcdSopenharmony_ci<dt>path</dt> 29e6865dcdSopenharmony_ci<dd>Pointer to the null-terminated string that specifies the <a href="filename.html">object</a> to get its information. The object must not be the root direcotry.</dd> 30e6865dcdSopenharmony_ci<dt>fno</dt> 31e6865dcdSopenharmony_ci<dd>Pointer to the blank <tt>FILINFO</tt> structure to store the information of the object. Set null pointer if this information is not needed.</dd> 32e6865dcdSopenharmony_ci</dl> 33e6865dcdSopenharmony_ci</div> 34e6865dcdSopenharmony_ci 35e6865dcdSopenharmony_ci 36e6865dcdSopenharmony_ci<div class="para ret"> 37e6865dcdSopenharmony_ci<h4>Return Values</h4> 38e6865dcdSopenharmony_ci<p> 39e6865dcdSopenharmony_ci<a href="rc.html#ok">FR_OK</a>, 40e6865dcdSopenharmony_ci<a href="rc.html#de">FR_DISK_ERR</a>, 41e6865dcdSopenharmony_ci<a href="rc.html#ie">FR_INT_ERR</a>, 42e6865dcdSopenharmony_ci<a href="rc.html#nr">FR_NOT_READY</a>, 43e6865dcdSopenharmony_ci<a href="rc.html#ok">FR_NO_FILE</a>, 44e6865dcdSopenharmony_ci<a href="rc.html#np">FR_NO_PATH</a>, 45e6865dcdSopenharmony_ci<a href="rc.html#in">FR_INVALID_NAME</a>, 46e6865dcdSopenharmony_ci<a href="rc.html#id">FR_INVALID_DRIVE</a>, 47e6865dcdSopenharmony_ci<a href="rc.html#ne">FR_NOT_ENABLED</a>, 48e6865dcdSopenharmony_ci<a href="rc.html#ns">FR_NO_FILESYSTEM</a>, 49e6865dcdSopenharmony_ci<a href="rc.html#tm">FR_TIMEOUT</a>, 50e6865dcdSopenharmony_ci<a href="rc.html#nc">FR_NOT_ENOUGH_CORE</a> 51e6865dcdSopenharmony_ci</p> 52e6865dcdSopenharmony_ci</div> 53e6865dcdSopenharmony_ci 54e6865dcdSopenharmony_ci 55e6865dcdSopenharmony_ci<div class="para desc"> 56e6865dcdSopenharmony_ci<h4>Description</h4> 57e6865dcdSopenharmony_ci<p>The <tt>f_stat</tt> function checks the existence of a file or sub-directory in the directory. If it is not exist, the function returns with <tt>FR_NO_FILE</tt>. If it is exist, the function returns with <tt>FR_OK</tt> and the informations about the object, size, timestamp and attribute, is stored to the file information structure. For details of the file information, refer to the <tt>FILINFO</tt> structure and <a href="readdir.html"><tt>f_readdir</tt></a> function.</p> 58e6865dcdSopenharmony_ci<p>Note that the file information comes from the meta data in the directory. If the file has been opend and modified, the file will need to be synched or closed in order to obtain the latest file information.</p> 59e6865dcdSopenharmony_ci</div> 60e6865dcdSopenharmony_ci 61e6865dcdSopenharmony_ci 62e6865dcdSopenharmony_ci<div class="para comp"> 63e6865dcdSopenharmony_ci<h4>QuickInfo</h4> 64e6865dcdSopenharmony_ci<p>Available when <tt><a href="config.html#fs_minimize">FF_FS_MINIMIZE</a> == 0</tt>.</p> 65e6865dcdSopenharmony_ci</div> 66e6865dcdSopenharmony_ci 67e6865dcdSopenharmony_ci 68e6865dcdSopenharmony_ci<div class="para use"> 69e6865dcdSopenharmony_ci<h4>Example</h4> 70e6865dcdSopenharmony_ci<pre> 71e6865dcdSopenharmony_ci FRESULT fr; 72e6865dcdSopenharmony_ci FILINFO fno; 73e6865dcdSopenharmony_ci const char *fname = "file.txt"; 74e6865dcdSopenharmony_ci 75e6865dcdSopenharmony_ci 76e6865dcdSopenharmony_ci printf("Test for \"%s\"...\n", fname); 77e6865dcdSopenharmony_ci 78e6865dcdSopenharmony_ci fr = <em>f_stat</em>(fname, &fno); 79e6865dcdSopenharmony_ci switch (fr) { 80e6865dcdSopenharmony_ci 81e6865dcdSopenharmony_ci case FR_OK: 82e6865dcdSopenharmony_ci printf("Size: %lu\n", fno.fsize); 83e6865dcdSopenharmony_ci printf("Timestamp: %u-%02u-%02u, %02u:%02u\n", 84e6865dcdSopenharmony_ci (fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31, 85e6865dcdSopenharmony_ci fno.ftime >> 11, fno.ftime >> 5 & 63); 86e6865dcdSopenharmony_ci printf("Attributes: %c%c%c%c%c\n", 87e6865dcdSopenharmony_ci (fno.fattrib & AM_DIR) ? 'D' : '-', 88e6865dcdSopenharmony_ci (fno.fattrib & AM_RDO) ? 'R' : '-', 89e6865dcdSopenharmony_ci (fno.fattrib & AM_HID) ? 'H' : '-', 90e6865dcdSopenharmony_ci (fno.fattrib & AM_SYS) ? 'S' : '-', 91e6865dcdSopenharmony_ci (fno.fattrib & AM_ARC) ? 'A' : '-'); 92e6865dcdSopenharmony_ci break; 93e6865dcdSopenharmony_ci 94e6865dcdSopenharmony_ci case FR_NO_FILE: 95e6865dcdSopenharmony_ci printf("\"%s\" is not exist.\n", fname); 96e6865dcdSopenharmony_ci break; 97e6865dcdSopenharmony_ci 98e6865dcdSopenharmony_ci default: 99e6865dcdSopenharmony_ci printf("An error occured. (%d)\n", fr); 100e6865dcdSopenharmony_ci } 101e6865dcdSopenharmony_ci</pre> 102e6865dcdSopenharmony_ci</div> 103e6865dcdSopenharmony_ci 104e6865dcdSopenharmony_ci 105e6865dcdSopenharmony_ci<div class="para ref"> 106e6865dcdSopenharmony_ci<h4>References</h4> 107e6865dcdSopenharmony_ci<p><tt><a href="opendir.html">f_opendir</a>, <a href="readdir.html">f_readdir</a>, <a href="sfileinfo.html">FILINFO</a></tt></p> 108e6865dcdSopenharmony_ci</div> 109e6865dcdSopenharmony_ci 110e6865dcdSopenharmony_ci<p class="foot"><a href="../00index_e.html">Return</a></p> 111e6865dcdSopenharmony_ci</body> 112e6865dcdSopenharmony_ci</html> 113