blob: cda405c2a11a9996c67af138c6992099eff31436 [file] [log] [blame]
bigbiff1f9e4842020-10-31 11:33:15 -04001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef _OTAUTIL_ZIPUTIL_H
18#define _OTAUTIL_ZIPUTIL_H
19
20#include <utime.h>
21
22#include <string>
23
24#include <selinux/label.h>
25#include <ziparchive/zip_archive.h>
26
27/*
28 * Inflate all files under zip_path to the directory specified by
29 * dest_path, which must exist and be a writable directory. The zip_path
30 * is allowed to be an empty string, in which case the whole package
31 * will be extracted.
32 *
33 * Directory entries are not extracted.
34 *
35 * The immediate children of zip_path will become the immediate
36 * children of dest_path; e.g., if the archive contains the entries
37 *
38 * a/b/c/one
39 * a/b/c/two
40 * a/b/c/d/three
41 *
42 * and ExtractPackageRecursive(a, "a/b/c", "/tmp", ...) is called, the resulting
43 * files will be
44 *
45 * /tmp/one
46 * /tmp/two
47 * /tmp/d/three
48 *
49 * If timestamp is non-NULL, file timestamps will be set accordingly.
50 *
51 * Returns true on success, false on failure.
52 */
53bool ExtractPackageRecursive(ZipArchiveHandle zip, const std::string& zip_path,
54 const std::string& dest_path, const struct utimbuf* timestamp,
55 struct selabel_handle* sehnd);
56
57#endif // _OTAUTIL_ZIPUTIL_H