Browse Source

Clean-up mpqapi_set_hidden (#552)

* Clean-up mpqapi_set_hidden
Co-Authored-By: JustAnotherGuid <46401660+JustAnotherGuid@users.noreply.github.com>
pull/25/head
JustAnotherGuid 7 years ago committed by Anders Jenbo
parent
commit
694be2da8d
  1. 24
      Source/mpqapi.cpp
  2. 2
      Source/mpqapi.h

24
Source/mpqapi.cpp

@ -15,25 +15,19 @@ BOOLEAN save_archive_open; // weak
HANDLE sghArchive = (HANDLE)0xFFFFFFFF; // idb
BOOLEAN __fastcall mpqapi_set_hidden(const char *pszArchive, BOOLEAN hidden)
BOOL __fastcall mpqapi_set_hidden(const char *pszArchive, BOOL hidden)
{
const char *v2; // edi
BOOL v3; // esi
DWORD v4; // eax
BOOLEAN result; // al
DWORD v6; // esi
DWORD dwFileAttributes;
DWORD dwFileAttributesToSet;
v2 = pszArchive;
v3 = hidden;
v4 = GetFileAttributes(pszArchive);
if (v4 == -1)
dwFileAttributes = GetFileAttributes(pszArchive);
if (dwFileAttributes == INVALID_FILE_ATTRIBUTES)
return GetLastError() == ERROR_FILE_NOT_FOUND;
v6 = v3 != 0 ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0;
if (v4 == v6)
result = 1;
dwFileAttributesToSet = hidden ? FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN : 0;
if (dwFileAttributes == dwFileAttributesToSet)
return TRUE;
else
result = SetFileAttributes(v2, v6);
return result;
return SetFileAttributes(pszArchive, dwFileAttributesToSet);
}
void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar)

2
Source/mpqapi.h

@ -9,7 +9,7 @@ extern BOOLEAN save_archive_modified; // weak
extern _BLOCKENTRY *sgpBlockTbl;
extern BOOLEAN save_archive_open; // weak
BOOLEAN __fastcall mpqapi_set_hidden(char *pszArchive, BOOLEAN hidden);
BOOL __fastcall mpqapi_set_hidden(char *pszArchive, BOOL hidden);
void __fastcall mpqapi_store_creation_time(const char *pszArchive, int dwChar);
BOOLEAN __fastcall mpqapi_reg_load_modification_time(char *dst, int size);
void __fastcall mpqapi_xor_buf(char *pbData);

Loading…
Cancel
Save