Merge pull request #37 from j6t/master

Determine file size only of regular files.
This commit is contained in:
Leonardo Zide 2017-03-17 14:19:09 -07:00 committed by GitHub
commit 9c0c8ade38

View file

@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include "lc_file.h"
// =============================================================================
@ -210,14 +211,11 @@ void lcDiskFile::SetLength(size_t NewLength)
size_t lcDiskFile::GetLength() const
{
long Length, Current;
struct stat st;
if (fstat(fileno(mFile), &st) < 0 || !S_ISREG(st.st_mode))
return 0;
Current = ftell(mFile);
fseek(mFile, 0, SEEK_END);
Length = ftell(mFile);
fseek(mFile, Current, SEEK_SET);
return Length;
return st.st_size;
}
void lcDiskFile::Flush()