esemi00

Dependencies:   mbed FatFileSystemCpp

mainUSB1.cpp

Committer:
esemi00
Date:
2021-01-20
Revision:
4:09a962d3fe70
Parent:
main.cpp@ 0:e294af8d0e07

File content as of revision 4:09a962d3fe70:

//mainUSB1.cpp
#include "mbed.h"
#include "MSCFileSystem.h"
#define FSNAME "usb"//FATファイルシステムのマウント名(任意) /マウント名 がルートディレクトリ

Serial pc(USBTX,USBRX);
MSCFileSystem msc(FSNAME);	//USBフラッシュメモリを/usbにマウントして使用するため宣言

int main(){	
	DIR *d;//ディレクトリ
    struct dirent *p;			//ディレクトリ内情報(ファイル名、ファイルタイプ)
    
    d = opendir("/" FSNAME);		//ルートディレクトリをオープン
    
    pc.printf("\nList of files on the flash drive:\r\n");
    
    if ( d != NULL )    {
        while ( (p = readdir(d)) != NULL ) {	//ルートディレクトリ内情報読み出し
        	pc.printf(" - %s\n", p->d_name);	//ファイル名を表示
		}
    } else {
        pc.printf("Could not open directory!\r\n");
    }
}









//d = opendir("/" FSNAME "/web");