Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
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
UERANSIM
Commits
155cddc1
Commit
155cddc1
authored
Feb 11, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IO utils improvement
parent
735cd3b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
src/utils/io.cpp
src/utils/io.cpp
+18
-0
src/utils/io.hpp
src/utils/io.hpp
+4
-0
No files found.
src/utils/io.cpp
View file @
155cddc1
...
...
@@ -8,6 +8,7 @@
#include "io.hpp"
#include <filesystem>
#include <fstream>
#include <ostream>
...
...
@@ -23,4 +24,21 @@ std::string ReadAllText(const std::string &file)
return
content
;
}
void
CreateDirectory
(
const
std
::
string
&
path
)
{
if
(
!
std
::
filesystem
::
exists
(
path
))
{
if
(
!
std
::
filesystem
::
is_directory
(
path
))
throw
std
::
runtime_error
(
"Required path '"
+
path
+
"' exists but not a directory."
);
std
::
filesystem
::
create_directory
(
path
);
std
::
filesystem
::
permissions
(
path
,
std
::
filesystem
::
perms
::
all
);
}
}
bool
Exists
(
const
std
::
string
&
path
)
{
return
std
::
filesystem
::
exists
(
path
);
}
}
// namespace io
src/utils/io.hpp
View file @
155cddc1
...
...
@@ -11,6 +11,10 @@
namespace
io
{
void
CreateDirectory
(
const
std
::
string
&
path
);
std
::
string
ReadAllText
(
const
std
::
string
&
file
);
bool
Exists
(
const
std
::
string
&
path
);
}
// namespace io
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