Skip to content

Commit

Permalink
HPCC-32639 Use function to append path part ensuring separator
Browse files Browse the repository at this point in the history
Adjust code in two places to use an inline function that ensures one
path separator between path parts when appending.

Signed-off-by: Terrence Asselin <terrence.asselin@lexisnexisrisk.com>
  • Loading branch information
asselitx committed Oct 1, 2024
1 parent 9d9ef75 commit cee6554
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,16 @@ inline unsigned groupDistance(IGroup *grp1,IGroup *grp2)
return grp1->distance(grp2);
}

inline StringBuffer &appendEnsurePathSepChar(StringBuffer &dest, StringBuffer &newPart, char psc)
{
addPathSepChar(dest, psc);
if (isPathSepChar(newPart.charAt(0)))
dest.append(newPart.str()+1);
else
dest.append(newPart);
return dest;
}


static StringBuffer &normalizeFormat(StringBuffer &in)
{
Expand Down Expand Up @@ -4474,12 +4484,8 @@ protected: friend class CDistributedFilePart;
if (isPathSepChar(newPath.charAt(newPath.length()-1)))
newPath.setLength(newPath.length()-1);
newPath.remove(0, myBase.length());
// Ensure one path separator between baseDir and newPath
newdir.append(addPathSepChar(baseDir, psc));
if (isPathSepChar(newPath.charAt(0)))
newdir.append(newPath.str()+1);
else
newdir.append(newPath);
newdir.append(baseDir);
appendEnsurePathSepChar(newdir, newPath, psc);
StringBuffer fullname;
CIArrayOf<CIStringArray> newNames;
unsigned i;
Expand All @@ -4498,7 +4504,8 @@ protected: friend class CDistributedFilePart;

StringBuffer copyDir(baseDir);
adjustClusterDir(i, copy, copyDir);
fullname.clear().append(copyDir).append(newPath);
fullname.clear().append(copyDir);
appendEnsurePathSepChar(fullname, newPath, psc);
newNames.item(i).append(fullname);
}
}
Expand Down

0 comments on commit cee6554

Please sign in to comment.