Changeset 155 for uKadecot/trunk/uip/apps/webserver/httpd-fs.c
- Timestamp:
- Feb 4, 2016, 11:11:09 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uKadecot/trunk/uip/apps/webserver/httpd-fs.c
r154 r155 40 40 #include "mmc_rspi.h" 41 41 #include <string.h> 42 #include "http-strings.h" 43 44 #ifndef _MSC_VER 45 #ifndef strcat_s 46 #define strcat_s(dst, dsz, src) strcat(dst, src) 47 #endif 48 #endif 42 49 43 50 //#define FILE_DUMP … … 114 121 /*-----------------------------------------------------------------------------------*/ 115 122 int 116 httpd_fs_open(int drv, c onst char *name, struct httpd_fs_file *file)123 httpd_fs_open(int drv, char *name, int len, struct httpd_fs_file *file) 117 124 { 118 125 FRESULT res; 119 FATFS *fs = (FATFS *)file->fs; 126 FATFS *fs = (FATFS *)&file->fs; 127 FILINFO fno; 128 DIR dir; 120 129 121 130 file->pos = 0; … … 123 132 file->drv = drv; 124 133 file->name = name; 134 file->redirect = 0; 125 135 memset(fs, 0, sizeof(FATFS)); 126 136 … … 143 153 } 144 154 145 if((res = pf_open(fs, name)) != FR_OK){ 146 printf("pf_open(%d:%s) => %d\n", drv, name, res); 147 return 0; 155 if ((res = pf_open(fs, name)) != FR_OK) { 156 dir.fs = fs; 157 if ((res = pf_opendir(&dir, name)) != FR_OK) { 158 printf("pf_opendir(%d:%s) => %d\n", drv, name, res); 159 return 0; 160 } 161 162 if ((res = pf_readdir(&dir, &fno)) != FR_OK) { 163 printf("pf_readdir(%d:%s) => %d\n", drv, name, res); 164 return 0; 165 } 166 167 if (len != 0/*fno.fattrib & AM_DIR*/) { 168 strcat_s(name, len, http_index_html); 169 res = pf_open(fs, name); 170 file->redirect = res == FR_OK; 171 } 172 else 173 res = FR_NO_FILE; 174 175 if (res != FR_OK) { 176 printf("pf_open(%d:%s) => %d %x\n", drv, name, res, fno.fattrib); 177 return 0; 178 } 148 179 } 149 180 … … 160 191 FRESULT ret; 161 192 UINT rlen; 162 FATFS *fs = (FATFS *) file->fs;193 FATFS *fs = (FATFS *)&file->fs; 163 194 164 195 if((ret = pf_lseek(fs, file->pos)) != FR_OK){
Note:
See TracChangeset
for help on using the changeset viewer.