Dean Bell / Mbed 2 deprecated FTP_Server_D1

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers vfs.c Source File

vfs.c

00001 
00002 #include "mbed.h"                  // DRB
00003 #include "SDFileSystem.h"          // DRB
00004 #include "vfs.h"
00005 }
00006 
00007 extern void printit( char *p_buf );
00008 
00009 
00010 int  *vfs_openfs( void )
00011 {
00012 //    printit( "FTP vfs_openfs" );
00013     return NULL;
00014 }
00015 
00016 
00017 vfs_file_t *vfs_open( int *fd, const char *fname, const char *mode )
00018 {
00019 #if 0
00020     char what[ 40 ];
00021     
00022 //    printit( "FTP vfs_open" );
00023     printit( (char*)fname );
00024     sprintf( what, "/sd/%s", fname );
00025 //    printit( what );
00026     return (vfs_file_t *)fopen( what, mode );
00027 #else
00028     return (vfs_file_t *)fopen( fname, mode );
00029 #endif
00030 }
00031 
00032 
00033 ssize_t vfs_read( void *buf,int what, int BufferSize, vfs_file_t *fp )
00034 {
00035 #if 0
00036     char txt[ 40 ];
00037     
00038     sprintf( txt, "FTP vfs_read,%u", BufferSize );
00039     printit( txt );
00040     memset( buf, 0xAA, BufferSize );
00041 #endif
00042     return fread( buf, 1, BufferSize, (FILE*)fp);
00043 }
00044 
00045 
00046 int vfs_write(  void *buf,int what, int BufferSize, vfs_file_t *fp  )
00047 {
00048     return fwrite( buf, 1, BufferSize, (FILE*)fp);
00049 }
00050 
00051 
00052 int vfs_eof( vfs_file_t *fp )
00053 {
00054     //printit( "vfs_eof" );
00055     return feof( (FILE*)fp );
00056 //    return 0; // not eof
00057 }
00058 
00059 
00060 int vfs_close( vfs_file_t *fp  )
00061 {
00062     //printit( "vfs_close" );
00063     if( NULL != fp )
00064     {
00065         fclose( (FILE*)fp );
00066     }
00067     else
00068     {
00069         //printit( "vfs_close--opps!!!" );
00070     }
00071     return 0;
00072 }
00073 
00074 
00075 int vfs_stat( int *fd, const char *fname, vfs_stat_t *st )
00076 {
00077     printit( "" );
00078     printit( (char*)fname );
00079     st->st_mode = 1; // ok
00080     st->st_size = 123; // file size
00081     return 1;
00082 }
00083 
00084 
00085 /*
00086  * Find pathname of process's current directory.
00087  *
00088  * Use vfs vnode-to-name reverse cache; if that fails, fall back
00089  * to reading directory contents.
00090  */
00091 char *vfs_getcwd( int *fd, void *x, int y )
00092 {
00093     printit( "vfs_getcwd" );
00094     return (char*)malloc( 123 );
00095 }
00096 
00097 
00098 vfs_dir_t    *vfs_opendir( int *fd, char *cwd )
00099 {
00100     printit( "FTP vfs_opendir" );
00101     return 0;
00102 }
00103 
00104 
00105 vfs_dirent_t *vfs_readdir( vfs_dir_t *fd )
00106 {
00107     printit( "FTP vfs_readdir" );
00108     return 0;
00109 }
00110 
00111 
00112 int vfs_closedir( vfs_dir_t *fd )
00113 {
00114     return 0;
00115 }
00116 
00117 
00118 int vfs_mkdir( int *fd, const char *arg, int mode )
00119 {
00120     return 0;
00121 }
00122 
00123 
00124 int vfs_rmdir( int *fd, const char *arg )
00125 {
00126     return 0;
00127 }
00128 
00129 
00130 int vfs_rename( int *fd, char *oldname, const char *newname )
00131 {
00132     return rename( oldname, newname );
00133 }
00134 
00135 
00136 int vfs_remove( int *fd, const char *arg )
00137 {
00138     return remove( arg );
00139 }
00140 
00141 
00142 int vfs_chdir( int *fd, const char *arg )
00143 {
00144     return 0;
00145 }
00146