bool ensure_parent_dir_created(const string&);
bool check_file(const string& path, ostream& out);
+
+size_t
+get_random_number();
+
+string
+get_random_number_as_string();
+
/// The different types of files understood the bi* suite of tools.
enum file_type
{
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <time.h>
#include <cstdlib>
#include <cstring>
#include <libgen.h>
#include <fstream>
#include <iostream>
+#include <sstream>
#include <abg-ir.h>
#include "abg-tools-utils.h"
return true;
}
+
+/// Get a pseudo random number.
+///
+/// @return a pseudo random number.
+size_t
+get_random_number()
+{
+ static __thread bool initialized = false;
+
+ if (!initialized)
+ {
+ srand(time(NULL));
+ initialized = true;
+ }
+
+ return rand();
+}
+
+/// Get a pseudo random number as string.
+///
+/// @return a pseudo random number as string.
+string
+get_random_number_as_string()
+{
+ std::ostringstream o;
+ o << get_random_number();
+
+ return o.str();
+}
+
ostream&
operator<<(ostream& output,
file_type r)
struct package
{
string path;
+ string extracted_package_parent_dir_path;
string extracted_package_dir_path;
abigail::tools_utils::file_type type;
bool is_debug_info;
extracted_package_dir_path = tmpdir;
else
extracted_package_dir_path = "/tmp";
- extracted_package_dir_path = extracted_package_dir_path + "/" + dir;
+
+ using abigail::tools_utils::get_random_number_as_string;
+
+ extracted_package_parent_dir_path = extracted_package_dir_path
+ + "/libabigail-tmp-dir-" + get_random_number_as_string();
+
+ extracted_package_dir_path = extracted_package_parent_dir_path + "/" + dir;
}
/// Erase the content of the temporary extraction directory that has
<< extracted_package_dir_path
<< " ...";
- string cmd = "rm -rf " + extracted_package_dir_path;
+ string cmd = "rm -rf " + extracted_package_parent_dir_path;
system(cmd.c_str());
if (verbose)
system(cmd.c_str());
- cmd = "mkdir " + extracted_package_dir_path + " && cd " +
+ cmd = "mkdir -p " + extracted_package_dir_path + " && cd " +
extracted_package_dir_path + " && rpm2cpio " + package_path +
" | cpio -dium --quiet";