少年修仙传客户端基础资源
hch
2024-04-01 d01413b00ef631ac20347716b23818b0b811f65f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "il2cpp-config.h"
 
#if IL2CPP_TARGET_WINDOWS_GAMES
 
#include "Win32ApiWindowsGamesEmulation.h"
 
#include "os/Win32/WindowsHeaders.h"
 
#undef GetFileAttributes
 
#include "os/File.h"
#include "utils/StringUtils.h"
 
namespace il2cpp
{
namespace os
{
    UnityPalFileAttributes File::GetFileAttributes(const std::string& path, int *error)
    {
        const UTF16String utf16Path(utils::StringUtils::Utf8ToUtf16(path.c_str()));
 
        // HACK: DLC api returns these funky long form UNC paths (\\?\GLOBALROOT\)
        // For some reason even though many of the file APIs on Xbox understand such a path
        // GetFileAttributesEx does not, so we check explicitly for such a path, and fake it.
        wchar_t * p = (wchar_t*)utf16Path.c_str();
        size_t len = wcslen(p);
        if (((len > 3 && (p[0] == L'\\' && p[1] == L'?'  && p[2] == L'\\'))
             || (len > 4 && (p[0] == L'\\' && p[1] == L'\\' && p[2] == L'?' && p[3] == L'\\'))
            ) && NULL != wcsstr(p, L"GLOBALROOT\\Device\\Harddisk"))
        {
            size_t diff = len - (wcsstr(p, L"Partition") - p);
            if (diff <= 11)
                return static_cast<UnityPalFileAttributes>(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_HIDDEN);
        }
 
        WIN32_FILE_ATTRIBUTE_DATA fileAttributes;
 
        BOOL result = ::GetFileAttributesExW((LPCWSTR)utf16Path.c_str(), GetFileExInfoStandard, &fileAttributes);
        if (result == FALSE)
        {
            *error = ::GetLastError();
            return static_cast<UnityPalFileAttributes>(INVALID_FILE_ATTRIBUTES);
        }
 
        *error = kErrorCodeSuccess;
        return static_cast<UnityPalFileAttributes>(fileAttributes.dwFileAttributes);
    }
} //os
} //il2cpp
 
 
#endif