MeshLib Documentation
Loading...
Searching...
No Matches
MRDirectory.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRMeshFwd.h"
4#include <filesystem>
5
6namespace MR
7{
8
16{
17 std::filesystem::path dir;
18 std::error_code & ec;
19};
20
28{
29 std::filesystem::path dir;
30 std::error_code & ec;
31};
32
35{
36 std::filesystem::directory_iterator it;
37 std::error_code & ec;
38 DirectoryIterator & operator ++() { it.increment( ec ); return * this; }
39 auto operator *() const { return *it; }
40};
41
43[[nodiscard]] MRMESH_API std::filesystem::path findPathWithExtension( const std::filesystem::path & pathWithoutExtension );
44
47{
48 std::filesystem::recursive_directory_iterator it;
49 std::error_code & ec;
50 DirectoryRecursiveIterator & operator ++() { it.increment( ec ); return * this; }
51 auto operator *() const { return *it; }
52};
53
54[[nodiscard]] inline DirectoryIterator begin( const Directory & sd )
55{
56 return DirectoryIterator{ std::filesystem::directory_iterator( sd.dir, sd.ec ), sd.ec };
57}
58
59[[nodiscard]] inline std::filesystem::directory_iterator end( const Directory & )
60{
61 return {};
62}
63
64[[nodiscard]] inline bool operator !=( const DirectoryIterator & a, const std::filesystem::directory_iterator & b )
65{
66 return !a.ec && a.it != b;
67}
68
69[[nodiscard]] inline DirectoryRecursiveIterator begin( const DirectoryRecursive & sd )
70{
71 return DirectoryRecursiveIterator{ std::filesystem::recursive_directory_iterator( sd.dir, sd.ec ), sd.ec };
72}
73
74[[nodiscard]] inline std::filesystem::recursive_directory_iterator end( const DirectoryRecursive & )
75{
76 return {};
77}
78
79[[nodiscard]] inline bool operator !=( const DirectoryRecursiveIterator & a, const std::filesystem::recursive_directory_iterator & b )
80{
81 return !a.ec && a.it != b;
82}
83
84} // namespace MR
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
auto begin(const BitSet &a)
Definition MRMesh/MRBitSet.h:280
auto end(const BitSet &)
Definition MRMesh/MRBitSet.h:282
bool operator!=(const SetBitIteratorT< T > &a, const SetBitIteratorT< T > &b)
Definition MRMesh/MRBitSet.h:276
Definition MRCameraOrientationPlugin.h:8
MRMESH_API std::filesystem::path findPathWithExtension(const std::filesystem::path &pathWithoutExtension)
given file name without final extension, finds in the same folder an existing file with same stem and...
iterator of directory items that will save any errors in (ec) instead of throwing exceptions
Definition MRDirectory.h:35
auto operator*() const
Definition MRDirectory.h:39
std::filesystem::directory_iterator it
Definition MRDirectory.h:36
std::error_code & ec
Definition MRDirectory.h:37
DirectoryIterator & operator++()
Definition MRDirectory.h:38
recursive iterator of directory items that will save any errors in (ec) instead of throwing exception...
Definition MRDirectory.h:47
std::error_code & ec
Definition MRDirectory.h:49
auto operator*() const
Definition MRDirectory.h:51
DirectoryRecursiveIterator & operator++()
Definition MRDirectory.h:50
std::filesystem::recursive_directory_iterator it
Definition MRDirectory.h:48
Definition MRDirectory.h:28
std::filesystem::path dir
Definition MRDirectory.h:29
std::error_code & ec
Definition MRDirectory.h:30
Definition MRDirectory.h:16
std::filesystem::path dir
Definition MRDirectory.h:17
std::error_code & ec
Definition MRDirectory.h:18