Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakub Janák
tss
Commits
f67893fd
Commit
f67893fd
authored
3 months ago
by
Jakub Janák
Browse files
Options
Downloads
Patches
Plain Diff
added todo for refactoring the read dot file method
parent
a970a0fa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/file_manager.cpp
+13
-4
13 additions, 4 deletions
files/file_manager.cpp
with
13 additions
and
4 deletions
files/file_manager.cpp
+
13
−
4
View file @
f67893fd
...
...
@@ -13,6 +13,7 @@ const std::string file_manager::INSTANCES_PATH = "../files/instances";
const
std
::
string
file_manager
::
RESULTS_PATH
=
"../files/results"
;
// TODO: refactor the read dot file
std
::
unique_ptr
<
ts_instance
>
file_manager
::
read_dot_file
(
const
std
::
string
&
file_name
)
{
// graphviz context
GVC_t
*
gvc
=
gvContext
();
...
...
@@ -95,8 +96,7 @@ std::vector<std::filesystem::directory_entry> file_manager::get_dot_instances(co
return
entries
;
}
void
file_manager
::
save_solution
(
const
std
::
string
&
file_name
,
const
std
::
string
&
file_content
)
{
// creating the results folder if not exists
void
file_manager
::
folder_exists_check
()
{
if
(
!
std
::
filesystem
::
exists
(
RESULTS_PATH
))
{
if
(
std
::
filesystem
::
create_directory
(
RESULTS_PATH
))
{
std
::
cout
<<
"Created results directory: "
<<
RESULTS_PATH
<<
std
::
endl
;
...
...
@@ -104,15 +104,24 @@ void file_manager::save_solution(const std::string &file_name, const std::string
std
::
cout
<<
"Error creating results directory: "
<<
RESULTS_PATH
<<
std
::
endl
;
}
}
}
// check for
output
file
conflicts
void
file_manager
::
file_naming_conflicts_check
(
const
std
::
string
&
file_name
,
std
::
string
&
output
_
file
)
{
int
num
=
1
;
std
::
string
output_file
;
do
{
std
::
string
number_string
=
(
num
==
1
)
?
""
:
"_"
+
std
::
to_string
(
num
);
output_file
=
RESULTS_PATH
+
"/"
+
file_name
+
number_string
+
".dot"
;
num
++
;
}
while
(
std
::
filesystem
::
exists
(
output_file
));
}
void
file_manager
::
save_solution
(
const
std
::
string
&
file_name
,
const
std
::
string
&
file_content
)
{
// creating the results folder if not exists
folder_exists_check
();
// check for output file conflicts
std
::
string
output_file
;
file_naming_conflicts_check
(
file_name
,
output_file
);
// Check if the file is open
if
(
std
::
ofstream
outFile
(
output_file
);
outFile
.
is_open
())
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment