| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright (C) 2013, 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 LATINIME_FILE_UTILS_H |
| 18 #define LATINIME_FILE_UTILS_H |
| 19 |
| 20 #include "third_party/prediction/defines.h" |
| 21 |
| 22 namespace latinime { |
| 23 |
| 24 class FileUtils { |
| 25 public: |
| 26 // Returns -1 on error. |
| 27 static int getFileSize(const char* const filePath); |
| 28 |
| 29 static bool existsDir(const char* const dirPath); |
| 30 |
| 31 // Remove a directory and all files in the directory. |
| 32 static bool removeDirAndFiles(const char* const dirPath); |
| 33 |
| 34 static int getFilePathWithSuffixBufSize(const char* const filePath, |
| 35 const char* const suffix); |
| 36 |
| 37 static void getFilePathWithSuffix(const char* const filePath, |
| 38 const char* const suffix, |
| 39 const int filePathBufSize, |
| 40 char* const outFilePath); |
| 41 |
| 42 static int getFilePathBufSize(const char* const dirPath, |
| 43 const char* const fileName); |
| 44 |
| 45 static void getFilePath(const char* const dirPath, |
| 46 const char* const fileName, |
| 47 const int filePathBufSize, |
| 48 char* const outFilePath); |
| 49 |
| 50 // Returns whether the filePath have the suffix. |
| 51 static bool getFilePathWithoutSuffix(const char* const filePath, |
| 52 const char* const suffix, |
| 53 const int dirPathBufSize, |
| 54 char* const outDirPath); |
| 55 |
| 56 static void getDirPath(const char* const filePath, |
| 57 const int dirPathBufSize, |
| 58 char* const outDirPath); |
| 59 |
| 60 static void getBasename(const char* const filePath, |
| 61 const int outNameBufSize, |
| 62 char* const outName); |
| 63 |
| 64 private: |
| 65 DISALLOW_IMPLICIT_CONSTRUCTORS(FileUtils); |
| 66 |
| 67 static bool removeDirAndFiles(const char* const dirPath, const int maxTries); |
| 68 }; |
| 69 } // namespace latinime |
| 70 #endif /* LATINIME_FILE_UTILS_H */ |
| OLD | NEW |