/** * @file app_fatfs.c * @brief FATFS 文件系统 API 桩实现(功能待实现) * * 本文件为 app_fatfs.h 中声明的所有函数提供桩实现。 * 所有函数返回"未实现"错误状态,待 FATFS 功能完整移植后再替换为真实实现。 */ #include "app_fatfs.h" #include /* 文件系统基础操作 */ FS_Status fs_init(void) { return FS_STATUS_INIT_FAILED; } FS_Status fs_deinit(void) { return FS_STATUS_OK; } FS_Status fs_mount(const char *path) { (void)path; return FS_STATUS_FS_ERROR; } FS_Status fs_unmount(const char *path) { (void)path; return FS_STATUS_OK; } FS_Status fs_check_space(void) { return FS_STATUS_NO_SPACE; } bool fs_get_is_mounted(void) { return false; } /* 文件系统格式化 */ FS_Status fs_format_drive(const char *drive_path) { (void)drive_path; return FS_STATUS_FS_ERROR; } FS_Status fs_format_drive_fat16(const char *drive_path) { (void)drive_path; return FS_STATUS_FS_ERROR; } /* 目录操作 */ FS_Status fs_mkdir(const char *path) { (void)path; return FS_STATUS_FS_ERROR; } FS_Status fs_dir_exists(const char *path, bool *exists) { (void)path; if (exists != NULL) { *exists = false; } return FS_STATUS_OK; } FS_Status fs_list_dir(const char *path, FS_FileInfo *file_list, uint32_t *count, uint32_t max_count) { (void)path; (void)file_list; (void)max_count; if (count != NULL) { *count = 0; } return FS_STATUS_OK; } /* 文件操作 */ FS_Status fs_create_file(const char *path) { (void)path; return FS_STATUS_FS_ERROR; } FS_Status fs_delete_file(const char *path) { (void)path; return FS_STATUS_FS_ERROR; } FS_Status fs_file_exists(const char *path, bool *exists) { (void)path; if (exists != NULL) { *exists = false; } return FS_STATUS_OK; } FS_Status fs_get_file_size(const char *path, uint32_t *size) { (void)path; if (size != NULL) { *size = 0; } return FS_STATUS_FILE_NOT_FOUND; } FS_Status fs_get_file_info(const char *path, FS_FileInfo *info) { (void)path; if (info != NULL) { memset(info, 0, sizeof(*info)); } return FS_STATUS_FILE_NOT_FOUND; } FS_Status fs_rename_file(const char *old_path, const char *new_path) { (void)old_path; (void)new_path; return FS_STATUS_FS_ERROR; } FS_Status fs_copy_file(const char *src_path, const char *dst_path) { (void)src_path; (void)dst_path; return FS_STATUS_FS_ERROR; } /* 文件读写 */ FS_Status fs_open(void *file, const char *path, uint8_t mode) { (void)file; (void)path; (void)mode; return FS_STATUS_FS_ERROR; } FS_Status fs_close(void *file) { (void)file; return FS_STATUS_OK; } FS_Status fs_read(void *file, void *buffer, uint32_t size, uint32_t *bytes_read) { (void)file; (void)buffer; (void)size; if (bytes_read != NULL) { *bytes_read = 0; } return FS_STATUS_READ_FAILED; } FS_Status fs_write(void *file, const void *buffer, uint32_t size, uint32_t *bytes_written) { (void)file; (void)buffer; (void)size; if (bytes_written != NULL) { *bytes_written = 0; } return FS_STATUS_WRITE_FAILED; } FS_Status fs_seek(void *file, uint32_t offset) { (void)file; (void)offset; return FS_STATUS_FS_ERROR; } FS_Status fs_truncate(void *file) { (void)file; return FS_STATUS_FS_ERROR; } FS_Status fs_sync(void *file) { (void)file; return FS_STATUS_OK; } /* 文件内容操作 */ FS_Status fs_read_file_content(const char *path, char *buffer, uint32_t buffer_size, FS_ReadRange *range) { (void)path; (void)buffer; (void)buffer_size; if (range != NULL) { range->actual_read = 0; } return FS_STATUS_READ_FAILED; } FS_Status fs_write_file_content(const char *path, const void *data, uint32_t size, bool append) { (void)path; (void)data; (void)size; (void)append; return FS_STATUS_WRITE_FAILED; } FS_Status fs_write_string(const char *path, const char *str, bool append) { (void)path; (void)str; (void)append; return FS_STATUS_WRITE_FAILED; } /* 文件系统信息 */ FS_Status fs_get_volume_info(const char *path, uint32_t *total_kb, uint32_t *free_kb, float *usage_percent) { (void)path; if (total_kb != NULL) *total_kb = 0; if (free_kb != NULL) *free_kb = 0; if (usage_percent != NULL) *usage_percent = 0.0f; return FS_STATUS_FS_ERROR; } /* 通用文件管理 */ FS_Status fs_file_manager_check_and_roll_ex(const FileManagerConfig *config, const char *current_file, uint32_t pending_write_size, char *new_filename, uint32_t new_filename_len) { (void)config; (void)current_file; (void)pending_write_size; (void)new_filename; (void)new_filename_len; return FS_STATUS_FS_ERROR; } FS_Status fs_file_manager_create_new(const FileManagerConfig *config, char *new_filename, uint32_t max_len) { (void)config; if (new_filename != NULL && max_len > 0) new_filename[0] = '\0'; return FS_STATUS_FS_ERROR; } FS_Status fs_file_manager_ensure_dir_exists(const FileManagerConfig *config) { (void)config; return FS_STATUS_FS_ERROR; } FS_Status fs_file_manager_get_count(const FileManagerConfig *config, uint32_t *count) { (void)config; if (count != NULL) *count = 0; return FS_STATUS_OK; } FS_Status fs_file_manager_delete_oldest(const FileManagerConfig *config) { (void)config; return FS_STATUS_FS_ERROR; } FS_Status fs_file_manager_find_latest(const FileManagerConfig *config, char *filename, uint32_t max_len) { (void)config; if (filename != NULL && max_len > 0) filename[0] = '\0'; return FS_STATUS_FILE_NOT_FOUND; } FS_Status fs_file_manager_find_oldest(const FileManagerConfig *config, char *filename, uint32_t max_len) { (void)config; if (filename != NULL && max_len > 0) filename[0] = '\0'; return FS_STATUS_FILE_NOT_FOUND; } FS_Status fs_file_manager_resolve_log_append_path(const FileManagerConfig *config, char *filename, uint32_t max_len) { (void)config; if (filename != NULL && max_len > 0) filename[0] = '\0'; return FS_STATUS_FS_ERROR; } void fs_log_set_filename_start_seq(uint8_t start_seq) { (void)start_seq; } FS_Status fs_generate_timestamp_filename(const FileManagerConfig *config, char *filename, uint32_t max_len) { (void)config; if (filename != NULL && max_len > 0) filename[0] = '\0'; return FS_STATUS_FS_ERROR; } bool fs_is_filename_valid(const char *filename, const FileManagerConfig *config) { (void)filename; (void)config; return false; } FS_Status fs_cleanup_invalid_files(const FileManagerConfig *config) { (void)config; return FS_STATUS_OK; } uint32_t fs_get_current_fat_time(void) { return 0; } FS_Status fs_get_current_time_string(char *buffer, uint32_t size) { if (buffer != NULL && size > 0) buffer[0] = '\0'; return FS_STATUS_FS_ERROR; } FS_Status fs_get_formatted_time_string(char *buffer, uint32_t size) { if (buffer != NULL && size > 0) buffer[0] = '\0'; return FS_STATUS_FS_ERROR; }