Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
74aede0c
Commit
74aede0c
authored
Jul 30, 2016
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better support for file size in 64 bits
parent
730f0e02
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
22 deletions
+18
-22
file_helper.h
include/spdlog/details/file_helper.h
+1
-3
os.h
include/spdlog/details/os.h
+17
-19
No files found.
include/spdlog/details/file_helper.h
View file @
74aede0c
...
...
@@ -100,9 +100,7 @@ public:
{
if
(
!
_fd
)
throw
spdlog_ex
(
"Cannot use size() on closed file "
+
os
::
filename_to_str
(
_filename
));
return
os
::
filesize
(
_fd
);
return
os
::
filesize
(
_fd
);
}
const
filename_t
&
filename
()
const
...
...
include/spdlog/details/os.h
View file @
74aede0c
...
...
@@ -186,43 +186,41 @@ inline bool file_exists(const filename_t& filename)
#endif
}
//Return file size according to open FILE* object
inline
size_t
filesize
(
FILE
*
f
)
{
if
(
f
==
nullptr
)
throw
spdlog_ex
(
"Failed getting file size. fd is null"
);
#ifdef _WIN32
#if _WIN64 //64 bits
int
fd
=
_fileno
(
f
);
#if _WIN64 //64 bits
struct
_stat64
st
;
if
(
_fstat64
(
fd
,
&
st
)
==
0
)
return
st
.
st_size
;
else
throw
spdlog_ex
(
"Failed getting file size from fd"
,
errno
);
#else //windows 32 bits
int
fd
=
_fileno
(
f
);
#else //windows 32 bits
struct
_stat
st
;
if
(
_fstat
(
fd
,
&
st
)
==
0
)
return
st
.
st_size
;
else
throw
spdlog_ex
(
"Failed getting file size from fd"
,
errno
);
#endif
#else// common unix
#if __x86_64__ || __ppc64__ //64 bits
int
fd
=
fileno
(
f
)
#else // unix
int
fd
=
fileno
(
f
);
//64 bits(but not in osx, where fstat64 is deprecated)
#if !defined(__APPLE__) && (defined(__x86_64__) || defined(__ppc64__))
struct
stat64
st
;
if
(
fstat64
(
fd
,
&
st
)
==
0
)
return
st
.
st_size
;
else
throw
spdlog_ex
(
"Failed getting file size from fd"
,
errno
);
#else //unix 32 bits
int
fd
=
fileno
(
f
)
struct
stat
st
;
return
st
.
st_size
;
#else // unix 32 bits or osx
struct
stat
st
;
if
(
fstat
(
fd
,
&
st
)
==
0
)
return
st
.
st_size
;
else
throw
spdlog_ex
(
"Failed getting file size from fd"
,
errno
);
return
st
.
st_size
;
#endif
#endif
throw
spdlog_ex
(
"Failed getting file size from fd"
,
errno
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment