1 /* 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 29 namespace android { 30 namespace 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 deleted as a 35 * group. 36 */ 37 class CacheItem { 38 public: 39 CacheItem(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 bool group; 50 bool tombstone; 51 int64_t size; 52 time_t modified; 53 54 private: 55 CacheItem* mParent; 56 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 65