summaryrefslogtreecommitdiff
path: root/thirdparty/openxr/src/common/unique_asset.h
blob: 4929039a031a392951aec7336e879aed6a5d353c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2017-2022, The Khronos Group Inc.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
#pragma once

#ifdef XR_USE_PLATFORM_ANDROID

#include <memory>
#include <android/asset_manager.h>

namespace deleters {
struct AAssetDeleter {
    void operator()(AAsset* asset) const noexcept {
        if (asset != nullptr) {
            AAsset_close(asset);
        }
    }
};

struct AAssetDirDeleter {
    void operator()(AAssetDir* dir) const noexcept {
        if (dir != nullptr) {
            AAssetDir_close(dir);
        }
    }
};

}  // namespace deleters

using UniqueAsset = std::unique_ptr<AAsset, deleters::AAssetDeleter>;
using UniqueAssetDir = std::unique_ptr<AAssetDir, deleters::AAssetDirDeleter>;

#endif