version 1.73, 2007/09/14 18:31:02
|
version 1.74, 2007/11/30 01:16:33
|
|
|
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/System.h> | #include <Pegasus/Common/System.h> |
#include <Pegasus/Common/AutoPtr.h> | #include <Pegasus/Common/AutoPtr.h> |
|
#include <Executor/Match.h> |
#include "FileSystem.h" | #include "FileSystem.h" |
#include "Dir.h" | #include "Dir.h" |
#ifndef PEGASUS_OS_TYPE_WINDOWS | #ifndef PEGASUS_OS_TYPE_WINDOWS |
|
|
| |
Boolean FileSystem::existsNoCase(const String& path, String& realPath) | Boolean FileSystem::existsNoCase(const String& path, String& realPath) |
{ | { |
|
// If a file exists that has the same case as the path parmater, |
|
// then we can bypass the expensive directory scanning below. |
|
|
|
if (FileSystem::exists(path)) |
|
{ |
|
realPath = path; |
|
return true; |
|
} |
|
|
|
|
realPath.clear(); | realPath.clear(); |
CString cpath = _clonePath(path); | CString cpath = _clonePath(path); |
const char* p = cpath; | const char* p = cpath; |
|
|
#endif | #endif |
} | } |
| |
|
Boolean FileSystem::glob( |
|
const String& path, |
|
const String& pattern_, |
|
Array<String>& filenames) |
|
{ |
|
filenames.clear(); |
|
|
|
try |
|
{ |
|
CString pattern(pattern_.getCString()); |
|
|
|
for (Dir dir(path); dir.more(); dir.next()) |
|
{ |
|
const char* name = dir.getName(); |
|
|
|
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0) |
|
continue; |
|
|
|
if (Match(pattern, name) == 0) |
|
filenames.append(name); |
|
} |
|
} |
|
catch (CannotOpenDirectory&) |
|
{ |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |