mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
added helper library
This commit is contained in:
parent
b5bde83c14
commit
de27b90ae4
|
@ -32,6 +32,18 @@ add_sapi_library(
|
|||
|
||||
FUNCTIONS
|
||||
archive_read_new
|
||||
archive_write_disk_new
|
||||
archive_write_disk_set_options
|
||||
archive_read_support_filter_bzip2
|
||||
archive_read_support_filter_gzip
|
||||
archive_read_support_filter_compress
|
||||
archive_read_support_format_tar
|
||||
archive_read_support_format_cpio
|
||||
archive_write_disk_set_standard_lookup
|
||||
archive_read_open_filename
|
||||
archive_error_string
|
||||
archive_read_next_header
|
||||
archive_entry_pathname
|
||||
|
||||
INPUTS libarchive/libarchive/archive.h
|
||||
LIBRARY archive
|
||||
|
|
|
@ -12,6 +12,18 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
add_library(helpers STATIC
|
||||
helpers.h
|
||||
helpers.cc
|
||||
)
|
||||
|
||||
target_link_libraries(helpers PUBLIC
|
||||
sapi::sapi
|
||||
sandbox2::fileops
|
||||
sandbox2::util
|
||||
)
|
||||
|
||||
# small example - todo delete later
|
||||
add_executable(small_example
|
||||
small_example.cc
|
||||
|
@ -19,6 +31,7 @@ add_executable(small_example
|
|||
|
||||
target_link_libraries(small_example PRIVATE
|
||||
archive
|
||||
helpers
|
||||
)
|
||||
|
||||
add_executable(sapi_example
|
||||
|
|
13
oss-internship-2020/sapi_libarchive/examples/helpers.cc
Normal file
13
oss-internship-2020/sapi_libarchive/examples/helpers.cc
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
#include "helpers.h"
|
||||
|
||||
std::vector<std::string> MakeAbsolutePaths(char *argv[]) {
|
||||
std::vector<std::string> arr;
|
||||
sandbox2::util::CharPtrArrToVecString(argv, &arr);
|
||||
// std::transform(arr.begin(), arr.end(), arr.begin(), [](std::string s) -> std::string {
|
||||
// return sandbox2::file_util::fileops::MakeAbsolute(s, sandbox2::file_util::fileops::GetCWD());
|
||||
// });
|
||||
auto f = std::bind(sandbox2::file_util::fileops::MakeAbsolute, std::placeholders::_1, sandbox2::file_util::fileops::GetCWD());
|
||||
std::transform(arr.begin(), arr.end(), arr.begin(), f);
|
||||
return arr;
|
||||
}
|
13
oss-internship-2020/sapi_libarchive/examples/helpers.h
Normal file
13
oss-internship-2020/sapi_libarchive/examples/helpers.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef SAPI_LIBARCHIVE_HELPERS_H
|
||||
#define SAPI_LIBARCHIVE_HELPERS_H
|
||||
|
||||
#include "sandboxed_api/sandbox2/util/fileops.h"
|
||||
#include "sandboxed_api/sandbox2/util.h"
|
||||
|
||||
|
||||
// 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
|
||||
std::vector<std::string> MakeAbsolutePaths(char *argv[]);
|
||||
|
||||
#endif // SAPI_LIBARCHIVE_HELPERS_H
|
|
@ -2,8 +2,15 @@
|
|||
|
||||
#include <archive.h>
|
||||
#include <archive_entry.h>
|
||||
#include "helpers.h"
|
||||
|
||||
int main() {
|
||||
int main(int argc, char *argv[]) {
|
||||
std::cout << "WORKS" << std::endl;
|
||||
std::vector<std::string> s = MakeAbsolutePaths(argv + 1);
|
||||
std::cout << "ok" << std::endl;
|
||||
for (const auto &i : s) {
|
||||
std::cout << i << std::endl;
|
||||
}
|
||||
std::cout << "==========" << std::endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user