1
0
mirror of https://github.com/facebook/zstd.git synced 2025-08-08 17:22:10 +03:00

[pzstd] Fixes for Windows build

* Add `Portability.h` to fix min/max issues.
* Fix conversion warnings
* Assert that windowLog <= 23, which is currently always the case.
  This could be loosened, but we aren't looking to add new functionality.

Fixes on top of PR #3375 by @eli-schwartz, which added Windows CI for contrib & programs.
This commit is contained in:
Nick Terrell
2022-12-19 12:23:29 -08:00
committed by Nick Terrell
parent 67cd24b25b
commit e9797b5dc5
4 changed files with 30 additions and 3 deletions

View File

@@ -8,11 +8,13 @@
*/
#pragma once
#include "utils/Portability.h"
#include "utils/Range.h"
#include <sys/stat.h>
#include <cerrno>
#include <cstdint>
#include <limits>
#include <system_error>
// A small subset of `std::filesystem`.
@@ -82,11 +84,11 @@ inline std::uintmax_t file_size(
std::error_code& ec) noexcept {
auto stat = status(path, ec);
if (ec) {
return -1;
return std::numeric_limits<uintmax_t>::max();
}
if (!is_regular_file(stat)) {
ec.assign(ENOTSUP, std::generic_category());
return -1;
return std::numeric_limits<uintmax_t>::max();
}
ec.clear();
return stat.st_size;