2020-09-09 20:02:40 +08:00
|
|
|
#ifndef SAPI_LIBARCHIVE_HELPERS_H
|
|
|
|
#define SAPI_LIBARCHIVE_HELPERS_H
|
|
|
|
|
2020-09-14 22:39:16 +08:00
|
|
|
#include <glog/logging.h>
|
2020-09-16 23:57:31 +08:00
|
|
|
|
|
|
|
#include "libarchive_sapi.sapi.h"
|
2020-09-09 20:02:40 +08:00
|
|
|
#include "sandboxed_api/sandbox2/util.h"
|
2020-09-14 22:39:16 +08:00
|
|
|
#include "sandboxed_api/sandbox2/util/fileops.h"
|
|
|
|
#include "sandboxed_api/sandbox2/util/path.h"
|
2020-09-21 21:30:43 +08:00
|
|
|
#include "sandboxed_api/sandbox2/util/temp_file.h"
|
2020-09-09 20:02:40 +08:00
|
|
|
|
2020-09-23 02:30:07 +08:00
|
|
|
inline constexpr size_t kBlockSize = 10240;
|
|
|
|
inline constexpr size_t kBuffSize = 16384;
|
|
|
|
|
2020-09-09 20:02:40 +08:00
|
|
|
// Used to convert the paths provided as arguments for the program
|
|
|
|
// (the paths used) to an array of absolute paths. This allows the user
|
|
|
|
// to use either relative or absolute paths
|
2020-09-23 02:30:07 +08:00
|
|
|
std::vector<std::string> MakeAbsolutePathsVec(const char* argv[]);
|
2020-09-14 22:39:16 +08:00
|
|
|
|
2020-09-16 23:57:31 +08:00
|
|
|
// Converts only one string to an absolute path by prepending the current
|
|
|
|
// working directory to the relative path
|
2020-09-23 02:30:07 +08:00
|
|
|
std::string MakeAbsolutePathAtCWD(const std::string& path);
|
2020-09-14 22:39:16 +08:00
|
|
|
|
2020-09-23 02:30:07 +08:00
|
|
|
// This function takes a status as argument and after checking the status
|
|
|
|
// it transfers the string. This is used mostly with archive_error_string
|
|
|
|
// and other library functions that return a char *.
|
2020-09-25 02:47:19 +08:00
|
|
|
std::string CheckStatusAndGetString(const absl::StatusOr<char*>& status,
|
2020-09-23 02:30:07 +08:00
|
|
|
LibarchiveSandbox& sandbox);
|
2020-09-09 20:02:40 +08:00
|
|
|
|
2020-09-23 02:30:07 +08:00
|
|
|
// Creates a temporary directory in the current working directory and
|
|
|
|
// returns the path. This is used in the extract function where the sandbox
|
|
|
|
// changes the current working directory to this temporary directory.
|
2020-09-21 21:30:43 +08:00
|
|
|
std::string CreateTempDirAtCWD();
|
|
|
|
|
2020-09-09 20:02:40 +08:00
|
|
|
#endif // SAPI_LIBARCHIVE_HELPERS_H
|