/** * @brief Add entire folder to playlist. * @param Foldername: pointer to folder name. * @retval None */ static void _AddEntireFolder(char *Foldername) { FRESULT res; FILINFO fno; DIR dir; char *fn; char tmp[FILEMGR_FULL_PATH_SIZE]; WM_HWIN hItem; #if _USE_LFN static char lfn[_MAX_LFN]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif res = f_opendir(&dir, Foldername); if (res == FR_OK) { while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif if (pVideoList->ptr < FILEMGR_LIST_DEPDTH) { if ((fno.fattrib & AM_DIR) == 0) { if(((strstr(fn, ".emf")) || (strstr(fn, ".EMF"))) && (VIDEOPLAYER_hWin != 0)) { strcpy(tmp, Foldername); strcat(tmp, "/"); strcat(tmp, fn); strncpy((char *)pVideoList->file[pVideoList->ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE); hItem = WM_GetDialogItem(VIDEOPLAYER_hWin, ID_VIDEO_LIST); LISTVIEW_AddRow(hItem, NULL); FILEMGR_GetFileOnly (tmp, fn); LISTVIEW_SetItemText(hItem, 0, pVideoList->ptr, fn); pVideoList->ptr++; } } } } } f_closedir(&dir); }
FRESULT scan_files ( char* path /* Start node to be scanned (***also used as work area***) */ ) { FRESULT res; DIR dir; UINT i; static FILINFO fno; res = f_opendir(&dir, path); /* Open the directory */ if (res == FR_OK) { for (;;) { res = f_readdir(&dir, &fno); /* Read a directory item */ if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ if (fno.fattrib & AM_DIR) { /* It is a directory */ sprintf(&path[i = strlen(path)], "/%s", fno.fname); res = scan_files(path); /* Enter the directory */ if (res != FR_OK) break; path[i] = 0; } else { /* It is a file. */ send_uart(path); send_uart("/"); send_uart(fno.fname); send_uart("\n"); //printf("%s/%s\n", path, fno.fname); } } f_closedir(&dir); } return res; }
static struct dirent* fat_readdir(struct device_d *dev, DIR *dir) { FF_DIR *ff_dir = dir->priv; FILINFO finfo; int ret; #ifdef CONFIG_FS_FAT_LFN char name[PATH_MAX]; #endif memset(&finfo, 0, sizeof(finfo)); #ifdef CONFIG_FS_FAT_LFN finfo.lfname = name; finfo.lfsize = PATH_MAX; #endif ret = f_readdir(ff_dir, &finfo); if (ret) return NULL; if (finfo.fname[0] == '\0') return NULL; #ifdef CONFIG_FS_FAT_LFN if (*finfo.lfname) strcpy(dir->d.d_name, finfo.lfname); else #endif strcpy(dir->d.d_name, finfo.fname); return &dir->d; }
static bool get_name(char dest[13], int page, int index) { DIR dir; FILINFO file; f_opendir(&dir, "/"); if (!seek_dir(page, &dir, &file)) { debugf("Directory seek failed"); return false; } for (int i = 0; i <= index; ) { if (f_readdir(&dir, &file) != 0 || file.fname[0] == 0) return false; if (is_a_script(file.fname)) i++; } printf("Selected %s\n", file.fname); memcpy(dest, file.fname, 13); return true; }
static FRESULT scan_files ( char* path /* Pointer to the path name working buffer */ ) { DIR dirs; FRESULT res; BYTE i; char* fn; if ((res = f_opendir(&dirs, path)) == FR_OK) { i = strlen(path); while (((res = f_readdir(&dirs, &Finfo)) == FR_OK) && Finfo.fname[0]) { if (_FS_RPATH && Finfo.fname[0] == '.') continue; #if _USE_LFN fn = *Finfo.lfname ? Finfo.lfname : Finfo.fname; #else fn = Finfo.fname; #endif if (Finfo.fattrib & AM_DIR) { AccDirs++; *(path+i) = '/'; strcpy(path+i+1, fn); res = scan_files(path); *(path+i) = '\0'; if (res != FR_OK) break; } else { /*xprintf("%s/%s\n", path, fn);*/ AccFiles++; AccSize += Finfo.fsize; } } } return res; }
static FRESULT scan_files(BaseChannel *chp, char *path) { FRESULT res; FILINFO fno; DIR dir; int i; char *fn; res = f_opendir(&dir, path); if (res == FR_OK) { i = strlen(path); for (;;) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; if (fno.fname[0] == '.') continue; fn = fno.fname; if (fno.fattrib & AM_DIR) { path[i++] = '/'; strcpy(&path[i], fn); res = scan_files(chp, path); if (res != FR_OK) break; path[i] = 0; } else { chprintf(chp, "%s/%s\r\n", path, fn); } } } return res; }
static struct dirent *fatfs_readdir(mount_point_t *point, file_t *file) { privinfo_t *priv = file->ctx; FRESULT res; if (priv != NULL) { FILINFO info; priv->entry.d_name[0] = '\0'; #if _USE_LFN info.lfname = priv->entry.d_name; info.lfsize = sizeof(priv->entry.d_name); #endif res = f_readdir(&priv->dir, &info); if (res == FR_OK && info.fname[0] != '\0') { #if _USE_LFN if (info.lfname[0] == '\0') { strlcpy(priv->entry.d_name, info.fname, sizeof(priv->entry.d_name)); } #else strlcpy(priv->entry.d_name, info.fname, sizeof(priv->entry.d_name)); #endif priv->entry.d_ino = 0; return &priv->entry; } else { fatfs_result_to_errno(res); return NULL; } } else { seterrno(EINVAL); return NULL; } }
extern struct dirent *readdir(FATFS_DIR* dp) { if (!dp) return NULL; FRESULT res; FILINFO info; #if _USE_LFN info.lfname = dp->d_dirent.d_name; info.lfsize = sizeof(dp->d_dirent.d_name); #endif res = f_readdir(&dp->dir, &info); if (res != FR_OK || info.fname[0] == 0) { return NULL; } #if _USE_LFN if (*(info.lfname) == 0) { dp->d_dirent.d_namlen = 13; /* 8.3 format */ memcpy(dp->d_dirent.d_name, info.fname, 13); } #else dp->d_dirent.d_namlen = 13; /* 8.3 format */ memcpy(dp->d_dirent.d_name, info.fname, 13); #endif return &(dp->d_dirent); }
//得到path路径下,目标文件的总个数 //path:路径 //返回值:总有效文件数 u16 MP3_getMp3FileNum(u8 *path) { u8 res; u16 rval=0; DIR tdir; //临时目录 FILINFO tfileinfo; //临时文件信息 u8 *fn; res=f_opendir(&tdir,(const TCHAR*)path); //打开目录 tfileinfo.lfsize=_MAX_LFN*2+1; //长文件名最大长度 tfileinfo.lfname=malloc(tfileinfo.lfsize);//为长文件缓存区分配内存 if(res==FR_OK&&tfileinfo.lfname!=NULL) { while(1)//查询总的有效文件数 { res=f_readdir(&tdir,&tfileinfo); //读取目录下的一个文件 if(res != FR_OK || tfileinfo.fname[0] == 0) break; //错误了/到末尾了,退出 fn = (u8*)(*tfileinfo.lfname ? tfileinfo.lfname : tfileinfo.fname); printf("歌曲名字: %s\r\n", fn); //显示歌曲名字 res=f_typetell(fn); if((res&0XF0)==0X40)//取高四位,看看是不是音乐文件 { rval++;//有效文件数增加1 } } } free(tfileinfo.lfname); //printf("目录%s下总共有%d首歌曲.\r\n",path, rval); //显示总歌曲数 return rval; }
char *get_ckfilename(void) { FRESULT res; char *fn = NULL; for(;;) { res = f_readdir(&fatfs_dir, &fatfs_fno); if (res != FR_OK || fatfs_fno.fname[0] == 0) { // エラーまたはもうファイルがない fn = NULL; break; } if (fatfs_fno.fname[0] == '.') continue; // ドットエントリの場合はリトライ if (fatfs_fno.fattrib & AM_DIR) continue; // ディレクトリの場合もリトライ fn = *fatfs_fno.lfname ? fatfs_fno.lfname : fatfs_fno.fname; if ( !check_extck(fn) ) continue; // .ckファイルでなければリトライ break; } // if (fn == NULL) f_closedir(&fatfs_dir); return fn; }
//得到path路径下,目标文件的总个数 //path:路径 //返回值:总有效文件数 u16 audio_get_tnum(u8 *path) { u8 res; u16 rval=0; DIR tdir; //临时目录 FILINFO tfileinfo; //临时文件信息 u8 *fn; res=f_opendir(&tdir,(const TCHAR*)path); //打开目录 tfileinfo.lfsize=_MAX_LFN*2+1; //长文件名最大长度 tfileinfo.lfname=mymalloc(SRAMIN,tfileinfo.lfsize); //为长文件缓存区分配内存 if(res==FR_OK&&tfileinfo.lfname!=NULL) { while(1)//查询总的有效文件数 { res=f_readdir(&tdir,&tfileinfo); //读取目录下的一个文件 if(res!=FR_OK||tfileinfo.fname[0]==0)break; //错误了/到末尾了,退出 fn=(u8*)(*tfileinfo.lfname?tfileinfo.lfname:tfileinfo.fname); res=f_typetell(fn); if((res&0XF0)==0X40)//取高四位,看看是不是音乐文件 { rval++;//有效文件数增加1 } } } myfree(SRAMIN,tfileinfo.lfname); return rval; }
// fill menu_dir file-list // skipping "start" number of entries while scanning FAT void menu_builtdir(uint16_t start) { FRESULT res; res = f_opendir(&dir, "."); if (res) { uart_puts_P("f_opendir failed\r\n"); return; } for(;;) { res = f_readdir(&dir, &Finfo); if ((res != FR_OK) || !Finfo.fname[0]) break; fn = *Finfo.lfname ? Finfo.lfname : Finfo.fname; if (fn[0] == '.') continue; if(Finfo.fattrib & AM_DIR) uart_puts_P("/"); if(strstr(strlwr(fn), ".mp3")) // FIXME: memory leak? { } } }
bool folder_enum(const char* folder_path,unsigned long enum_index,char* out_buffer,unsigned long* out_buffer_length) { unsigned long find_subfolder_index=0; DIR directory; FILINFO file_data; file_data.lfname=malloc(MAX_FOLDER_NAME_LENGTH); if (NULL==file_data.lfname) return false; file_data.lfsize=MAX_FOLDER_NAME_LENGTH; if (FR_OK==f_opendir(&directory,folder_path)) { while (FR_OK==f_readdir(&directory,&file_data)) { if (file_data.fname[0]) { if (enum_index==find_subfolder_index) { memcpy(out_buffer,file_data.lfname,file_data.lfsize); *out_buffer_length=file_data.lfsize; return true; } else if (enum_index>find_subfolder_index) return false; else ++find_subfolder_index; } else return false; } } return false; }
u8 mf_scan_files(u8 * path) { FRESULT res; char *fn; /* This function is assuming non-Unicode cfg. */ #if _USE_LFN fileinfo.lfsize = _MAX_LFN * 2 + 1; fileinfo.lfname = mymalloc(SRAMIN,fileinfo.lfsize); #endif res = f_opendir(&dir,(const TCHAR*)path); if (res == FR_OK) { printf("\r\n"); while(1) { res = f_readdir(&dir, &fileinfo); if (res != FR_OK || fileinfo.fname[0] == 0) break; //if (fileinfo.fname[0] == '.') continue; #if _USE_LFN fn = *fileinfo.lfname ? fileinfo.lfname : fileinfo.fname; #else fn = fileinfo.fname; #endif /* It is a file. */ printf("%s/", path); printf("%s\r\n", fn); } } myfree(SRAMIN,fileinfo.lfname); return res; }
int cliLs(const char ** argv) { FILINFO fno; DIR dir; char *fn; /* This function is assuming non-Unicode cfg. */ #if _USE_LFN TCHAR lfn[_MAX_LFN + 1]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif FRESULT res = f_opendir(&dir, argv[1]); /* Open the directory */ if (res == FR_OK) { for (;;) { res = f_readdir(&dir, &fno); /* Read a directory item */ if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */ #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif serialPrint(fn); } } else { serialPrint("%s: Invalid directory \"%s\"", argv[0], argv[1]); } return 0; }
void OutPutFile(void) { FRESULT res; FILINFO finfo; DIR dirs; int i; char *fn; char path[50]={""}; char name[]={"WVO.TXT"}; printf("\n file system starting! \n"); disk_initialize(0); f_mount(0, &fs); /* res = f_opendir(&dir, path); if (res == FR_OK) { i = strlen(path); for (;;) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; fn = fno.fname; if (fno.fattrib & AM_DIR) { sprintf(&path[i], "/%s", fn); res = scan_files(path); if (res != FR_OK) break; path[i] = 0; } else { printf("%s/%s\n\n", path, fn); } } } */ if (f_opendir(&dirs, path) == FR_OK) { while (f_readdir(&dirs, &finfo) == FR_OK) { if (finfo.fattrib & AM_ARC) { if(!finfo.fname[0]) break; printf("\n file name is:\n %s\n",finfo.fname); res = f_open(&fsrc, finfo.fname, FA_OPEN_EXISTING | FA_READ); res = f_read(&fsrc, &buffer, 50, &br); printf("\n file contex is:\n %s\n",buffer); f_close(&fsrc); } } } while(1); }
/** * @brief Return the first file present inside a direcory with FileExt * @param DirName: Directory name * @param Action : Opendir, previous or next files, Closedir * @param FileExt: extension filter if NULL not filter * @retval STORAGE_RETURN */ STORAGE_RETURN kStorage_GetDirectoryFiles(const uint8_t *DirName, uint8_t action, uint8_t *FileName, uint8_t *FileExt) { static DIR MyDirectory; static uint16_t count = 0; uint16_t prev = 0; FILINFO MyFileInfo; uint8_t ext[4]; switch(action) { case KSTORAGE_FINDPREV : /* Recherche du prev */ if(count == 1 ) return KSTORAGE_FIND_NOPREV; prev = count-1; count = 0; f_closedir(&MyDirectory); case KSTORAGE_FINDFIRST : if(f_opendir(&MyDirectory, (char const *)DirName) != FR_OK) { return KSTORAGE_FIND_DIRDOESNTEXSIT; } case KSTORAGE_FINDNEXT : do { /* Get the first file */ if((f_readdir(&MyDirectory, &MyFileInfo) != FR_OK) || (MyFileInfo.fname[0] == '\0')) { return KSTORAGE_FIND_NOFILE; } /* check the file extension */ kStorage_GetExt(MyFileInfo.fname, (char *)ext); /* part to handle previous */ if((prev != 0 ) && ((FileExt == NULL) || (strcmp((char const*)ext, (char const*)FileExt) == 0))) { count++; if(count != prev) { /* go to next picture */ ext[0] = '\0'; } else { count--; } } } while((FileExt != NULL) && strcmp((char const*)ext, (char const*)FileExt) != 0); count++; strcpy((char *)FileName,MyFileInfo.fname); break; case KSTORAGE_FINDCLOSE : f_closedir(&MyDirectory); break; } return KSTORAGE_NOERROR; }
void DirectoryIterator::rewind() { if (!m_dir.same(false)) { f_rewinddir(m_dir); m_dirEntry = f_readdir(m_dir); m_index = 0; m_fileName = getPathName(); } }
FRESULT scan_files(char* path) { DIR dirs; FRESULT res; int i; char *fn; if ((res = f_opendir(&dirs, path)) == FR_OK) { i = strlen(path); //CDCprintln("scan path: %s", path); while (((res = f_readdir(&dirs, &Finfo)) == FR_OK) && Finfo.fname[0]) { if (_FS_RPATH && Finfo.fname[0] == '.') continue; #if _USE_LFN fn = *Finfo.lfname ? Finfo.lfname : Finfo.fname; #else fn = Finfo.fname; #endif if (Finfo.fattrib & AM_DIR) { AccDirs++; //CDCprintln("next path: %s", fn); /* FIXME: doubles code size! char * s = malloc(snprintf(NULL, 0, "%s/%s", path, fn) + 1); sprintf(s, "%s/%s", path, fn); */ res = scan_files(s); /* FIXME: seg fault path[i] = '/'; CDCprintln("#1: %s", path); mem_cpy(&path[i + 1], fn); CDCprintln("#2: %s", path); res = scan_files(path); path[i] = 0; CDCprintln("#3: %s", path); */ if (res != FR_OK) break; } else { #if 0 CDCprintln("%s/%s\n", path, fn); #endif AccFiles++; AccSize += Finfo.fsize; } } } return res; }
void skybean_file_list() { uint8_t len = skybean_stream.Read(); char path[128]; for (uint8_t i = 0; i < len; i++) path[i] = skybean_stream.Read(); path[len] = 0; uint16_t total_length; uint16_t file_count = skybean_file_readdir(path, &total_length); total_length += 2; skybean_startpacket(total_length, SKYBEAN_FILE, 0x81); skybean_stream.Write(2, (uint8_t *)&file_count); DIR f_dir; if (f_opendir(&f_dir, path) == FR_OK) { FILINFO f_info; while(1) { uint8_t res = f_readdir(&f_dir, &f_info); if (res == FR_OK) { if (f_info.fname[0] != '\0') { if (f_info.fname[0] == 0xFF) continue; if (f_info.fattrib & AM_DIR) { skybean_stream.Write(0xFF); skybean_stream.Write(0xFF); skybean_stream.Write(0xFF); skybean_stream.Write(0xFF); } else skybean_stream.Write(4, (uint8_t *)&f_info.fsize); uint8_t len = strlen(f_info.fname); skybean_stream.Write(len); skybean_stream.Write(len, (uint8_t *)f_info.fname); } else break; } else break; } } }
DirectoryIterator::DirectoryIterator(CStrRef path) : m_path(path), m_index(0) { Variant dir = f_opendir(m_path); if (!dir.same(false)) { m_dir = dir; m_dirEntry = f_readdir(m_dir); m_fileName = getPathName(); } }
int sys_list(const char *pathname) { DIR dir; FILINFO fno; int res; printk("ls folder = %s\n", pathname); f_opendir(&dir, pathname); res = f_readdir(&dir, &fno); while (strlen(fno.fname)) { printk("[%s] ret = %d, filename = %s, fsize = %d, date = %d, time = %d\n", __func__, res, fno.fname, fno.fsize, fno.fdate, fno.ftime); res = f_readdir(&dir, &fno); } f_closedir(&dir); return 0; }
/** * @brief Copy disk content in the explorer list * @param path: pointer to root path * @param list: pointer to file list * @retval Status */ uint8_t FILEMGR_ParseDisks (char *path, FILELIST_FileTypeDef *list) { FRESULT res; FILINFO fno; DIR dir; char *fn; #if _USE_LFN static char lfn[_MAX_LFN]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif res = f_opendir(&dir, path); list->ptr = 0; if (res == FR_OK) { while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif if (list->ptr < FILEMGR_LIST_DEPDTH) { if ((fno.fattrib & AM_DIR) == AM_DIR) { strncpy((char *)list->file[list->ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE); list->file[list->ptr].type = FILETYPE_DIR; list->ptr++; } else { strncpy((char *)list->file[list->ptr].name, (char *)fn, FILEMGR_FILE_NAME_SIZE); list->file[list->ptr].type = FILETYPE_FILE; list->ptr++; } } } } f_closedir(&dir); return res; }
vfs_dirent_t* vfs_readdir(vfs_dir_t* dir) { FILINFO fi; fi.lfname = NULL; FRESULT r = f_readdir(dir, &fi); if (r != FR_OK) return NULL; if (fi.fname[0] == 0) return NULL; memcpy(dir_ent.name, fi.fname, sizeof(fi.fname)); return &dir_ent; }
void readFileList(void) { #if (USE_SDCARD == 1) || defined( USE_USB_OTG_HS ) FRESULT fres; FILINFO finfo; DIR dirs; static char lfn[_MAX_LFN + 1]; int i; win_showMsgWin(); scr_gotoxy(2, 0); scr_printf("Open SD dir.. "); if ((fres = f_opendir(&dirs, path)) != FR_OK) { showCriticalStatus(" f_opendir()\n error [code:%d]\n Only RESET possible at now", fres); WAIT_KEY_C(); } scr_puts("\nRead file list"); finfo.lfname = lfn; finfo.lfsize = sizeof(lfn); for (fileListSz = 0; f_readdir(&dirs, &finfo) == FR_OK && fileListSz < MAX_FILE_LIST_SZ;) { scr_gotoxy(0, 3); scr_printf("files:[%d]", fileListSz); if (!finfo.fname[0]) break; if (finfo.fname[0] == '.') continue; if (!(finfo.fattrib & AM_DIR) && strcmp(CONF_FILE_NAME, *finfo.lfname ? finfo.lfname : finfo.fname) != 0) strncpy(&fileList[fileListSz++][0], *finfo.lfname ? finfo.lfname : finfo.fname, MAX_FILE_NAME_SZ); } if (loadedFileName[0] != 0) { // set last loaded file as selected file scr_printf("\nselect:'%s'..", loadedFileName); for (i = 0; i < fileListSz; i++) { if (!strcmp(&fileList[i][0], &loadedFileName[0])) { loadedFileName[0] = 0; // reset for next dir reload currentFile = i; if (currentFile < FILE_LIST_ROWS) firstFileInWin = 0; else if ((fileListSz - currentFile) < FILE_LIST_ROWS) firstFileInWin = fileListSz - FILE_LIST_ROWS; else firstFileInWin = currentFile; break; } } scr_printf("\npos in win/cur file:%d/%d", firstFileInWin, currentFile); } scr_puts("\n---- OK -----"); #endif }
/** * @brief Image browser * @param path: pointer to root path * @retval None */ static uint8_t Image_Browser(char *path) { FRESULT res; uint8_t ret = 1; FILINFO fno; DIR dir; char *fn; res = f_opendir(&dir, path); if (res != FR_OK) { Error_Handler(); } else { for (;;) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) break; if (fno.fname[0] == '.') continue; fn = fno.fname; if (fno.fattrib & AM_DIR) { continue; } else { if((strstr(fn, "bmp")) || (strstr(fn, "BMP"))) { res = f_open(&file, fn, FA_OPEN_EXISTING | FA_READ); Show_Image(); USBH_Delay(100); ret = 0; while((Appli_state == APPLICATION_START) && \ (BSP_PB_GetState (BUTTON_KEY) != SET)) { Toggle_Leds(); } f_close(&file); } } } } /* LCD Log initialization */ LCD_LOG_Init(); LCD_LOG_SetHeader((uint8_t *)"LTDC Application"); LCD_LOG_SetFooter ((uint8_t *)" USB Host Library V3.2.0" ); USBH_USR_ApplicationState = USH_USR_FS_READLIST; f_closedir(&dir); return ret; }
/** * @brief Add entire folder to play list. * @param Foldername: pointer to folder name. * @retval None */ static void _AddEntireFolder(char *Foldername) { FRESULT res; FILINFO fno; DIR dir; char *fn; static char tmp[FILEMGR_FILE_NAME_SIZE]; #if _USE_LFN static char lfn[_MAX_LFN]; fno.lfname = lfn; fno.lfsize = sizeof(lfn); #endif res = f_opendir(&dir, Foldername); if (res == FR_OK) { while (1) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif if (VideoList.ptr < FILEMGR_LIST_DEPDTH) { if ((fno.fattrib & AM_DIR) == 0) { if((strstr(fn, ".emf")) || (strstr(fn, ".EMF"))) { strcpy(tmp, Foldername); strcat(tmp, "/"); strcat(tmp, fn); strncpy((char *)VideoList.file[VideoList.ptr].name, (char *)tmp, FILEMGR_FILE_NAME_SIZE); VideoList.ptr++; } } } } } f_closedir(&dir); }
struct dirent * FS_ReadDir( FS_DIR *dirp) { _FS_PTR * dir = (_FS_PTR *) dirp; FILINFO FileInfo; static struct dirent ent; char *fn; #if _USE_LFN static WCHAR lfn[_MAX_LFN+1]; FileInfo.lfname = (TCHAR*)lfn; FileInfo.lfsize = sizeof(lfn); #endif ent.d_name[0]=0; if (dirp == 0) { return 0; /* Device not found */ } FS_X_OS_LockDirOp(); dir->error = f_readdir ( &dir->fs.dir, /* Pointer to the open directory object */ &FileInfo /* Pointer to the file information structure */ ); if(dir->error!=FR_OK) { FS_X_OS_UnlockDirOp(); ent.d_name[0]=0; ent.st_mode=0; ent.id = 0; ent.st_ctime = 0; return 0; } #if _USE_LFN fn = (char *)(*FileInfo.lfname ? FileInfo.lfname : FileInfo.fname); #else fn = (char *)FileInfo.fname; #endif if(FileInfo.fname[0] == 0) //end ent.d_name[0]=0; else strcpy(ent.d_name,fn); ent.st_mode = (FileInfo.fattrib & AM_DIR)?_IFDIR:0; ent.id = FileInfo.fsize; ent.st_ctime = FileInfo.ftime|(FileInfo.fdate<<16); FS_X_OS_UnlockDirOp(); return &ent; }
/** * \brief Show SD card content on the OLED screen. * \note Does not browse sub folders. */ static void display_sd_files_unicode(void) { FRESULT res; FILINFO fno; uint32_t line; uint32_t pos; char *pc_fn; TCHAR path[3]; path[0] = 0x0030; path[1] = 0x003A; path[2] = 0x0000; #if _USE_LFN TCHAR c_lfn[_MAX_LFN + 1]; fno.lfname = c_lfn; fno.lfsize = sizeof(c_lfn); #endif #ifndef CONF_ENGLISH_LANGUAGE line = 1; #else line = 0; #endif pos = 1; /* Open the directory */ res = f_opendir(&dir, path); if (res == FR_OK) { for (;;) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } #if _USE_LFN pc_fn = (char *)(*fno.lfname ? fno.lfname : fno.fname); #else pc_fn = (char *)(fno.fname); #endif if (*pc_fn == '.') { continue; } if ((pos >= sd_listing_pos) && (line < 4)) { multi_language_show_file_name(line, pc_fn); line++; #ifndef CONF_ENGLISH_LANGUAGE line++; #endif } pos += 1; } } }
static Variant HHVM_METHOD(DirectoryIterator, hh_readdir) { auto dir = getDir<Directory>(this_); if (auto array_dir = dynamic_cast<ArrayDirectory*>(dir)) { auto prop = this_->o_realProp("dirName", 0, s_directory_iterator); *prop = array_dir->path(); } return f_readdir(Resource(dir)); }