8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 07:23:03 +01:00

I prefer a clearer and specific way to ensure our paths end on a valid directory separator.

This commit is contained in:
robocop 2006-06-02 08:46:28 +00:00
parent cd6f21e2e2
commit a5df2e453d
4 changed files with 26 additions and 2 deletions

View File

@ -352,7 +352,7 @@ TempFile* TempSpace::setupFile(size_t size)
Firebird::PathName dirname, filename;
PathUtils::splitLastComponent(dirname, filename,
tempFiles[j]->getName());
PathUtils::concatPath(dirname, dirname, PathUtils::dir_sep);
PathUtils::ensureSeparator(dirname);
if (!directory.compare(dirname) &&
tempFiles[j]->getSize() + size <= MAX_FILE_SIZE)
{

View File

@ -118,7 +118,7 @@ public:
/** Concatenates the two paths given in the second and third parameters,
and writes the resulting path into the first parameter. The
two path input arguments (arg 2 and 3) are concatinated in the order
two path input arguments (arg 2 and 3) are concatenated in the order
arg2 arg3. The concatenation is done is such a way as to remove
any duplicate directory separators that may have resulted from
a simple string concatenation of the arguments with the directory
@ -126,6 +126,10 @@ public:
**/
static void concatPath(Firebird::PathName&, const Firebird::PathName&,
const Firebird::PathName&);
// Tries to ensure our path finishes with a platform-specific directory separator.
// We don't work correctly with MBCS.
static void PathUtils::ensureSeparator(Firebird::PathName& in_out);
/** splitLastComponent takes a path as the third argument and
removes the last component in that path (usually a file or directory name).

View File

@ -148,6 +148,16 @@ void PathUtils::concatPath(Firebird::PathName& result,
result = first + second;
}
// We don't work correctly with MBCS.
void PathUtils::ensureSeparator(Firebird::PathName& in_out)
{
if (in_out.length() == 0)
in_out = PathUtils::dir_sep;
if (in_out[in_out.length() - 1] != PathUtils::dir_sep)
in_out += PathUtils::dir_sep;
}
bool PathUtils::isRelative(const Firebird::PathName& path)
{
if (path.length() > 0)

View File

@ -130,6 +130,16 @@ void PathUtils::concatPath(Firebird::PathName& result,
result = first + second;
}
// We don't work correctly with MBCS.
void PathUtils::ensureSeparator(Firebird::PathName& in_out)
{
if (in_out.length() == 0)
in_out = PathUtils::dir_sep;
if (in_out[in_out.length() - 1] != PathUtils::dir_sep)
in_out += PathUtils::dir_sep;
}
bool PathUtils::isRelative(const Firebird::PathName& path)
{
if (path.length() > 0) {