mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 16:57:49 +03:00
b708ee6953
Summary: In the case that the overlay was closed before the initial createOverlayFile, prevent an invalid OverlayFile from being accessed, causing the test to fail. Reviewed By: genevievehelsel Differential Revision: D19591636 fbshipit-source-id: 9d961f044c3b68b5c0b2dcd108ff85db6326276d
51 lines
1.3 KiB
C++
51 lines
1.3 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);
|
|
|
|
OverlayFile(OverlayFile&&) = default;
|
|
OverlayFile& operator=(OverlayFile&&) = default;
|
|
|
|
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:
|
|
OverlayFile(const OverlayFile&) = delete;
|
|
OverlayFile& operator=(const OverlayFile&) = delete;
|
|
|
|
folly::File file_;
|
|
std::weak_ptr<Overlay> overlay_;
|
|
};
|
|
} // namespace eden
|
|
} // namespace facebook
|