31 |
#endif |
#endif |
32 |
#include <string> |
#include <string> |
33 |
#include "Utility.h" |
#include "Utility.h" |
34 |
|
#define BOOST_FILESYSTEM_VERSION 3 |
35 |
#include <boost/filesystem/path.hpp> |
#include <boost/filesystem/path.hpp> |
36 |
#include <boost/filesystem/operations.hpp> |
#include <boost/filesystem/operations.hpp> |
37 |
#include <boost/filesystem/convenience.hpp> |
#include <boost/filesystem/convenience.hpp> |
42 |
// Returns the directory location corresponding to some path |
// Returns the directory location corresponding to some path |
43 |
std::string GetFileDirFromPath(const char *tszPath) |
std::string GetFileDirFromPath(const char *tszPath) |
44 |
{ |
{ |
45 |
bfs::path path = bfs::path(tszPath, bfs::native); |
bfs::path path = bfs::path(tszPath); |
46 |
return path.branch_path().native_file_string(); |
return path.parent_path().string(); |
47 |
} |
} |
48 |
|
|
49 |
// Returns the filename from the supplied path |
// Returns the filename from the supplied path |
50 |
std::string GetFileNameFromPath(const char *tszPath) |
std::string GetFileNameFromPath(const char *tszPath) |
51 |
{ |
{ |
52 |
bfs::path path = bfs::path(tszPath, bfs::native); |
bfs::path path = bfs::path(tszPath); |
53 |
return path.leaf(); |
return path.filename().string(); |
54 |
} |
} |
55 |
|
|
56 |
// Returns the filetitle from the supplied path |
// Returns the filetitle from the supplied path |
57 |
std::string GetFileTitleFromPath(const char *tszPath) |
std::string GetFileTitleFromPath(const char *tszPath) |
58 |
{ |
{ |
59 |
bfs::path path = bfs::path(tszPath, bfs::native); |
bfs::path path = bfs::path(tszPath); |
60 |
std::string fname = path.leaf(); |
std::string fname = path.filename().string(); |
61 |
std::string::size_type lastdot = fname.rfind('.'); |
std::string::size_type lastdot = fname.rfind('.'); |
62 |
if (lastdot != std::string::npos) |
if (lastdot != std::string::npos) |
63 |
{ |
{ |
69 |
// Returns the file extension from the supplied path |
// Returns the file extension from the supplied path |
70 |
std::string GetFileExtFromPath(const char *tszPath) |
std::string GetFileExtFromPath(const char *tszPath) |
71 |
{ |
{ |
72 |
bfs::path path = bfs::path(tszPath, bfs::native); |
bfs::path path = bfs::path(tszPath); |
73 |
std::string fname = path.leaf(); |
std::string fname = path.filename().string(); |
74 |
std::string::size_type lastdot = fname.rfind('.'); |
std::string::size_type lastdot = fname.rfind('.'); |
75 |
if (lastdot != std::string::npos) |
if (lastdot != std::string::npos) |
76 |
{ |
{ |
81 |
|
|
82 |
std::string ExtractFilePath(std::string FileName) |
std::string ExtractFilePath(std::string FileName) |
83 |
{ |
{ |
84 |
bfs::path path = bfs::path(FileName, bfs::native); |
bfs::path path = bfs::path(FileName); |
85 |
return path.branch_path().native_file_string(); |
return path.parent_path().string(); |
86 |
} |
} |
87 |
|
|
88 |
std::string ConcatPaths(const std::string & dir_name, const std::string & file_name) |
std::string ConcatPaths(const std::string & dir_name, const std::string & file_name) |
89 |
{ |
{ |
90 |
bfs::path dir_path (dir_name, bfs::native), |
bfs::path dir_path (dir_name), |
91 |
file_path (file_name, bfs::native); |
file_path (file_name); |
92 |
return (dir_path / file_path).native_file_string(); |
return (dir_path / file_path).string(); |
93 |
} |
} |
94 |
|
|
95 |
bool IsFileNameValid(const char * lpFileName) |
bool IsFileNameValid(const char * lpFileName) |
100 |
|
|
101 |
bool MakeSureDirectoryPathExists(std::string Dir) |
bool MakeSureDirectoryPathExists(std::string Dir) |
102 |
{ |
{ |
103 |
bfs::path pth = bfs::path(Dir, bfs::native).branch_path(); |
bfs::path pth = bfs::path(Dir).parent_path(); |
104 |
if (bfs::exists(pth)) |
if (bfs::exists(pth)) |
105 |
{ |
{ |
106 |
if (bfs::is_directory(pth)) |
if (bfs::is_directory(pth)) |
118 |
|
|
119 |
bool DirectoryExists(const std::string Name) |
bool DirectoryExists(const std::string Name) |
120 |
{ |
{ |
121 |
bfs::path pth (Name, bfs::native); |
bfs::path pth (Name); |
122 |
return bfs::exists(pth) && bfs::is_directory(pth); |
return bfs::exists(pth) && bfs::is_directory(pth); |
123 |
} |
} |
124 |
|
|