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

44 lines
725 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(JString name)
{
pathName = name;
const char *start = pathName;
const char *slash = NULL;
const char *dot = NULL;
const char *rootName = start;
absolute = IS_SLASH (start [0]);
for (const char *p = start; *p; ++p)
if (!dot && IS_SLASH (*p))
slash = p;
else if (*p == '.')
dot = p;
if (slash)
{
directory.setString (start, (int) (slash - rootName));
rootName = slash + 1;
}
if (dot)
{
extension = dot + 1;
root.setString (rootName, (int) (dot - rootName));
}
else
root = rootName;
}
FileName::~FileName(void)
{
}