38 #include <sys/types.h> 47 #if (defined (UNIX) || defined(CYGWIN)) && !defined(ANDROID) 56 using namespace ::
std;
62 std::string::size_type lastDot = filename.find_last_of(
'.');
63 if (lastDot != std::string::npos)
64 return filename.substr(lastDot + 1);
71 std::string::size_type lastDot = filename.find_last_of(
'.');
72 if (lastDot != std::string::npos)
73 return filename.substr(0, lastDot);
81 std::string::size_type lastSlash = filename.find_last_of(
'\\');
83 std::string::size_type lastSlash = filename.find_last_of(
'/');
85 if (lastSlash != std::string::npos)
86 return filename.substr(lastSlash + 1);
94 std::string::size_type lastSlash = filename.find_last_of(
'\\');
96 std::string::size_type lastSlash = filename.find_last_of(
'/');
98 if (lastSlash != std::string::npos)
99 return filename.substr(0, lastSlash);
106 std::string::size_type lastDot = filename.find_last_of(
'.');
107 if (lastDot != std::string::npos) {
109 return filename.substr(0, lastDot) + newExt;
111 return filename.substr(0, lastDot + 1) + newExt;
118 struct stat statInfo;
119 return (stat(filename, &statInfo) == 0);
124 std::vector<std::string> result;
129 WIN32_FIND_DATA FData;
130 if ((hFind = FindFirstFile(pattern, &FData)) != INVALID_HANDLE_VALUE) {
132 result.push_back(FData.cFileName);
133 }
while (FindNextFile(hFind, &FData));
137 #elif (defined (UNIX) || defined (CYGWIN)) && !defined(ANDROID) 140 wordexp(pattern, &p, 0);
146 for (
int k = 0; (k < 100) && (p.we_wordc == 0); k++) {
149 wordexp(pattern, &p, WRDE_APPEND);
153 result.reserve(p.we_wordc);
154 for (
size_t i = 0; i < p.we_wordc; ++i)
155 result.push_back(p.we_wordv[i]);
std::string changeFileExtension(const std::string &filename, const std::string &newExt, bool stripDot)
std::string getFileExtension(const std::string &filename)
std::string getBasename(const std::string &filename)
std::string getDirname(const std::string &filename)
std::string getPureFilename(const std::string &filename)
std::vector< std::string > getFilesByPattern(const char *pattern)
bool fileExists(const char *filename)