1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MTPFS_TMP_FILES_POOL_H 17 #define MTPFS_TMP_FILES_POOL_H 18 19 #include "mtpfs_type_tmp_file.h" 20 21 class MtpFsTmpFilesPool { 22 public: 23 MtpFsTmpFilesPool(); 24 ~MtpFsTmpFilesPool(); 25 SetTmpDir(const std::string & tmpDir)26 void SetTmpDir(const std::string &tmpDir) 27 { 28 tmpDir_ = tmpDir; 29 } 30 AddFile(const MtpFsTypeTmpFile & tmp)31 void AddFile(const MtpFsTypeTmpFile &tmp) 32 { 33 pool_.insert(tmp); 34 } 35 void RemoveFile(const std::string &path); Empty()36 bool Empty() const 37 { 38 return pool_.size(); 39 } 40 41 const MtpFsTypeTmpFile *GetFile(const std::string &path) const; 42 43 std::string MakeTmpPath(const std::string &pathDevice) const; 44 bool CreateTmpDir(); 45 bool RemoveTmpDir(); 46 47 private: 48 std::string tmpDir_; 49 std::set<MtpFsTypeTmpFile> pool_; 50 }; 51 52 #endif // MTPFS_TMP_FILES_POOL_H 53