| ... | @@ -23,6 +23,14 @@ | ... | @@ -23,6 +23,14 @@ |
| 23 | #define WIN32_LEAN_AND_MEAN | 23 | #define WIN32_LEAN_AND_MEAN |
| 24 | #endif | 24 | #endif |
| 25 | | 25 | |
| | 26 | #if !defined(_WIN32_WINNT) |
| | 27 | #define _WIN32_WINNT 0x600 |
| | 28 | #endif |
| | 29 | |
| | 30 | #if !defined(NTDDI_VERSION) |
| | 31 | #define NTDDI_VERSION 0x06000000 |
| | 32 | #endif |
| | 33 | |
| 26 | #include <windows.h> | 34 | #include <windows.h> |
| 27 | #include <shlobj.h> | 35 | #include <shlobj.h> |
| 28 | #include <io.h> | 36 | #include <io.h> |
| ... | @@ -1634,16 +1642,16 @@ static Optional<uint32_t> Utf16LeIterator_nextCodepoint(Utf16LeIterator *it) { | ... | @@ -1634,16 +1642,16 @@ static Optional<uint32_t> Utf16LeIterator_nextCodepoint(Utf16LeIterator *it) { |
| 1634 | if (it->bytes[it->i] == 0 && it->bytes[it->i + 1] == 0) | 1642 | if (it->bytes[it->i] == 0 && it->bytes[it->i + 1] == 0) |
| 1635 | return {}; | 1643 | return {}; |
| 1636 | uint32_t c0 = ((uint32_t)it->bytes[it->i]) | (((uint32_t)it->bytes[it->i + 1]) << 8); | 1644 | uint32_t c0 = ((uint32_t)it->bytes[it->i]) | (((uint32_t)it->bytes[it->i + 1]) << 8); |
| 1637 | if (c0 & ~((uint32_t)0x03ff) == 0xd800) { | 1645 | if ((c0 & ~((uint32_t)0x03ff)) == 0xd800) { |
| 1638 | // surrogate pair | 1646 | // surrogate pair |
| 1639 | it->i += 2; | 1647 | it->i += 2; |
| 1640 | assert(it->bytes[it->i] != 0 || it->bytes[it->i + 1] != 0); | 1648 | assert(it->bytes[it->i] != 0 || it->bytes[it->i + 1] != 0); |
| 1641 | uint32_t c1 = ((uint32_t)it->bytes[it->i]) | (((uint32_t)it->bytes[it->i + 1]) << 8); | 1649 | uint32_t c1 = ((uint32_t)it->bytes[it->i]) | (((uint32_t)it->bytes[it->i + 1]) << 8); |
| 1642 | assert(c1 & ~((uint32_t)0x03ff) == 0xdc00); | 1650 | assert((c1 & ~((uint32_t)0x03ff)) == 0xdc00); |
| 1643 | it->i += 2; | 1651 | it->i += 2; |
| 1644 | return Optional<uint32_t>::some(0x10000 + (((c0 & 0x03ff) << 10) | (c1 & 0x03ff))); | 1652 | return Optional<uint32_t>::some(0x10000 + (((c0 & 0x03ff) << 10) | (c1 & 0x03ff))); |
| 1645 | } else { | 1653 | } else { |
| 1646 | assert(c0 & ~((uint32_t)0x03ff) != 0xdc00); | 1654 | assert((c0 & ~((uint32_t)0x03ff)) != 0xdc00); |
| 1647 | it->i += 2; | 1655 | it->i += 2; |
| 1648 | return Optional<uint32_t>::some(c0); | 1656 | return Optional<uint32_t>::some(c0); |
| 1649 | } | 1657 | } |
| ... | @@ -1714,7 +1722,7 @@ static void utf16le_ptr_to_utf8(Buf *out, WCHAR *utf16le) { | ... | @@ -1714,7 +1722,7 @@ static void utf16le_ptr_to_utf8(Buf *out, WCHAR *utf16le) { |
| 1714 | // Ported from std.os.getAppDataDir | 1722 | // Ported from std.os.getAppDataDir |
| 1715 | Error os_get_app_data_dir(Buf *out_path, const char *appname) { | 1723 | Error os_get_app_data_dir(Buf *out_path, const char *appname) { |
| 1716 | #if defined(ZIG_OS_WINDOWS) | 1724 | #if defined(ZIG_OS_WINDOWS) |
| 1717 | Error err; | 1725 | // Error err; |
| 1718 | WCHAR *dir_path_ptr; | 1726 | WCHAR *dir_path_ptr; |
| 1719 | switch (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, nullptr, &dir_path_ptr)) { | 1727 | switch (SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_CREATE, nullptr, &dir_path_ptr)) { |
| 1720 | case S_OK: | 1728 | case S_OK: |
| ... | @@ -1928,7 +1936,8 @@ Error os_file_mtime(OsFile file, OsTimeStamp *mtime) { | ... | @@ -1928,7 +1936,8 @@ Error os_file_mtime(OsFile file, OsTimeStamp *mtime) { |
| 1928 | FILETIME last_write_time; | 1936 | FILETIME last_write_time; |
| 1929 | if (!GetFileTime(file, nullptr, nullptr, &last_write_time)) | 1937 | if (!GetFileTime(file, nullptr, nullptr, &last_write_time)) |
| 1930 | return ErrorUnexpected; | 1938 | return ErrorUnexpected; |
| 1931 | mtime->sec = last_write_time.dwLowDateTime | (last_write_time.dwHighDateTime << 32); | 1939 | // mtime->sec = last_write_time.dwLowDateTime | (last_write_time.dwHighDateTime << 32); |
| | 1940 | mtime->sec = (((ULONGLONG) last_write_time.dwHighDateTime) << 32) + last_write_time.dwLowDateTime; |
| 1932 | mtime->nsec = 0; | 1941 | mtime->nsec = 0; |
| 1933 | return ErrorNone; | 1942 | return ErrorNone; |
| 1934 | #elif defined(ZIG_OS_LINUX) | 1943 | #elif defined(ZIG_OS_LINUX) |
| ... | @@ -2007,11 +2016,12 @@ Error os_file_read_all(OsFile file, Buf *contents) { | ... | @@ -2007,11 +2016,12 @@ Error os_file_read_all(OsFile file, Buf *contents) { |
| 2007 | | 2016 | |
| 2008 | Error os_file_overwrite(OsFile file, Buf *contents) { | 2017 | Error os_file_overwrite(OsFile file, Buf *contents) { |
| 2009 | #if defined(ZIG_OS_WINDOWS) | 2018 | #if defined(ZIG_OS_WINDOWS) |
| | 2019 | DWORD bytes_written; |
| 2010 | if (SetFilePointer(file, 0, nullptr, FILE_BEGIN) == INVALID_SET_FILE_POINTER) | 2020 | if (SetFilePointer(file, 0, nullptr, FILE_BEGIN) == INVALID_SET_FILE_POINTER) |
| 2011 | return ErrorFileSystem; | 2021 | return ErrorFileSystem; |
| 2012 | if (!SetEndOfFile(file)) | 2022 | if (!SetEndOfFile(file)) |
| 2013 | return ErrorFileSystem; | 2023 | return ErrorFileSystem; |
| 2014 | if (!WriteFile(file, buf_ptr(contents), buf_len(contents), nullptr, nullptr)) | 2024 | if (!WriteFile(file, buf_ptr(contents), buf_len(contents), &bytes_written, nullptr)) |
| 2015 | return ErrorFileSystem; | 2025 | return ErrorFileSystem; |
| 2016 | return ErrorNone; | 2026 | return ErrorNone; |
| 2017 | #else | 2027 | #else |