ComFile.h
ComFile.cpp
- /*
- @author:EricsT
- @data:20241024
- @version:V1.0
- */
- #include "stdafx.h"
- #include "ComFile.h"
- #include <io.h>
- bool ComFile::isFileExists(string strFilePath)
- {
- if (-1 == _access(strFilePath.c_str(), 0))
- return false;
- return true;
- }
- bool ComFile::isFileExists(CString csFilePath)
- {
- //CStringToString
- int len = csFilePath.GetLength();
- PCHAR pch = new char[len + 1];
- size_t pchSize = wcstombs(pch, csFilePath, len + 1);
- if (pchSize == wstring::npos)
- {
- delete pch;
- return "";
- }
- string strFilePath(pch);
- delete pch;
- if (-1 == _access(strFilePath.c_str(), 0))
- return false;
- return true;
- }
- bool ComFile::isFileExists(PCHAR pchFilePath)
- {
- if (-1 == _access(pchFilePath, 0))
- return false;
- return true;
- }
- BYTE ComFile::ReadByteFromAddr_Bin(FILE* fp, DWORD iAddr)
- {
- if (nullptr == fp)
- return 0;
- BYTE bRet = 0;
- fseek(fp, iAddr, SEEK_SET);
- fread(&bRet, sizeof(BYTE), 1, fp);
- return bRet & 0xFF;
- }
- BYTE ComFile::ReadByte_Bin(FILE* fp)
- {
- if (nullptr == fp)
- return 0;
- BYTE bRet = 0;
- fread(&bRet, sizeof(BYTE), 1, fp);
- return bRet & 0xFF;
- }
- WORD ComFile::ReadWordFromAddr_Bin(FILE* fp, DWORD iAddr)
- {
- if (nullptr == fp)
- return 0;
- WORD wRet = 0;
- fseek(fp, iAddr, SEEK_SET);
- fread(&wRet, sizeof(WORD), 1, fp);
- return wRet & 0xFFFF;
- }
- WORD ComFile::ReadWord_Bin(FILE * fp)
- {
- if (nullptr == fp)
- return 0;
- WORD wRet = 0;
- fread(&wRet, sizeof(WORD), 1, fp);
- return wRet & 0xFFFF;
- }
- DWORD ComFile::ReadDWordFromAddr_Bin(FILE* fp, DWORD iAddr)
- {
- if (nullptr == fp)
- return 0;
- DWORD dwRet = 0;
- fseek(fp, iAddr, SEEK_SET);
- fread(&dwRet, sizeof(DWORD), 1, fp);
- return dwRet & 0xFFFFFFFF;
- }
- DWORD ComFile::ReadDWord_Bin(FILE* fp)
- {
- if (nullptr == fp)
- return 0;
- DWORD dwRet = 0;
- fread(&dwRet, sizeof(DWORD), 1, fp);
- return dwRet & 0xFFFFFFFF;
- }
- void ComFile::ReadUselessByteFromAddr_Bin(FILE* fp, DWORD iAddr, DWORD num)
- {
- if (nullptr == fp)
- return;
- BYTE bRet;
- fseek(fp, iAddr, SEEK_SET);
- for (int i = 0; i < num; i++)
- fread(&bRet, sizeof(BYTE), 1, fp);
- }
- void ComFile::ReadUselessByte_Bin(FILE* fp, DWORD num)
- {
- if (nullptr == fp)
- return;
- BYTE bRet;
- for (int i = 0; i < num; i++)
- fread(&bRet, sizeof(BYTE), 1, fp);
- }
- std::string ComFile::GetLine_Stream(ifstream& ifs)
- {
- if (!ifs.is_open())
- return string();
- string strLine;
- getline(ifs, strLine);
- return strLine;
- }
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |