blob: bec8bc85b8f658cff9e76eb19c53aab4bc3d57b8 [file] [log] [blame]
Jeff Sharkey88ddd942017-01-17 18:05:54 -07001/*
2 * Copyright (C) 2017 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 ANDROID_INSTALLD_CACHE_ITEM_H
18#define ANDROID_INSTALLD_CACHE_ITEM_H
19
20#include <memory>
21#include <string>
22
23#include <fts.h>
24#include <sys/types.h>
25#include <sys/stat.h>
26
27#include <android-base/macros.h>
28
29namespace android {
30namespace installd {
31
32/**
33 * Single cache item that can be purged to free up space. This may be an
34 * isolated file, or an entire directory tree that should be atomically
35 * deleted.
36 */
37class CacheItem {
38public:
39 CacheItem(const std::shared_ptr<CacheItem>& parent, FTSENT* p);
40 ~CacheItem();
41
42 std::string toString();
43 std::string buildPath();
44
45 int purge();
46
47 short level;
48 bool directory;
49 int64_t size;
50 time_t modified;
51
52private:
53 std::shared_ptr<CacheItem> mParent;
54 std::string mName;
55
56 DISALLOW_COPY_AND_ASSIGN(CacheItem);
57};
58
59} // namespace installd
60} // namespace android
61
62#endif // ANDROID_INSTALLD_CACHE_ITEM_H