mirror of
https://github.com/leozide/leocad
synced 2025-01-30 20:34:56 +01:00
Merge pull request #37 from j6t/master
Determine file size only of regular files.
This commit is contained in:
commit
9c0c8ade38
1 changed files with 5 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
#include "lc_file.h"
|
#include "lc_file.h"
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
@ -210,14 +211,11 @@ void lcDiskFile::SetLength(size_t NewLength)
|
||||||
|
|
||||||
size_t lcDiskFile::GetLength() const
|
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);
|
return st.st_size;
|
||||||
fseek(mFile, 0, SEEK_END);
|
|
||||||
Length = ftell(mFile);
|
|
||||||
fseek(mFile, Current, SEEK_SET);
|
|
||||||
|
|
||||||
return Length;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void lcDiskFile::Flush()
|
void lcDiskFile::Flush()
|
||||||
|
|
Loading…
Add table
Reference in a new issue