0.4.00.4.10.4.2
|
Last change
on this file since f029bc2 was
79e734f,
checked in by Michael Medin <michael@…>, 3 years ago
|
|
Re added some more stuff anf fixed *nix compatibility of sockets
|
-
Property mode set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include <boost/filesystem.hpp>
|
|---|
| 4 |
|
|---|
| 5 | namespace file_helpers {
|
|---|
| 6 | class checks {
|
|---|
| 7 | public:
|
|---|
| 8 | static bool is_directory(std::wstring path) {
|
|---|
| 9 | boost::filesystem::is_directory(path);
|
|---|
| 10 | }
|
|---|
| 11 | // static bool is_directory(DWORD dwAtt) {
|
|---|
| 12 | // if (dwAtt == INVALID_FILE_ATTRIBUTES) {
|
|---|
| 13 | // return false;
|
|---|
| 14 | // } else if ((dwAtt&FILE_ATTRIBUTE_DIRECTORY)==FILE_ATTRIBUTE_DIRECTORY) {
|
|---|
| 15 | // return true;
|
|---|
| 16 | // }
|
|---|
| 17 | // return false;
|
|---|
| 18 | // }
|
|---|
| 19 | static bool is_file(std::wstring path) {
|
|---|
| 20 | return boost::filesystem::is_regular(path);
|
|---|
| 21 | // DWORD dwAtt = ::GetFileAttributes(path.c_str());
|
|---|
| 22 | // if (dwAtt == INVALID_FILE_ATTRIBUTES) {
|
|---|
| 23 | // return false;
|
|---|
| 24 | // } else if ((dwAtt&FILE_ATTRIBUTE_NORMAL)==FILE_ATTRIBUTE_NORMAL) {
|
|---|
| 25 | // return true;
|
|---|
| 26 | // }
|
|---|
| 27 | // return false;
|
|---|
| 28 | }
|
|---|
| 29 | static bool exists(std::wstring path) {
|
|---|
| 30 | return boost::filesystem::exists(path);
|
|---|
| 31 | // DWORD dwAtt = ::GetFileAttributes(path.c_str());
|
|---|
| 32 | // if (dwAtt == INVALID_FILE_ATTRIBUTES) {
|
|---|
| 33 | // return false;
|
|---|
| 34 | // }
|
|---|
| 35 | // return true;
|
|---|
| 36 | }
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | class patterns {
|
|---|
| 40 | public:
|
|---|
| 41 | typedef std::pair<boost::filesystem::wpath,std::wstring> pattern_type;
|
|---|
| 42 |
|
|---|
| 43 | static pattern_type split_pattern(boost::filesystem::wpath path) {
|
|---|
| 44 | if (boost::filesystem::is_directory(path))
|
|---|
| 45 | return pattern_type(path, _T(""));
|
|---|
| 46 | return pattern_type(path.branch_path(), path.leaf() /*filename()*/);
|
|---|
| 47 | }
|
|---|
| 48 | static boost::filesystem::wpath combine_pattern(pattern_type pattern) {
|
|---|
| 49 | return pattern.first / pattern.second;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 | }
|
|---|
Note: See
TracBrowser
for help on using the repository browser.