// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: fileutl.cc,v 1.9 1998/10/20 02:39:28 jgg Exp $
+// $Id: fileutl.cc,v 1.13 1998/10/26 07:11:49 jgg Exp $
/* ######################################################################
File Utilities
// CopyFile - Buffered copy of a file /*{{{*/
// ---------------------------------------------------------------------
/* The caller is expected to set things so that failure causes erasure */
-bool CopyFile(FileFd From,FileFd To)
+bool CopyFile(FileFd &From,FileFd &To)
{
if (From.IsOpen() == false || To.IsOpen() == false)
return false;
/* */
void SetNonBlock(int Fd,bool Block)
{
- int Flags = fcntl(Fd,F_GETFL);
- if (fcntl(Fd,F_SETFL,(Block == false)?0:O_NONBLOCK) != 0)
+ int Flags = fcntl(Fd,F_GETFL) & (~O_NONBLOCK);
+ if (fcntl(Fd,F_SETFL,Flags | ((Block == false)?0:O_NONBLOCK)) != 0)
{
cerr << "FATAL -> Could not set non-blocking flag " << strerror(errno) << endl;
exit(100);
fd_set Set;
FD_ZERO(&Set);
FD_SET(Fd,&Set);
+
if (select(Fd+1,&Set,0,0,0) <= 0)
return false;
+
return true;
}
/*}}}*/
if (iFd < 0)
_error->Errno("open","Could not open file %s",FileName.c_str());
else
+ {
this->FileName = FileName;
- SetCloseExec(iFd,true);
+ SetCloseExec(iFd,true);
+ }
}
/*}}}*/
// FileFd::~File - Closes the file /*{{{*/