version 1.19, 2002/06/01 00:56:31
|
version 1.25, 2003/01/25 14:38:58
|
|
|
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/String.h> | #include <Pegasus/Common/String.h> |
#include <Pegasus/Common/Array.h> |
#include <Pegasus/Common/ArrayInternal.h> |
#include <Pegasus/Common/Exception.h> |
#include <Pegasus/Common/InternalException.h> |
|
#include <Pegasus/Common/Linkage.h> |
#include <fstream> | #include <fstream> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
*/ | */ |
static void translateSlashes(String& path); | static void translateSlashes(String& path); |
| |
|
/** Get an absolute path from an absolute directory and a relative or |
|
absolute file name. If the file name is fully specified, it is |
|
returned unchanged. Otherwise, the specified directory is prepended |
|
to the file name. |
|
*/ |
|
static String getAbsolutePath(const char* path, const String& filename); |
|
|
|
/** Return the just the filename to the file name into base. |
|
*/ |
|
static String extractFileName(const String& base); |
|
|
|
/** Return the just the path to the file name into path. |
|
*/ |
|
static String extractFilePath(const String& path); |
|
|
private: | private: |
| |
FileSystem() { } | FileSystem() { } |
|
|
return FileSystem::getFileSize(realPath, size); | return FileSystem::getFileSize(realPath, size); |
} | } |
| |
|
inline String FileSystem::getAbsolutePath( |
|
const char* path, |
|
const String& filename) |
|
{ |
|
String absolutePath; |
|
|
|
if (filename != String::EMPTY) |
|
{ |
|
if ((filename[0] != '/') && path && path[0]) |
|
{ |
|
absolutePath.append(path); |
|
absolutePath.append('/'); |
|
} |
|
absolutePath.append(filename); |
|
} |
|
translateSlashes(absolutePath); |
|
|
|
return absolutePath; |
|
} |
|
|
inline Boolean Open(PEGASUS_STD(ifstream)& is, const String& path) | inline Boolean Open(PEGASUS_STD(ifstream)& is, const String& path) |
{ | { |
char* tmpPath = path.allocateCString(); |
is.open(path.getCString()); |
is.open(tmpPath); |
|
delete [] tmpPath; |
|
return !!is; | return !!is; |
} | } |
| |
inline Boolean Open(PEGASUS_STD(ofstream)& os, const String& path) | inline Boolean Open(PEGASUS_STD(ofstream)& os, const String& path) |
{ | { |
char* tmpPath = path.allocateCString(); |
os.open(path.getCString()); |
os.open(tmpPath); |
|
delete [] tmpPath; |
|
return !!os; | return !!os; |
} | } |
| |
inline Boolean OpenAppend(PEGASUS_STD(ofstream)& os, const String& path) | inline Boolean OpenAppend(PEGASUS_STD(ofstream)& os, const String& path) |
{ | { |
char* tmpPath = path.allocateCString(); |
os.open(path.getCString(), PEGASUS_STD(ios::app)); |
os.open(tmpPath, PEGASUS_STD(ios::app)); |
|
delete [] tmpPath; |
|
return !!os; | return !!os; |
} | } |
| |