Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
b52e50a3
Commit
b52e50a3
authored
Jul 02, 2015
by
Davis King
Browse files
Added a .revert() to the locally_change_current_dir object.
parent
48444811
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
dlib/misc_api/misc_api_kernel_abstract.h
dlib/misc_api/misc_api_kernel_abstract.h
+10
-1
dlib/misc_api/misc_api_shared.h
dlib/misc_api/misc_api_shared.h
+13
-1
No files found.
dlib/misc_api/misc_api_kernel_abstract.h
View file @
b52e50a3
...
@@ -90,7 +90,16 @@ namespace dlib
...
@@ -90,7 +90,16 @@ namespace dlib
);
);
/*!
/*!
ensures
ensures
- calls set_current_dir(old_dir())
- if (revert() hasn't already been called) then
- calls set_current_dir(old_dir())
!*/
void
revert
(
);
/*!
ensures
- if (revert() hasn't already been called) then
- calls set_current_dir(old_dir())
!*/
!*/
};
};
...
...
dlib/misc_api/misc_api_shared.h
View file @
b52e50a3
...
@@ -18,13 +18,14 @@ namespace dlib
...
@@ -18,13 +18,14 @@ namespace dlib
const
std
::
string
&
new_dir
const
std
::
string
&
new_dir
)
)
{
{
reverted
=
false
;
_old_dir
=
get_current_dir
();
_old_dir
=
get_current_dir
();
set_current_dir
(
new_dir
);
set_current_dir
(
new_dir
);
}
}
~
locally_change_current_dir
()
~
locally_change_current_dir
()
{
{
set_current_dir
(
_old_dir
);
revert
(
);
}
}
const
std
::
string
&
old_dir
(
const
std
::
string
&
old_dir
(
...
@@ -33,7 +34,18 @@ namespace dlib
...
@@ -33,7 +34,18 @@ namespace dlib
return
_old_dir
;
return
_old_dir
;
}
}
void
revert
(
)
{
if
(
!
reverted
)
{
set_current_dir
(
_old_dir
);
reverted
=
true
;
}
}
private:
private:
bool
reverted
;
std
::
string
_old_dir
;
std
::
string
_old_dir
;
};
};
...
...
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