8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-31 03:23:03 +01:00
firebird-mirror/src/config/FileName.cpp

46 lines
828 B
C++
Raw Normal View History

2005-05-28 00:45:31 +02:00
#include "firebird.h"
#include "FileName.h"
#ifdef WIN_NT
#define IS_SLASH(c) (c == '/' || c == '\\')
#else
#define IS_SLASH(c) (c == '/')
#endif
FileName::FileName(const Firebird::PathName& name) :
pathName(getPool()), directory(getPool()), root(getPool()), extension(getPool())
2005-05-28 00:45:31 +02:00
{
pathName = name;
const char* const start = pathName.c_str();
const char* slash = NULL;
const char* dot = NULL;
const char* rootName = start;
2005-05-28 00:45:31 +02:00
absolute = IS_SLASH (start [0]);
for (const char* p = start; *p; ++p)
{
2005-05-28 00:45:31 +02:00
if (!dot && IS_SLASH (*p))
slash = p;
else if (*p == '.')
dot = p;
}
2008-12-05 02:20:14 +01:00
2005-05-28 00:45:31 +02:00
if (slash)
{
directory.assign (start, (int) (slash - rootName));
2005-05-28 00:45:31 +02:00
rootName = slash + 1;
}
2008-12-05 02:20:14 +01:00
2005-05-28 00:45:31 +02:00
if (dot)
{
2005-05-28 00:45:31 +02:00
extension = dot + 1;
root.assign (rootName, (int) (dot - rootName));
}
2005-05-28 00:45:31 +02:00
else
2008-12-05 02:20:14 +01:00
root = rootName;
2005-05-28 00:45:31 +02:00
}
FileName::~FileName()
2005-05-28 00:45:31 +02:00
{
}