Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
replace CreateFile, WriteFile, CloseHandle in compiler.cpp
Browse files Browse the repository at this point in the history
and remove unnecessary CreateDirectory from str_service.cpp
  • Loading branch information
q4a committed Jan 19, 2022
1 parent f05a30c commit 09e6afc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
9 changes: 4 additions & 5 deletions src/apps/engine/src/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1845,12 +1845,11 @@ bool COMPILER::Compile(SEGMENT_DESC &Segment, char *pInternalCode, uint32_t pInt
_splitpath(Segment.name, nullptr, nullptr, file_name, nullptr);
strcat_s(file_name, ".b");
std::wstring FileNameW = utf8::ConvertUtf8ToWide(file_name);
fh = CreateFile(FileNameW.c_str(), GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, nullptr);
if (fh != INVALID_HANDLE_VALUE)
auto fileS = fio->_CreateFile(file_name, std::ios::binary | std::ios::out);
if (fileS.is_open())
{
WriteFile(fh, Segment.pCode, Segment.BCode_Program_size, (LPDWORD)&dwR, nullptr);
CloseHandle(fh);
fio->_WriteFile(fileS, Segment.pCode, Segment.BCode_Program_size);
fio->_CloseFile(fileS);
}
}
return true;
Expand Down
13 changes: 0 additions & 13 deletions src/libs/xinterface/src/string_service/str_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,19 +1292,6 @@ uint32_t _InterfaceCreateFolder(VS_STACK *pS)
if (!pDat)
return IFUNCRESULT_FAILED;
const char *sFolderName = pDat->GetString();

// precreate directory
const char *pcCurPtr = sFolderName;
while ((pcCurPtr = strchr(pcCurPtr, '\\')) != nullptr)
{
const char tmpchr = pcCurPtr[0];
((char *)pcCurPtr)[0] = 0;
std::wstring FolderNameW = utf8::ConvertUtf8ToWide(sFolderName);
CreateDirectory(FolderNameW.c_str(), nullptr);
((char *)pcCurPtr)[0] = tmpchr;
pcCurPtr++;
}
// create self directory
const int32_t nSuccess = fio->_CreateDirectory(sFolderName);

pDat = (VDATA *)pS->Push();
Expand Down

0 comments on commit 09e6afc

Please sign in to comment.