git-svn-id: https://profuse.googlecode.com/svn/branches/v2@230 aa027e90-d47c-11dd-86d7-074df07e0730

This commit is contained in:
ksherlock
2010-05-19 23:47:32 +00:00
parent 6dd25c9be5
commit 4fe15a8e99
2 changed files with 12 additions and 0 deletions

View File

@@ -71,11 +71,21 @@ void File::close()
void File::adopt(File &f) void File::adopt(File &f)
{ {
if (&f == this) return;
close(); close();
_fd = f._fd; _fd = f._fd;
f._fd = -1; f._fd = -1;
} }
void File::adopt(int fd)
{
if (fd == _fd) return;
close();
_fd = fd;
}
void File::swap(File &f) void File::swap(File &f)
{ {
std::swap(_fd, f._fd); std::swap(_fd, f._fd);

View File

@@ -26,6 +26,8 @@ class File {
void close(); void close();
void adopt(File &f); void adopt(File &f);
void adopt(int fd);
void swap(File &f); void swap(File &f);
private: private: