Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
c19e325b
Commit
c19e325b
authored
Oct 25, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some tests for create_dir
parent
bd92c23a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
5 deletions
+16
-5
include/spdlog/details/file_helper-inl.h
include/spdlog/details/file_helper-inl.h
+2
-4
include/spdlog/details/os-inl.h
include/spdlog/details/os-inl.h
+6
-1
tests/test_create_dir.cpp
tests/test_create_dir.cpp
+8
-0
No files found.
include/spdlog/details/file_helper-inl.h
View file @
c19e325b
...
...
@@ -34,10 +34,8 @@ SPDLOG_INLINE void file_helper::open(const filename_t &fname, bool truncate)
for
(
int
tries
=
0
;
tries
<
open_tries_
;
++
tries
)
{
if
(
!
folder_name
.
empty
())
{
os
::
create_dir
(
folder_name
);
// will not created if already exists
}
// will not created if already exists or empty.
os
::
create_dir
(
folder_name
);
if
(
!
os
::
fopen_s
(
&
fd_
,
fname
,
mode
))
{
...
...
include/spdlog/details/os-inl.h
View file @
c19e325b
...
...
@@ -478,7 +478,7 @@ SPDLOG_INLINE bool mkdir_(const filename_t &path)
}
// create the given directory - and all directories leading to it
// return true on success
// return true on success
or if the directory already exists
SPDLOG_INLINE
bool
create_dir
(
filename_t
path
)
{
if
(
path_exists
(
path
))
...
...
@@ -486,6 +486,11 @@ SPDLOG_INLINE bool create_dir(filename_t path)
return
true
;
}
if
(
path
.
empty
())
{
return
false
;
}
#ifdef _WIN32
// support forward slash in windows
std
::
replace
(
path
.
begin
(),
path
.
end
(),
'/'
,
folder_sep
);
...
...
tests/test_create_dir.cpp
View file @
c19e325b
...
...
@@ -32,6 +32,14 @@ TEST_CASE("create_dir", "[create_dir]")
#endif
}
TEST_CASE
(
"create_invalid_dir"
,
"[create_dir]"
)
{
REQUIRE
(
create_dir
(
""
)
==
false
);
#ifdef __linux__
REQUIRE
(
create_dir
(
"/proc/spdlog-utest"
)
==
false
);
#endif
}
TEST_CASE
(
"dir_name"
,
"[create_dir]"
)
{
using
spdlog
::
details
::
os
::
dir_name
;
...
...
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