Sample code for DirectoryList class library

Dependencies:   DirectoryList mbed

Information

Use of this sample code is described in library page.
https://developer.mbed.org/users/okano/code/DirectoryList/

このサンプルコードの使い方の説明は,ライブラリのページで解説されています. https://developer.mbed.org/users/okano/code/DirectoryList/

main.cpp

Committer:
okano
Date:
2015-07-17
Revision:
2:e1cc05857acb
Parent:
0:f31922ea4d33

File content as of revision 2:e1cc05857acb:

/**
 *  DirectoryList library demo program
 *
 *  @author  Tedd OKANO
 *  @version 0.1
 *  @date    Jan-2015
 *
 *  A simple directory listing interface.
 */

#include "mbed.h"
#include "DirectoryList.h"

LocalFileSystem local( "local" );

int main(void)
{
    //
    //  make an instance and get file name list
    //
    
    DirectoryList   dir( "/local" );

    //
    //  check if the directory list is obtained successfully
    //
    
    if ( dir.error_check() )
        error( "directory could not be opened\r\n" );

    //
    //  show file names
    //  each file names are given as std::string object
    //  (call "c_str()" if you need to convert to "char *")
    //
    //  this sample shows the file name displayed by printf
    //  with converting string class to normal-C-string 
    //
        
    for ( int i = 0; i < dir.size(); i++ )
        printf( "%s\r\n", dir[ i ].c_str() );
}