mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
0f78403480
Summary: changes `overlay_` to be stored as a `std::shared_ptr` in order to safely create and pass `std::weak_ptr`s of the overlay to OverlayFiles that are being created. Reviewed By: chadaustin Differential Revision: D18302732 fbshipit-source-id: 495b613914771714ba8a8d1beb1c7a0cd72b33d4
45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <folly/Expected.h>
|
|
#include <folly/File.h>
|
|
#include <folly/portability/SysUio.h>
|
|
|
|
namespace folly {
|
|
class File;
|
|
}
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
class Overlay;
|
|
|
|
class OverlayFile {
|
|
public:
|
|
OverlayFile() = default;
|
|
explicit OverlayFile(folly::File file, std::weak_ptr<Overlay> overlay);
|
|
|
|
folly::Expected<struct stat, int> fstat() const;
|
|
folly::Expected<ssize_t, int> preadNoInt(void* buf, size_t n, off_t offset)
|
|
const;
|
|
folly::Expected<off_t, int> lseek(off_t offset, int whence) const;
|
|
folly::Expected<ssize_t, int>
|
|
pwritev(const iovec* iov, int iovcnt, off_t offset) const;
|
|
folly::Expected<int, int> ftruncate(off_t length) const;
|
|
folly::Expected<int, int> fsync() const;
|
|
folly::Expected<int, int> fdatasync() const;
|
|
folly::Expected<std::string, int> readFile() const;
|
|
|
|
private:
|
|
folly::File file_;
|
|
std::weak_ptr<Overlay> overlay_;
|
|
};
|
|
} // namespace eden
|
|
} // namespace facebook
|