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_UTIL_H 17 #define MTPFS_UTIL_H 18 19 #include <config.h> 20 #include <cstdint> 21 #include <string> 22 23 #include <libmtp.h> 24 25 class MtpFsUtil { 26 public: 27 MtpFsUtil() = delete; 28 29 static void On(); 30 static void Off(); 31 32 private: 33 static bool enabled_; 34 static int stdOut_; 35 static int stdErr_; 36 }; 37 38 std::string SmtpfsDirName(const std::string &path); 39 std::string SmtpfsBaseName(const std::string &path); 40 std::string SmtpfsRealPath(const std::string &path); 41 std::string SmtpfsGetTmpDir(); 42 43 bool SmtpfsCreateDir(const std::string &dirName); 44 bool SmtpfsRemoveDir(const std::string &dirName); 45 bool SmtpfsCheckDir(const std::string &path); 46 bool SmtpfsUsbDevPath(const std::string &path, uint8_t *bnum, uint8_t *dnum); 47 48 LIBMTP_raw_device_t *SmtpfsRawDeviceNew(const std::string &path); 49 void SmtpfsRawDeviceFree(LIBMTP_raw_device_t *device); 50 bool SmtpfsResetDevice(LIBMTP_raw_device_t *device); 51 52 #endif // MTPFS_UTIL_H 53