Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

FileUtils.h
Go to the documentation of this file.
1 // This file is part of CoreLibrary containing useful reusable utility
2 // classes.
3 //
4 // Copyright (C) 2014 to present, Duncan Crutchley
5 // Contact <dac1976github@outlook.com>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published
9 // by the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License and GNU Lesser General Public License
16 // for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // and GNU Lesser General Public License along with this program. If
20 // not, see <http://www.gnu.org/licenses/>.
21
27 #ifndef FILEUTILS
28 #define FILEUTILS
29
30 #include <string>
31 #include <list>
32 #include "CoreLibraryDllGlobal.h"
33 #include "Platform/PlatformDefines.h"
34
36 namespace core_lib
37 {
39 namespace file_utils
40 {
41
50 bool CORE_LIBRARY_DLL_SHARED_API FindFileRecursively(const std::wstring& dirPath,
51 const std::wstring& fileName,
52 std::wstring& pathFound,
53 bool includeFileName = true);
54
63 std::wstring CORE_LIBRARY_DLL_SHARED_API FindCommonRootPath(const std::wstring& path1,
64 const std::wstring& path2);
65
67 enum class eCopyDirectoryOptions
68 {
70 failIfTargetExists,
72 continueIfTargetExists
73 };
74
94 void CORE_LIBRARY_DLL_SHARED_API CopyDirectoryRecursively(
95 const std::wstring& source, const std::wstring& target,
96 eCopyDirectoryOptions options = eCopyDirectoryOptions::continueIfTargetExists);
97
106 std::list<std::wstring> CORE_LIBRARY_DLL_SHARED_API
107 ListDirectoryContents(const std::wstring& path, const std::wstring& extMatch = L"");
108
116 std::list<std::wstring> CORE_LIBRARY_DLL_SHARED_API ListSubDirectories(const std::wstring& path);
117
118 } // namespace file_utils
119 } // namespace core_lib
120
121 #endif // FILEUTILS
core_lib::file_utils::eCopyDirectoryOptions::continueIfTargetExists
Continue copying even if target directory exists.
core_lib::file_utils::eCopyDirectoryOptions::failIfTargetExists
Do not continue copying if target directory exists.
core_lib::file_utils::ListDirectoryContents
std::list< std::wstring > CORE_LIBRARY_DLL_SHARED_API ListDirectoryContents(const std::wstring &path, const std::wstring &extMatch=L"")
List of regular files in the specified directory.
Definition: FileUtils.cpp:159
core_lib::file_utils::FindFileRecursively
bool CORE_LIBRARY_DLL_SHARED_API FindFileRecursively(const std::wstring &dirPath, const std::wstring &fileName, std::wstring &pathFound, bool includeFileName=true)
Find the common root path of 2 paths.
Definition: FileUtils.cpp:45
core_lib::file_utils::eCopyDirectoryOptions
eCopyDirectoryOptions
Copy directory options enumeration.
Definition: FileUtils.h:67
core_lib
The core_lib namespace.
Definition: AsioDefines.h:59
core_lib::file_utils::CopyDirectoryRecursively
void CORE_LIBRARY_DLL_SHARED_API CopyDirectoryRecursively(const std::wstring &source, const std::wstring &target, eCopyDirectoryOptions options=eCopyDirectoryOptions::continueIfTargetExists)
Recursively copy one directory and its contents to another location.
Definition: FileUtils.cpp:102
core_lib::file_utils::ListSubDirectories
std::list< std::wstring > CORE_LIBRARY_DLL_SHARED_API ListSubDirectories(const std::wstring &path)
List of immediate sub-directories in the specified directory.
Definition: FileUtils.cpp:189
CoreLibraryDllGlobal.h
File containing declaration of DLL import/export control defines.
PlatformDefines.h
File containing platform specific definitions.
core_lib::file_utils::FindCommonRootPath
std::wstring CORE_LIBRARY_DLL_SHARED_API FindCommonRootPath(const std::wstring &path1, const std::wstring &path2)
Find the common root path of 2 paths.
Definition: FileUtils.cpp:69