AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
FileSystem.h
1
5#pragma once
6
7#include <aws/core/Core_EXPORTS.h>
8#include <aws/core/utils/memory/stl/AWSVector.h>
9#include <aws/core/utils/memory/stl/AWSString.h>
10#include <aws/core/utils/memory/stl/AWSMap.h>
11#include <functional>
12
13namespace Aws
14{
15
16namespace FileSystem
17{
18 struct DirectoryEntry;
19 class Directory;
20
21 #ifdef _WIN32
22 static const char PATH_DELIM = '\\';
23 #else
24 static const char PATH_DELIM = '/';
25 #endif
26
31
36
42 AWS_CORE_API bool CreateDirectoryIfNotExists(const char* path, bool createParentDirs = false);
43
48 AWS_CORE_API bool RemoveDirectoryIfExists(const char* path);
49
53 AWS_CORE_API bool RemoveFileIfExists(const char* fileName);
54
58 AWS_CORE_API bool RelocateFileOrDirectory(const char* from, const char* to);
59
63 AWS_CORE_API bool DeepCopyDirectory(const char* from, const char* to);
64
68 AWS_CORE_API bool DeepDeleteDirectory(const char* toDelete);
69
74
78 AWS_CORE_API Aws::UniquePtr<Directory> OpenDirectory(const Aws::String& path, const Aws::String& relativePath = "");
79
84 AWS_CORE_API Aws::String Join(const Aws::String& leftSegment, const Aws::String& rightSegment);
85
90 AWS_CORE_API Aws::String Join(char delimiter, const Aws::String& leftSegment, const Aws::String& rightSegment);
91
95 enum class FileType
96 {
97 None,
98 File,
99 Symlink,
101 };
102
104 {
106
107 operator bool() const { return !path.empty() && fileType != FileType::None; }
108
112 int64_t fileSize = 0;
113 };
114
119 class AWS_CORE_API Directory
120 {
121 public:
122 virtual ~Directory() = default;
123
127 Directory(const Aws::String& path, const Aws::String& relativePath);
128
132 virtual operator bool() const { return m_directoryEntry.operator bool(); }
133
137 const DirectoryEntry& GetDirectoryEntry() const { return m_directoryEntry; }
138
142 const Aws::String& GetPath() const { return m_directoryEntry.path; }
143
147 virtual DirectoryEntry Next() = 0;
148
154
159
160 protected:
162 };
163
164 class DirectoryTree;
165
169 typedef std::function<bool(const DirectoryTree*, const DirectoryEntry&)> DirectoryEntryVisitor;
170
175 class AWS_CORE_API DirectoryTree
176 {
177 public:
182
187
191 bool operator==(const Aws::String& path);
192
201
205 operator bool() const;
206
211 void TraverseDepthFirst(const DirectoryEntryVisitor& visitor, bool postOrderTraversal = false);
212
217
218 private:
219 bool TraverseDepthFirst(Directory& dir, const DirectoryEntryVisitor& visitor, bool postOrder = false);
220 void TraverseBreadthFirst(Directory& dir, const DirectoryEntryVisitor& visitor);
221
223 };
224
225} // namespace FileSystem
226} // namespace Aws
virtual DirectoryEntry Next()=0
const Aws::String & GetPath() const
Definition FileSystem.h:142
const DirectoryEntry & GetDirectoryEntry() const
Definition FileSystem.h:137
Aws::UniquePtr< Directory > Descend(const DirectoryEntry &directoryEntry)
static Aws::Vector< Aws::String > GetAllFilePathsInDirectory(const Aws::String &path)
DirectoryEntry m_directoryEntry
Definition FileSystem.h:161
Directory(const Aws::String &path, const Aws::String &relativePath)
virtual ~Directory()=default
DirectoryTree(const Aws::String &path)
bool operator==(const Aws::String &path)
void TraverseDepthFirst(const DirectoryEntryVisitor &visitor, bool postOrderTraversal=false)
void TraverseBreadthFirst(const DirectoryEntryVisitor &visitor)
Aws::Map< Aws::String, DirectoryEntry > Diff(DirectoryTree &other)
bool operator==(DirectoryTree &other)
std::function< bool(const DirectoryTree *, const DirectoryEntry &)> DirectoryEntryVisitor
Definition FileSystem.h:169
AWS_CORE_API bool DeepDeleteDirectory(const char *toDelete)
AWS_CORE_API Aws::String CreateTempFilePath()
AWS_CORE_API Aws::String GetHomeDirectory()
AWS_CORE_API Aws::String GetExecutableDirectory()
static const char PATH_DELIM
Definition FileSystem.h:24
AWS_CORE_API bool RelocateFileOrDirectory(const char *from, const char *to)
AWS_CORE_API bool CreateDirectoryIfNotExists(const char *path, bool createParentDirs=false)
Creates directory if it doesn't exist. Returns true if the directory was created or already exists....
AWS_CORE_API bool RemoveFileIfExists(const char *fileName)
AWS_CORE_API bool RemoveDirectoryIfExists(const char *path)
AWS_CORE_API Aws::UniquePtr< Directory > OpenDirectory(const Aws::String &path, const Aws::String &relativePath="")
AWS_CORE_API bool DeepCopyDirectory(const char *from, const char *to)
AWS_CORE_API Aws::String Join(const Aws::String &leftSegment, const Aws::String &rightSegment)
std::map< K, V, std::less< K >, Aws::Allocator< std::pair< const K, V > > > Map
Definition AWSMap.h:20
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
std::vector< T, Aws::Allocator< T > > Vector
Definition AWSVector.h:17
std::unique_ptr< T, D > UniquePtr
Definition AWSMemory.h:255
Definition FileSystem.h:104
Aws::String path
Definition FileSystem.h:109
FileType fileType
Definition FileSystem.h:111
int64_t fileSize
Definition FileSystem.h:112
DirectoryEntry()
Definition FileSystem.h:105
Aws::String relativePath
Definition FileSystem.h:110