1 /* 2 * Copyright 2017-2023, Andrew Lindesay <apl@lindesay.co.nz>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef PATH_UTILS_H 6 #define PATH_UTILS_H 7 8 #include <Path.h> 9 10 #include "Language.h" 11 12 class StorageUtils { 13 14 public: 15 static bool AreWorkingFilesAvailable(); 16 static void SetWorkingFilesUnavailable(); 17 18 static status_t LocalWorkingFilesPath(const BString leaf, 19 BPath& path, 20 bool failOnCreateDirectory = true); 21 static status_t LocalWorkingDirectoryPath(const BString leaf, 22 BPath& path, 23 bool failOnCreateDirectory = true); 24 25 static status_t CheckCanWriteTo(const BPath& path); 26 27 static status_t AppendToString(const BPath& path, BString& result); 28 static status_t AppendToFile(const BString& input, 29 const BPath& path); 30 31 static status_t RemoveWorkingDirectoryContents(); 32 static status_t RemoveDirectoryContents(BPath& path); 33 static status_t RemoveDirectoryContentsRetainingLatestFiles(BPath& path, 34 uint32 countLatestRetained); 35 36 static status_t ExistsObject(const BPath& path, 37 bool* exists, 38 bool* isDirectory, 39 off_t* size); 40 41 static status_t SwapExtensionOnPath(BPath& path, 42 const char* extension); 43 static BString SwapExtensionOnPathComponent( 44 const char* pathComponent, 45 const char* extension); 46 47 static status_t IconTarPath(BPath& path); 48 static status_t DumpExportReferenceDataPath(BPath& path, const LanguageRef language); 49 static status_t DumpExportRepositoryDataPath(BPath& path, const LanguageRef language); 50 static status_t DumpExportPkgDataPath(BPath& path, const BString& repositorySourceCode, 51 const LanguageRef language); 52 53 }; 54 55 #endif // PATH_UTILS_H 56