Improve repair function

This commit is contained in:
Robin Jones 2024-03-19 23:00:32 +00:00
parent dc793898f5
commit ae0d19bcce
2 changed files with 14 additions and 4 deletions

View File

@ -61,7 +61,17 @@ cpak_err_t cpak_overwrite_contents_from_file(char *path, uint8_t port) {
return CONTROLLER_PAK_ERR_IO; return CONTROLLER_PAK_ERR_IO;
} }
cpak_err_t cpak_attempt_repair() { cpak_err_t cpak_attempt_repair(uint8_t port, bool allow_formatting) {
// TODO: implementation. int result = validate_mempak(port);
return CONTROLLER_PAK_ERR_IO; if (result == CONTROLLER_PAK_OK) {
return CONTROLLER_PAK_OK;
}
// TODO: repair implementation.
// last resort would be to format it completely!
if (result == -3 && allow_formatting) {
result = format_mempak(port);
}
return result;
} }

View File

@ -28,6 +28,6 @@ typedef struct {
cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info); cpak_err_t cpak_info_load(uint8_t port, cpak_info_t *cpak_info);
int cpak_clone_contents_to_file(char *path, uint8_t port); int cpak_clone_contents_to_file(char *path, uint8_t port);
cpak_err_t cpak_overwrite_contents_from_file(char *path, uint8_t port); cpak_err_t cpak_overwrite_contents_from_file(char *path, uint8_t port);
cpak_err_t cpak_attempt_repair(); cpak_err_t cpak_attempt_repair(uint8_t port, bool allow_formatting);
#endif #endif