/*-----------------------------------------------------------------------------------*/ #if LWIP_HTTPD_DYNAMIC_FILE_READ #if LWIP_HTTPD_FS_ASYNC_READ int fs_read_async(struct fs_file *file, char *buffer, int count, fs_wait_cb callback_fn, void *callback_arg) #else /* LWIP_HTTPD_FS_ASYNC_READ */ int fs_read(struct fs_file *file, char *buffer, int count) #endif /* LWIP_HTTPD_FS_ASYNC_READ */ { int read; if(file->index == file->len) { return FS_READ_EOF; } #if LWIP_HTTPD_FS_ASYNC_READ #if LWIP_HTTPD_CUSTOM_FILES if (!fs_canread_custom(file)) { if (fs_wait_read_custom(file, callback_fn, callback_arg)) { return FS_READ_DELAYED; } } #else /* LWIP_HTTPD_CUSTOM_FILES */ LWIP_UNUSED_ARG(callback_fn); LWIP_UNUSED_ARG(callback_arg); #endif /* LWIP_HTTPD_CUSTOM_FILES */ #endif /* LWIP_HTTPD_FS_ASYNC_READ */ read = file->len - file->index; if(read > count) { read = count; } MEMCPY(buffer, (file->data + file->index), read); file->index += read; return(read); }
int fs_is_file_ready(struct fs_file *file, fs_wait_cb callback_fn, void *callback_arg) { if (file != NULL) { #if LWIP_HTTPD_FS_ASYNC_READ && LWIP_HTTPD_CUSTOM_FILES if (!fs_canread_custom(file)) { if (fs_wait_read_custom(file, callback_fn, callback_arg)) { return 0; } } #endif /* LWIP_HTTPD_FS_ASYNC_READ && LWIP_HTTPD_CUSTOM_FILES */ } return 1; }