sapling/eden/fs/utils/NfsSocket.cpp
Chad Austin a1bc268963 port Path and PathPiece from folly::StringPiece to std::string_view
Summary:
std::string_view has noexcept accessors and folly::Range doesn't, so
this allows us to make Path and PathPiece noexcept.

Reviewed By: kmancini

Differential Revision: D41145426

fbshipit-source-id: 046f6f6a532d8d0da8508ccf7896c914e19a25ec
2022-11-16 18:09:51 -08:00

28 lines
778 B
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "eden/fs/utils/NfsSocket.h"
#include <folly/Exception.h>
namespace facebook::eden {
folly::SocketAddress makeNfsSocket(std::optional<AbsolutePath> unixSocketPath) {
if (folly::kIsApple && unixSocketPath.has_value()) {
int rc = unlink(unixSocketPath->c_str());
if (rc != 0 && errno != ENOENT) {
folly::throwSystemError(
fmt::format("unable to remove socket file {}", *unixSocketPath));
}
return folly::SocketAddress::makeFromPath(unixSocketPath->view());
} else {
return folly::SocketAddress("127.0.0.1", 0);
}
}
} // namespace facebook::eden