Android-cuttlefish cvd tool
managed.h
Go to the documentation of this file.
1//
2// Copyright (C) 2025 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#pragma once
17
18#include <stddef.h>
19
20#include <memory>
21
22#include <zip.h>
23
24namespace cuttlefish {
25
26struct ZipDeleter {
27 void operator()(zip_error_t* error) {
28 zip_error_fini(error);
29 delete error;
30 }
31 void operator()(zip_source_t* source) { zip_source_free(source); }
32 void operator()(zip_t* zip_ptr) { zip_discard(zip_ptr); }
33};
34
35using ManagedZip = std::unique_ptr<zip_t, ZipDeleter>;
36using ManagedZipError = std::unique_ptr<zip_error_t, ZipDeleter>;
37using ManagedZipSource = std::unique_ptr<zip_source_t, ZipDeleter>;
38
39} // namespace cuttlefish
#define error(format, args...)
Definition: fec_private.h:201
Definition: alloc_driver.h:20
std::unique_ptr< zip_t, ZipDeleter > ManagedZip
Definition: managed.h:35
std::unique_ptr< zip_source_t, ZipDeleter > ManagedZipSource
Definition: managed.h:37
std::unique_ptr< zip_error_t, ZipDeleter > ManagedZipError
Definition: managed.h:36
Definition: managed.h:26
void operator()(zip_t *zip_ptr)
Definition: managed.h:32
void operator()(zip_error_t *error)
Definition: managed.h:27
void operator()(zip_source_t *source)
Definition: managed.h:31