This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ModLocalFileSystem.h Source File

ModLocalFileSystem.h

00001 #pragma once
00002 ////////////////////////////////////////////////////////////////////////////////
00003 // ModRomFiles.h
00004 ////////////////////////////////////////////////////////////////////////////////
00005 
00006 #include "NyLPC_net.h"
00007 #include "ModBaseClass.h"
00008 
00009 
00010 namespace MiMic
00011 {
00012     class HttpdConnection;
00013 
00014     /**
00015      * This class is httpd module.
00016      * The class provide files on mbed LocalFile System.
00017      * The class provide 2 services.
00018      * <ul>
00019      * <li>lfile content provider.</li>
00020      * This is response of local file path. for example "/local/file.txt". full content of file.
00021      * <li>file list provider</li>
00022      * This is array of json response. for example, "/local/"
00023      * [{name:"name",size:"size",type:"type"}]
00024      * </ul>
00025      */
00026     class ModLocalFileSystem:ModBaseClass
00027     {
00028     private:
00029         /** file system type*/
00030         unsigned char _fs_type;
00031         /** ルートディレクトリのプレフィクス "/pathname/" 表記*/        
00032         const char* _root_alias;
00033     private:
00034         void retFile(char* i_buf,HttpdConnection& i_connection);
00035         void retDirHtml(const char* i_buf,HttpdConnection& i_connection,unsigned char i_fs_type);
00036         void retDirJson(const char* buf,HttpdConnection& i_connection,unsigned char i_fs_type);
00037         
00038     public:
00039         const static unsigned char FST_DEFAULT=0x00;
00040         const static unsigned char FST_SDFATFS=0x01;
00041     public:
00042         /**
00043          * Create filesistem responder.
00044          * @param i_fs_type
00045          * Filesystem type.
00046          * This value should match the file system type of mount point.
00047          * <ul>
00048          * <li>FST_DEFAULT - default filesystem(eg. mbed local.)</li>         
00049          * <li>FST_SDFATFS - for SD filesystem</li>
00050          * </ul>
00051          */
00052         ModLocalFileSystem(const char* i_path,unsigned char i_fs_type=FST_DEFAULT);
00053         /**
00054          * 2nd constructor.
00055          * @param i_root_alias
00056          * Root path string. Handler replaces the accepted URL prefix in the root path.
00057          * ex. '/' or '/virtual_path/',
00058          */
00059         ModLocalFileSystem(const char* i_path,const char* i_root_alias,unsigned char i_fs_type=FST_DEFAULT);
00060         /**
00061          * 3rd donstructor.
00062          * Must be call setParam method before call execute.
00063          */
00064         ModLocalFileSystem();
00065         virtual ~ModLocalFileSystem();
00066         void setParam(const char* i_path,unsigned char i_fs_type=FST_DEFAULT);
00067         void setParam(const char* i_path,const char* i_root_alias,unsigned char i_fs_type=FST_DEFAULT);
00068         virtual bool canHandle(HttpdConnection& i_connection);
00069        
00070         bool execute(HttpdConnection& i_connection);
00071     };
00072 
00073 }