refactor: use fstream in subprocess tests (#6733)
This commit is contained in:
parent
4ce8a02916
commit
b318bf8d9d
|
@ -7,8 +7,9 @@
|
||||||
#include <libtransmission/utils.h> // tr_env_get_string()
|
#include <libtransmission/utils.h> // tr_env_get_string()
|
||||||
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
|
#include <fmt/ostream.h>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <fstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
@ -22,8 +23,8 @@ int main(int argc, char** argv)
|
||||||
auto const test_action = std::string{ argv[2] };
|
auto const test_action = std::string{ argv[2] };
|
||||||
auto const tmp_result_path = result_path + ".tmp";
|
auto const tmp_result_path = result_path + ".tmp";
|
||||||
|
|
||||||
FILE* out = std::fopen(tmp_result_path.c_str(), "w+");
|
auto out = std::ofstream(tmp_result_path.c_str(), std::ios::out | std::ios::trunc | std::ios::binary);
|
||||||
if (out == nullptr)
|
if (!out)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -55,12 +56,12 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(void)std::fclose(out);
|
out.close();
|
||||||
(void)std::remove(tmp_result_path.c_str());
|
(void)std::remove(tmp_result_path.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)std::fclose(out);
|
out.close();
|
||||||
tr_sys_path_rename(tmp_result_path.c_str(), result_path.c_str());
|
tr_sys_path_rename(tmp_result_path.c_str(), result_path.c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue