|
@@ -2401,7 +2401,7 @@ FileFd::~FileFd()
|
|
|
gracefully. */
|
|
gracefully. */
|
|
|
bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
|
|
bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
ssize_t Res = 1;
|
|
ssize_t Res = 1;
|
|
|
errno = 0;
|
|
errno = 0;
|
|
@@ -2452,7 +2452,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
|
|
|
char* FileFd::ReadLine(char *To, unsigned long long const Size)
|
|
char* FileFd::ReadLine(char *To, unsigned long long const Size)
|
|
|
{
|
|
{
|
|
|
*To = '\0';
|
|
*To = '\0';
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return nullptr;
|
|
return nullptr;
|
|
|
return d->InternalReadLine(To, Size);
|
|
return d->InternalReadLine(To, Size);
|
|
|
}
|
|
}
|
|
@@ -2460,6 +2460,8 @@ char* FileFd::ReadLine(char *To, unsigned long long const Size)
|
|
|
// FileFd::Flush - Flush the file /*{{{*/
|
|
// FileFd::Flush - Flush the file /*{{{*/
|
|
|
bool FileFd::Flush()
|
|
bool FileFd::Flush()
|
|
|
{
|
|
{
|
|
|
|
|
+ if (Failed())
|
|
|
|
|
+ return false;
|
|
|
if (d == nullptr)
|
|
if (d == nullptr)
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
@@ -2469,7 +2471,7 @@ bool FileFd::Flush()
|
|
|
// FileFd::Write - Write to the file /*{{{*/
|
|
// FileFd::Write - Write to the file /*{{{*/
|
|
|
bool FileFd::Write(const void *From,unsigned long long Size)
|
|
bool FileFd::Write(const void *From,unsigned long long Size)
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
ssize_t Res = 1;
|
|
ssize_t Res = 1;
|
|
|
errno = 0;
|
|
errno = 0;
|
|
@@ -2525,7 +2527,7 @@ bool FileFd::Write(int Fd, const void *From, unsigned long long Size)
|
|
|
// FileFd::Seek - Seek in the file /*{{{*/
|
|
// FileFd::Seek - Seek in the file /*{{{*/
|
|
|
bool FileFd::Seek(unsigned long long To)
|
|
bool FileFd::Seek(unsigned long long To)
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
Flags &= ~HitEof;
|
|
Flags &= ~HitEof;
|
|
|
return d->InternalSeek(To);
|
|
return d->InternalSeek(To);
|
|
@@ -2534,7 +2536,7 @@ bool FileFd::Seek(unsigned long long To)
|
|
|
// FileFd::Skip - Skip over data in the file /*{{{*/
|
|
// FileFd::Skip - Skip over data in the file /*{{{*/
|
|
|
bool FileFd::Skip(unsigned long long Over)
|
|
bool FileFd::Skip(unsigned long long Over)
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
return d->InternalSkip(Over);
|
|
return d->InternalSkip(Over);
|
|
|
}
|
|
}
|
|
@@ -2542,7 +2544,7 @@ bool FileFd::Skip(unsigned long long Over)
|
|
|
// FileFd::Truncate - Truncate the file /*{{{*/
|
|
// FileFd::Truncate - Truncate the file /*{{{*/
|
|
|
bool FileFd::Truncate(unsigned long long To)
|
|
bool FileFd::Truncate(unsigned long long To)
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
// truncating /dev/null is always successful - as we get an error otherwise
|
|
// truncating /dev/null is always successful - as we get an error otherwise
|
|
|
if (To == 0 && FileName == "/dev/null")
|
|
if (To == 0 && FileName == "/dev/null")
|
|
@@ -2555,7 +2557,7 @@ bool FileFd::Truncate(unsigned long long To)
|
|
|
/* */
|
|
/* */
|
|
|
unsigned long long FileFd::Tell()
|
|
unsigned long long FileFd::Tell()
|
|
|
{
|
|
{
|
|
|
- if (d == nullptr)
|
|
|
|
|
|
|
+ if (d == nullptr || Failed())
|
|
|
return false;
|
|
return false;
|
|
|
off_t const Res = d->InternalTell();
|
|
off_t const Res = d->InternalTell();
|
|
|
if (Res == (off_t)-1)
|
|
if (Res == (off_t)-1)
|
|
@@ -2618,7 +2620,7 @@ time_t FileFd::ModificationTime()
|
|
|
unsigned long long FileFd::Size()
|
|
unsigned long long FileFd::Size()
|
|
|
{
|
|
{
|
|
|
if (d == nullptr)
|
|
if (d == nullptr)
|
|
|
- return false;
|
|
|
|
|
|
|
+ return 0;
|
|
|
return d->InternalSize();
|
|
return d->InternalSize();
|
|
|
}
|
|
}
|
|
|
/*}}}*/
|
|
/*}}}*/
|