PLCnext API Documentation 25.0.2.69
Directory.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Core/IEnumerator.hxx"
9#include "Arp/System/Commons/Logging.h"
10#include "Arp/System/Commons/Text/Regex.hpp"
11
12namespace Arp { namespace System { namespace Commons { namespace Io
13{
14
16class Directory : private Loggable<Directory>
17{
18public: // construction/destruction
19 Directory(void) = delete;
20
21public: // static operations
22 static bool Exists(const String& path);
23 static void Create(const String& path);
24 static void Create(const String& path, bool sync);
25 static void Delete(const String& path);
26 static void Delete(const String& path, bool sync);
27 static void Clear(const String& path);
28 static void Clear(const String& path, bool sync);
29 static void Copy(const String& sourcePath, const String& destinationPath, bool clear = false);
30 static void Copy(const String& sourcePath, const String& destinationPath, bool clear, bool sync);
31 static void Move(const String& sourcePath, const String& destinationPath, bool overwrite = false);
32 static void Move(const String& sourcePath, const String& destinationPath, bool overwrite, bool sync);
33
34 ARP_DEPRECATED("Please use Directory::Move() instead of Directory::Rename().")
35 static void Rename(const String& sourcePath, const String& destinationPath);
36 static String GetCurrent(void);
37 static void SyncAll(void);
38 static void Sync(const String& path);
39 static IEnumerator<String>::Ptr GetEnumerator(const String& path, bool recursive = false);
40 static IEnumerator<String>::Ptr GetEnumerator(const String& path, const char* searchPattern, bool recursive = false);
41 static IEnumerator<String>::Ptr GetFileEnumerator(const String& path, bool recursive = false);
42 static IEnumerator<String>::Ptr GetFileEnumerator(const String& path, const char* searchPattern, bool recursive = false);
43 static IEnumerator<String>::Ptr GetDirectoryEnumerator(const String& path, bool recursive = false);
44 static IEnumerator<String>::Ptr GetDirectoryEnumerator(const String& path, const char* searchPattern, bool recursive = false);
45 static IEnumerator<String>::Ptr TryGetEnumerator(const String& path, bool recursive = false);
46 static IEnumerator<String>::Ptr TryGetEnumerator(const String& path, const char* searchPattern, bool recursive = false);
47 static IEnumerator<String>::Ptr TryGetFileEnumerator(const String& path, bool recursive = false);
48 static IEnumerator<String>::Ptr TryGetFileEnumerator(const String& path, const char* searchPattern, bool recursive = false);
49 static IEnumerator<String>::Ptr TryGetDirectoryEnumerator(const String& path, bool recursive = false);
50 static IEnumerator<String>::Ptr TryGetDirectoryEnumerator(const String& path, const char* searchPattern, bool recursive = false);
51
52private: // static methods
53 static IEnumerator<String>::Ptr GetEnumerator(const String& path, bool recursive, bool files, bool directories);
54 static IEnumerator<String>::Ptr GetSearchEnumerator(const String& path, const char* searchPattern, bool recursive, bool files, bool directories);
55 static IEnumerator<String>::Ptr TryGetEnumerator(const String& path, bool recursive, bool files, bool directories);
56 static IEnumerator<String>::Ptr TryGetSearchEnumerator(const String& path, const char* searchPattern, bool recursive, bool files, bool directories);
57
58private:
59 template<class Iterator>
60 class Enumerator;
61
62 template<class Iterator>
63 class SearchEnumerator;
64
65 class EmptyEnumerator;
66};
67
68}}}} // end of namespace Arp::System::Commons::Io
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom.
Definition: IEnumerator.hxx:49
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
Derive from this class to inherit logging functionality.
Definition: Loggable.hxx:28
API for manipulation and examiniation of directories of a file system.
Definition: Directory.hpp:17
static void SyncAll(void)
Force global file system synchronization.
Definition: Directory.cpp:357
static void Move(const String &sourcePath, const String &destinationPath, bool overwrite=false)
Moves a directory and its content to a new location. After successful operation, the synchronization ...
Definition: Directory.cpp:286
static void Clear(const String &path)
Deletes the complete content of a directory. After successful operation, the synchronization of the f...
Definition: Directory.cpp:192
static void Copy(const String &sourcePath, const String &destinationPath, bool clear=false)
Copies a directory and its content to a new location. After successful operation, the synchronization...
Definition: Directory.cpp:226
static void Create(const String &path)
Creates a new directory. After successful operation, the synchronization of the file system will be f...
Definition: Directory.cpp:111
static IEnumerator< String >::Ptr GetDirectoryEnumerator(const String &path, bool recursive=false)
Like Arp::System::Commons::Io::Directory::GetEnumerator but only directories are listed by the return...
Definition: Directory.cpp:491
static IEnumerator< String >::Ptr GetFileEnumerator(const String &path, bool recursive=false)
Like Arp::System::Commons::Io::Directory::GetEnumerator but only files are listed by the returned enu...
Definition: Directory.cpp:468
static IEnumerator< String >::Ptr GetEnumerator(const String &path, bool recursive=false)
Returns an enumerator listing the content of a directory.
Definition: Directory.cpp:445
static bool Exists(const String &path)
Checks if a specific directory exists.
Definition: Directory.cpp:90
static IEnumerator< String >::Ptr TryGetDirectoryEnumerator(const String &path, bool recursive=false)
Like Arp::System::Commons::Io::Directory::GetDirectoryEnumerator but will not throw any exception.
Definition: Directory.cpp:561
static String GetCurrent(void)
Returns the fully qualified path of the current directory.
Definition: Directory.cpp:350
static IEnumerator< String >::Ptr TryGetFileEnumerator(const String &path, bool recursive=false)
Like Arp::System::Commons::Io::Directory::GetFileEnumerator but will not throw any exception.
Definition: Directory.cpp:537
static void Sync(const String &path)
Force file system synchronization for the given file.
Definition: Directory.cpp:365
static void Delete(const String &path)
Deletes a directory. After successful operation, the synchronization of the file system will be force...
Definition: Directory.cpp:146
static IEnumerator< String >::Ptr TryGetEnumerator(const String &path, bool recursive=false)
Like Arp::System::Commons::Io::Directory::GetEnumerator but will not throw any exception.
Definition: Directory.cpp:514
Root namespace for the PLCnext API