Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LEFEBVREJP email
radix
Commits
8b4804f4
Commit
8b4804f4
authored
Jun 14, 2018
by
LEFEBVREJP email
Browse files
Merge branch 'system-copy' into 'master'
System copy See merge request
!38
parents
7abb14ef
7d5954bb
Pipeline
#13790
passed with stages
in 18 minutes and 42 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
radixcore/system.cc
View file @
8b4804f4
...
...
@@ -6,6 +6,7 @@
*/
#include <algorithm>
#include <array>
#include <cstdarg>
#include <cstdio>
#include <cstring>
...
...
@@ -393,6 +394,29 @@ std::string search_env_path(const std::string &filename)
return
std
::
string
();
}
std
::
string
system_copy
(
const
std
::
string
&
source
,
const
std
::
string
&
destination
)
{
std
::
string
copy_command
;
#ifdef _WIN32
copy_command
=
"copy"
;
#else
copy_command
=
"cp"
;
#endif
std
::
string
command
=
copy_command
+
std
::
string
(
" "
)
+
source
+
std
::
string
(
" "
)
+
destination
;
FILE
*
handle
=
pipe_open
(
command
);
std
::
array
<
char
,
128
>
buf
;
std
::
string
output
;
while
(
fgets
(
buf
.
data
(),
int
(
buf
.
size
()),
handle
)
!=
NULL
)
{
output
+=
buf
.
data
();
}
radix
::
pipe_close
(
handle
);
return
output
;
}
// remove_file
}
// namespace radix
radixcore/system.hh
View file @
8b4804f4
...
...
@@ -16,6 +16,14 @@
namespace
radix
{
/**
* @brief system_copy Uses system copy command to copy source to destination
* @param source
* @param destination
* @return std::string output of command
*/
RADIX_PUBLIC
std
::
string
system_copy
(
const
std
::
string
&
source
,
const
std
::
string
&
destination
);
/**
* @brief Provides platform independent popen call
* function creates a pipe and asynchronously executes a spawned
...
...
radixcore/tests/tstSystem.cc
View file @
8b4804f4
...
...
@@ -224,3 +224,13 @@ TEST(System, SearchEnvPath)
std
::
string
path
=
search_env_path
(
app
);
EXPECT_EQ
(
blessed
,
radix
::
string_tolower
(
path
));
}
TEST
(
System
,
copy
)
{
std
::
string
this_file
(
__FILE__
);
// copy the unit test source file to the current working directory
radix
::
system_copy
(
this_file
,
radix
::
current_dir
());
EXPECT_TRUE
(
radix
::
file_exists
(
radix
::
basename
(
this_file
)));
radix
::
remove_file
(
radix
::
basename
(
this_file
));
EXPECT_FALSE
(
radix
::
file_exists
(
basename
(
this_file
)));
}
\ No newline at end of file
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