initial commit

This commit is contained in:
Danielle Rozenblit
2023-01-04 13:01:54 -08:00
parent ef566c8d68
commit 908e812733
328 changed files with 3340 additions and 1426 deletions
+5 -3
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-present, Facebook, Inc.
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
@@ -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;