MCPcopy Create free account
hub / github.com/Simple-XX/SimpleKernel / FresultToErrorCode

Function FresultToErrorCode

src/filesystem/fatfs/fatfs.cpp:23–54  ·  view source on GitHub ↗

* @brief 将 FatFS FRESULT 映射到内核 ErrorCode * @details 区分常见错误类别,避免将所有错误笼统归入 kFsCorrupted */

Source from the content-addressed store, hash-verified

21 * @details 区分常见错误类别,避免将所有错误笼统归入 kFsCorrupted
22 */
23auto FresultToErrorCode(FRESULT fr) -> ErrorCode {
24 switch (fr) {
25 case FR_OK:
26 return ErrorCode::kSuccess;
27 case FR_NO_FILE:
28 case FR_NO_PATH:
29 return ErrorCode::kFsFileNotFound;
30 case FR_EXIST:
31 return ErrorCode::kFsFileExists;
32 case FR_DENIED:
33 case FR_WRITE_PROTECTED:
34 return ErrorCode::kFsPermissionDenied;
35 case FR_NOT_READY:
36 case FR_DISK_ERR:
37 return ErrorCode::kBlkReadFailed;
38 case FR_NOT_ENABLED:
39 case FR_INVALID_DRIVE:
40 return ErrorCode::kFsNotMounted;
41 case FR_NOT_ENOUGH_CORE:
42 return ErrorCode::kFsNoSpace;
43 case FR_INVALID_NAME:
44 case FR_INVALID_PARAMETER:
45 case FR_INVALID_OBJECT:
46 return ErrorCode::kInvalidArgument;
47 case FR_TOO_MANY_OPEN_FILES:
48 return ErrorCode::kFsFdTableFull;
49 case FR_INT_ERR:
50 case FR_MKFS_ABORTED:
51 default:
52 return ErrorCode::kFsCorrupted;
53 }
54}
55
56/**
57 * @brief 将 FRESULT 转换为 Expected<void>

Callers 9

FresultToExpectedFunction · 0.85
MountMethod · 0.85
OpenFilMethod · 0.85
LookupMethod · 0.85
CreateMethod · 0.85
ReadMethod · 0.85
WriteMethod · 0.85
SeekMethod · 0.85
ReadDirMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected