FileSystem.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2020, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeCore/Base.h"
16 #include "CeeCore/Str.h"
17 
18 #include <vector>
19 
20 namespace cee {
21 
22 
23 //==================================================================================================
24 //
25 // Static class containing file system utility functions
26 //
27 //==================================================================================================
28 class CEE_CORE_EXPORT FileSystem
29 {
30 public:
31  static Str fromNativeSeparators(const Str& path);
32  static Str toNativeSeparators(const Str& path);
33 
34  static Str addTrailingSeparator(const Str& path);
35  static Str removeTrailingSeparator(const Str& path);
36 
37  static Str fileName(const Str& path);
38  static Str extension(const Str& path);
39  static Str parentPath(const Str& path);
40 
41  static Str makeAbsolute(const Str& path);
42 
43  static Str currentPath();
44 
45  static bool pathExists(const Str& pathName);
46  static bool fileExists(const Str& fileName);
47  static bool directoryExists(const Str& dirName);
48 
49  static bool createDirectory(const Str& dirName);
50  static bool createDirectoryTree(const Str& dirPath);
51 
52  static bool copyFile(const Str& fromFileName, const Str& toFileName);
53 
54  static bool deleteFile(const Str& fileName);
55  static bool deleteDirectory(const Str& dirName);
56  static bool deleteAllFilesInDirectory(const Str& dirName);
57  static bool deleteDirectoryRecursive(const Str& dirName);
58 
59  static bool getDirectoryContents(const Str& dirName, std::vector<Str>* fileNameArr, std::vector<Str>* dirNameArr);
60  static std::vector<Str> getAllFilesInDirectory(const Str& dirName);
61  static std::vector<Str> findFilesInDirectory(const Str& dirName, const Str& filePattern);
62 
63  static uint64_t fileSize(const Str& fileName);
64  static unsigned int fileContentsCrc(const Str& fileName, uint64_t maxBytesToRead);
65 };
66 
67 }
68 
Static class containing file system utility functions.
Definition: FileSystem.h:28
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppAssert.cpp:18
A general unicode based string class.
Definition: Str.h:28