少年修仙传客户端基础资源
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "os/c-api/il2cpp-config-platforms.h"
 
#if IL2CPP_TARGET_DARWIN
#import <Foundation/Foundation.h>
 
#include "os/c-api/Allocator.h"
#include "os/TimeZoneInfo.h"
#include "mono-structs.h"
 
namespace il2cpp
{
namespace os
{
    bool TimeZoneInfo::UsePalForTimeZoneInfo()
    {
        return true;
    }
 
    void* TimeZoneInfo::GetTimeZoneIDs()
    {
        @autoreleasepool
        {
            NSArray* nsarray = [NSTimeZone knownTimeZoneNames];
            int count = nsarray.count;
 
            VoidPtrArray timezoneIDsArray;
            for (int i = 0; i < count; i++)
            {
                NSString* zone = [nsarray objectAtIndex: i];
                char* zoneName = Allocator::CopyToAllocatedStringBuffer(zone.UTF8String);
                timezoneIDsArray.push_back(zoneName);
            }
            return (void*)void_ptr_array_to_gptr_array(timezoneIDsArray);
        }
    }
 
    bool TimeZoneInfo::GetLocalTimeZoneData(void** nativeRawData, char** nativeID, int* size)
    {
        @autoreleasepool
        {
            *nativeRawData = NULL;
            *nativeID = NULL;
            *size = 0;
 
            NSTimeZone* TZ = [NSTimeZone localTimeZone];
            NSString* TzName = [TZ name];
 
            char* localTimeZoneName = (char*)TzName.UTF8String;
            if (!GetTimeZoneDataForID(localTimeZoneName, nativeRawData, size))
            {
                return false;
            }
 
            *nativeID = Allocator::CopyToAllocatedStringBuffer(localTimeZoneName);
 
            return true;
        }
    }
 
    bool TimeZoneInfo::GetTimeZoneDataForID(char* id, void** nativeRawData, int* size)
    {
        @autoreleasepool
        {
            *nativeRawData = NULL;
            *size = 0;
 
            NSString *timeZoneName = [[NSString alloc] initWithUTF8String: id];
            NSTimeZone* timeZone = [[NSTimeZone alloc] initWithName: timeZoneName];
 
            if (timeZone)
            {
                NSData *timeZoneData = [timeZone data];
                *size = [timeZoneData length];
                *nativeRawData = Allocator::Allocate(*size);
                memcpy(*nativeRawData, timeZoneData.bytes, *size);
                return true;
            }
            return false;
        }
    }
}
}
 
#endif