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 class StorageUtils { 11 12 public: 13 static bool AreWorkingFilesAvailable(); 14 static void SetWorkingFilesUnavailable(); 15 16 static status_t LocalWorkingFilesPath(const BString leaf, 17 BPath& path, 18 bool failOnCreateDirectory = true); 19 static status_t LocalWorkingDirectoryPath(const BString leaf, 20 BPath& path, 21 bool failOnCreateDirectory = true); 22 23 static status_t CheckCanWriteTo(const BPath& path); 24 25 static status_t AppendToString(const BPath& path, BString& result); 26 static status_t AppendToFile(const BString& input, 27 const BPath& path); 28 29 static status_t RemoveWorkingDirectoryContents(); 30 static status_t RemoveDirectoryContents(BPath& path); 31 static status_t RemoveDirectoryContentsRetainingLatestFiles(BPath& path, 32 uint32 countLatestRetained); 33 34 static status_t ExistsObject(const BPath& path, 35 bool* exists, 36 bool* isDirectory, 37 off_t* size); 38 39 static status_t SwapExtensionOnPath(BPath& path, 40 const char* extension); 41 static BString SwapExtensionOnPathComponent( 42 const char* pathComponent, 43 const char* extension); 44 }; 45 46 #endif // PATH_UTILS_H 47