return path;
}
-} // namespace
+} // namespace
TemporaryFile::TemporaryFile(StringPiece namePrefix,
fs::path dir,
}
}
+void TemporaryFile::close() {
+ if (::close(fd_) == -1) {
+ PLOG(ERROR) << "close failed";
+ }
+ fd_ = -1;
+}
+
const fs::path& TemporaryFile::path() const {
CHECK(scope_ != Scope::UNLINK_IMMEDIATELY);
DCHECK(!path_.empty());
return path_;
}
-TemporaryFile::~TemporaryFile() {
+void TemporaryFile::reset() {
if (fd_ != -1 && closeOnDestruction_) {
- if (close(fd_) == -1) {
- PLOG(ERROR) << "close failed";
+ if (::close(fd_) == -1) {
+ PLOG(ERROR) << "close failed (fd = " << fd_ << "): ";
}
}
}
}
+TemporaryFile::~TemporaryFile() {
+ reset();
+}
+
TemporaryDirectory::TemporaryDirectory(
StringPiece namePrefix,
fs::path dir,
return !hasPCREPatternMatch(pattern, target);
}
-} // namespace detail
+} // namespace detail
CaptureFD::CaptureFD(int fd, ChunkCob chunk_cob)
: chunkCob_(std::move(chunk_cob)), fd_(fd), readOffset_(0) {
return std::string(buf.get(), size);
}
-} // namespace test
-} // namespace folly
+} // namespace test
+} // namespace folly