コード例 #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
        private static FRESULT Scan_Files(string path)
        {
            FRESULT res;
            FILINFO fno = new FILINFO();
            DIR     dir = new DIR();

            byte[] buff = new byte[256];
            buff = path.ToNullTerminatedByteArray();

            res = Ff.Current.f_opendir(ref dir, buff);                      /* Open the directory */
            if (res == FRESULT.FR_OK)
            {
                for (; ;)
                {
                    res = Ff.Current.f_readdir(ref dir, ref fno);           /* Read a directory item */
                    if (res != FRESULT.FR_OK || fno.fname[0] == 0)
                    {
                        break;                                              /* Break on error or end of dir */
                    }
                    if ((fno.fattrib & AM_DIR) > 0 && !((fno.fattrib & AM_SYS) > 0 || (fno.fattrib & AM_HID) > 0))
                    {
                        /* It is a directory */
                        var newpath = path + "/" + fno.fname.ToStringNullTerminationRemoved();
                        Debug.WriteLine($"Directory: {path}/{fno.fname.ToStringNullTerminationRemoved()}");
                        res = Scan_Files(newpath);                    /* Enter the directory */
                        if (res != FRESULT.FR_OK)
                        {
                            break;
                        }
                    }
                    else
                    {
                        /* It is a file. */
                        Debug.WriteLine($"File: {path}/{fno.fname.ToStringNullTerminationRemoved()}");
                    }
                }
                Ff.Current.f_closedir(ref dir);
            }

            return(res);
        }
コード例 #3
0
 internal static extern FRESULT f_stat(byte* path, FILINFO* fno);
コード例 #4
0
 internal static extern void FILINFOFree(FILINFO* filinfo);