Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 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 |
Jeff Sharkey | ed909ae | 2017-03-22 21:27:40 -0600 | [diff] [blame] | 34 | * isolated file, or an entire directory tree that should be deleted as a |
| 35 | * group. |
Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 36 | */ |
| 37 | class CacheItem { |
| 38 | public: |
Jeff Sharkey | 871a8f2 | 2017-02-21 18:30:28 -0700 | [diff] [blame] | 39 | CacheItem(FTSENT* p); |
Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 40 | ~CacheItem(); |
| 41 | |
| 42 | std::string toString(); |
| 43 | std::string buildPath(); |
| 44 | |
| 45 | int purge(); |
| 46 | |
| 47 | short level; |
| 48 | bool directory; |
Jeff Sharkey | ed909ae | 2017-03-22 21:27:40 -0600 | [diff] [blame] | 49 | bool group; |
Jeff Sharkey | 871a8f2 | 2017-02-21 18:30:28 -0700 | [diff] [blame] | 50 | bool tombstone; |
Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 51 | int64_t size; |
| 52 | time_t modified; |
| 53 | |
| 54 | private: |
Jeff Sharkey | 871a8f2 | 2017-02-21 18:30:28 -0700 | [diff] [blame] | 55 | CacheItem* mParent; |
Jeff Sharkey | 88ddd94 | 2017-01-17 18:05:54 -0700 | [diff] [blame] | 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 |