📄 fs_checkdisk.c
字号:
/*
**********************************************************************
* Micrium, Inc.
* 949 Crestview Circle
* Weston, FL 33327-1848
*
* uC/FS
*
* (c) Copyright 2001 - 2006, Micrium, Inc.
* All rights reserved.
*
***********************************************************************
----------------------------------------------------------------------
----------------------------------------------------------------------
File : CheckDisk.c
Purpose : Sample program demonstrating FS FAT checkdisk functionality
---------------------------END-OF-HEADER------------------------------
*/
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
#include "FS_API.h"
#include "Global.h"
static U32 _aBuffer[5000];
/*********************************************************************
*
* _OnError
*/
int _OnError(int ErrCode, ...); // Forward declaration to avoid "no prototype" warning
int _OnError(int ErrCode, ...) {
va_list ParamList;
const char * sFormat;
char c;
char ac[1000];
sFormat = FS_FAT_CheckDisk_ErrCode2Text(ErrCode);
if (sFormat) {
va_start(ParamList, ErrCode);
vsprintf(ac, sFormat, ParamList);
printf("%s\n", ac);
}
if (ErrCode != FS_ERRCODE_CLUSTER_UNUSED) {
printf(" Do you want to repair this? (y/n/a) ");
} else {
printf(" * Convert lost cluster chain into file (y)\n"
" * Delete cluster chain (d)\n"
" * Do not repair (n)\n"
" * Abort (a) ");
printf("\n");
}
c = getchar();
printf("\n");
if ((c == 'y') || (c == 'Y')) {
return 1;
} else if ((c == 'a') || (c == 'A')) {
return 2;
} else if ((c == 'd') || (c == 'D')) {
return 3;
}
return 0; // Do not fix.
}
/*********************************************************************
*
* MainTask
*/
void MainTask(void); // Forward declaration to avoid "no prototype" warning
void MainTask(void) {
FS_Init();
while (FS_FAT_CheckDisk("", &_aBuffer[0], sizeof(_aBuffer), 5, _OnError) == 1) {
}
}
/*************************** End of file ****************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -