📄 main.cpp
字号:
#include <Windows.h>
#include <Winbase.h>
#include <tchar.h>
#include <stdio.h>
#include <memory.h>
#include <iostream>
#include "FatMaster.h"
using namespace::std;
int main(int argc, char **argv)
{
cout<<"start FAT OPE test"<<endl;
FatMaster fat32Test;
BOOL bRet;
DWORD errNum;
BYTE inBuf[512], filePathName[64], *pOutBuf=NULL;
UINT32 inSize, size;
UINT32 command;
while(1){
memset(inBuf, 0, sizeof(inBuf));
cout<<" +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "<<endl;
cout<<"Plz enter the command number:"<<endl;
cout<<"1:write tag in file;"<<endl;
cout<<"2:read tag from file;"<<endl;
cout<<"0:exit the FatOperator."<<endl;
cin>>inBuf;
command = atoi((char*)inBuf);
switch(command) {
case 1:
cout<<"Plz enter the full path file name(name length must be less than 64)"<<endl;
cin>>inBuf;
if(strlen((char*)inBuf) > 64){
cout<<"!!! ERROR: enter file name large than 64; Plz enter agin"<<endl;
continue;
}
strcpy((char*)filePathName, (char*)inBuf);
cout<<"Plz enter the tag string"<<endl;
cin>>inBuf;
inSize = strlen((char*)inBuf);
bRet = fat32Test.WriteTags((char*)filePathName, (char*)&inBuf, &inSize);
if( !bRet ) {
errNum = GetLastError();
cout<<"!!! ERROR: enter tag failed with errno="<<errNum<<endl;
} else {
cout<<"write tag successfully, inSize: "<<inSize<<" inbuf: "<<inBuf<<" ."<<endl;
}
break;
case 2:
cout<<"Plz enter the full path file name(name length must be less than 64)"<<endl;
cin>>inBuf;
if(strlen((char*)inBuf) > 64){
cout<<"!!! ERROR: enter file name large than 64; Plz enter agin"<<endl;
continue;
}
strcpy((char*)filePathName, (char*)inBuf);
bRet = fat32Test.ReadTags((char*)filePathName, (char**)&pOutBuf, &size);
if( !bRet ) {
errNum = GetLastError();
cout<<"!!! ERROR: enter tag failed with errno="<<errNum<<endl;
} else {
cout<<"read tag successfully, size: "<<size<<" *pOutBuf: ";
if(pOutBuf)
cout<<pOutBuf;
cout<<" ."<<endl;
}
delete [] pOutBuf;
break;
case 0:
exit(0);
default:
cout<<"Don't recognise command number, plz input again"<<endl;
break;
}
}
cout<<"end FAT OPE test"<<endl;
return 0;
}
/*
const char* file = "E:\\w\\me\\ttag.txt";
const char* dfile = "E:\\w\\me\\ttag.txt";
char buf[512] = "hello world!";
char* dbuf;
UINT32 dsize, size = 512;
BOOL ret = fat32Test.WriteTags(file, (char*)&buf, &size);
cout<<".write tag:"<<buf<<"."<<endl;
ret = fat32Test.ReadTags(dfile, &dbuf, &dsize);
cout<<".read tag:"<<dbuf<<".."<<endl;
delete [] dbuf;
while(1){
cout<<"Plz enter the command number:"<<endl;
cout<<"1:write tag in file;"<<endl;
cout<<"2:read tag from file;"<<endl;
cout<<"0:exit the FatOperator."<<endl;
cin>>inBuf;
command = atoi(inBuf);
cout<<"Plz enter the full path file name(name length must be less than 64)"<<endl;
cin>>inBuf;
if(strlen(inBuf) > 64){
cout<<"!!! ERROR: enter file name large than 64; Plz enter agin"<<endl;
continue;
}
strcpy(filePathName, inBuf);
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -