mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Factor FDHandle out of the bytecode reader into the FileUtilities.h support
routines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10642 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -194,3 +194,26 @@ bool llvm::MakeFileExecutable(const std::string &Filename) {
|
||||
bool llvm::MakeFileReadable(const std::string &Filename) {
|
||||
return AddPermissionsBits(Filename, 0444);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FDHandle class implementation
|
||||
//
|
||||
|
||||
FDHandle::~FDHandle() {
|
||||
if (FD != -1) close(FD);
|
||||
}
|
||||
|
||||
FDHandle &FDHandle::operator=(int fd) {
|
||||
if (FD != -1) close(FD);
|
||||
FD = fd;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
/// take - Take ownership of the file descriptor away from the FDHandle
|
||||
/// object, so that the file is not closed when the FDHandle is destroyed.
|
||||
int FDHandle::take() {
|
||||
int Ret = FD;
|
||||
FD = -1;
|
||||
return Ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user