blob: 84b77aabb2d9f69c4bac3a771b9d0bc22e2e1ecc [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
Jeff Sharkeyed909ae2017-03-22 21:27:40 -060034 * isolated file, or an entire directory tree that should be deleted as a
35 * group.
Jeff Sharkey88ddd942017-01-17 18:05:54 -070036 */
37class CacheItem {
38public:
Jeff Sharkey871a8f22017-02-21 18:30:28 -070039 CacheItem(FTSENT* p);
Jeff Sharkey88ddd942017-01-17 18:05:54 -070040 ~CacheItem();
41
42 std::string toString();
43 std::string buildPath();
44
45 int purge();
46
47 short level;
48 bool directory;
Jeff Sharkeyed909ae2017-03-22 21:27:40 -060049 bool group;
Jeff Sharkey871a8f22017-02-21 18:30:28 -070050 bool tombstone;
Jeff Sharkey88ddd942017-01-17 18:05:54 -070051 int64_t size;
52 time_t modified;
53
54private:
Jeff Sharkey871a8f22017-02-21 18:30:28 -070055 CacheItem* mParent;
Jeff Sharkey88ddd942017-01-17 18:05:54 -070056 std::string mName;
57
58 DISALLOW_COPY_AND_ASSIGN(CacheItem);
59};
60
61} // namespace installd
62} // namespace android
63
64#endif // ANDROID_INSTALLD_CACHE_ITEM_H