コード例 #1
0
ファイル: Program.cs プロジェクト: valoni/FatFsFez
        static void FileExistsExample()
        {
            FILINFO fno = new FILINFO();

            res = Ff.Current.f_stat("/sub1/File2.txt", ref fno);
            switch (res)
            {
            case Ff.FRESULT.FR_OK:
                Debug.WriteLine($"Size: {fno.fsize}");
                Debug.WriteLine(String.Format("Timestamp: {0}/{1}/{2}, {3}:{4}",
                                              (fno.fdate >> 9) + 1980, fno.fdate >> 5 & 15, fno.fdate & 31,
                                              fno.ftime >> 11, fno.ftime >> 5 & 63));
                Debug.WriteLine(String.Format("Attributes: {0}{1}{2}{3}{4}",
                                              (fno.fattrib & AM_DIR) > 0 ? 'D' : '-',
                                              (fno.fattrib & AM_RDO) > 0 ? 'R' : '-',
                                              (fno.fattrib & AM_HID) > 0 ? 'H' : '-',
                                              (fno.fattrib & AM_SYS) > 0 ? 'S' : '-',
                                              (fno.fattrib & AM_ARC) > 0 ? 'A' : '-'));
                break;

            case Ff.FRESULT.FR_NO_FILE:
                Debug.WriteLine("File does not exist");
                break;

            default:
                Debug.WriteLine($"An error occured. {res.ToString()}");
                break;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: valoni/FatFsFez
        static void GetFreeSpaceExample()
        {
            uint fre_clust = 0;
            uint fre_sect, tot_sect;

            /* Get volume information and free clusters of drive 1 */
            res = Ff.Current.f_getfree("0:", ref fre_clust, ref fs);
            if (res != FRESULT.FR_OK)
            {
                Debug.WriteLine($"An error occured. {res.ToString()}");
                return;
            }
            ;

            /* Get total sectors and free sectors */
            tot_sect = (fs.n_fatent - 2) * fs.csize;
            fre_sect = fre_clust * fs.csize;

            /* Print the free space (assuming 512 bytes/sector) */
            Debug.WriteLine(String.Format("{0} KB total drive space\n{1} KB available", tot_sect / 2, fre_sect / 2));
        }