|
@@ -1151,45 +1151,79 @@ bool dPathCopy(const char *fromName, const char *toName, bool nooverwrite)
|
|
DIR *dip;
|
|
DIR *dip;
|
|
struct dirent *d;
|
|
struct dirent *d;
|
|
|
|
|
|
- if (subPath && (dStrncmp(subPath, "", 1) != 0))
|
|
|
|
- {
|
|
|
|
- if ((basePath[dStrlen(basePath) - 1]) == '/')
|
|
|
|
- dSprintf(Path, 1024, "%s%s", basePath, subPath);
|
|
|
|
- else
|
|
|
|
- dSprintf(Path, 1024, "%s/%s", basePath, subPath);
|
|
|
|
- }
|
|
|
|
|
|
+ dsize_t trLen = basePath ? dStrlen(basePath) : 0;
|
|
|
|
+ dsize_t subtrLen = subPath ? dStrlen(subPath) : 0;
|
|
|
|
+ char trail = trLen > 0 ? basePath[trLen - 1] : '\0';
|
|
|
|
+ char subTrail = subtrLen > 0 ? subPath[subtrLen - 1] : '\0';
|
|
|
|
+ char subLead = subtrLen > 0 ? subPath[0] : '\0';
|
|
|
|
+
|
|
|
|
+ if (trail == '/')
|
|
|
|
+ {
|
|
|
|
+ if (subPath && (dStrncmp(subPath, "", 1) != 0))
|
|
|
|
+ {
|
|
|
|
+ if (subTrail == '/')
|
|
|
|
+ dSprintf(Path, 1024, "%s%s", basePath, subPath);
|
|
|
|
+ else
|
|
|
|
+ dSprintf(Path, 1024, "%s%s/", basePath, subPath);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ dSprintf(Path, 1024, "%s", basePath);
|
|
|
|
+ }
|
|
else
|
|
else
|
|
- dSprintf(Path, 1024, "%s", basePath);
|
|
|
|
|
|
+ {
|
|
|
|
+ if (subPath && (dStrncmp(subPath, "", 1) != 0))
|
|
|
|
+ {
|
|
|
|
+ if (subTrail == '/')
|
|
|
|
+ dSprintf(Path, 1024, "%s%s", basePath, subPath);
|
|
|
|
+ else
|
|
|
|
+ dSprintf(Path, 1024, "%s%s/", basePath, subPath);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ dSprintf(Path, 1024, "%s/", basePath);
|
|
|
|
+ }
|
|
|
|
+
|
|
dip = opendir(Path);
|
|
dip = opendir(Path);
|
|
if (dip == NULL)
|
|
if (dip == NULL)
|
|
return false;
|
|
return false;
|
|
|
|
+
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// add path to our return list ( provided it is valid )
|
|
// add path to our return list ( provided it is valid )
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
if (!Platform::isExcludedDirectory(subPath))
|
|
if (!Platform::isExcludedDirectory(subPath))
|
|
- {
|
|
|
|
- if (noBasePath)
|
|
|
|
- {
|
|
|
|
- // We have a path and it's not an empty string or an excluded directory
|
|
|
|
- if ( (subPath && (dStrncmp (subPath, "", 1) != 0)) )
|
|
|
|
- directoryVector.push_back(StringTable->insert(subPath));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- if ( (subPath && (dStrncmp(subPath, "", 1) != 0)) )
|
|
|
|
- {
|
|
|
|
- char szPath[1024];
|
|
|
|
- dMemset(szPath, 0, 1024);
|
|
|
|
- if ( (basePath[dStrlen(basePath) - 1]) != '/')
|
|
|
|
- dSprintf(szPath, 1024, "%s%s", basePath, subPath);
|
|
|
|
- else
|
|
|
|
- dSprintf(szPath, 1024, "%s%s", basePath, &subPath[1]);
|
|
|
|
- directoryVector.push_back(StringTable->insert(szPath));
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- directoryVector.push_back(StringTable->insert(basePath));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ {
|
|
|
|
+ if (noBasePath)
|
|
|
|
+ {
|
|
|
|
+ // We have a path and it's not an empty string or an excluded directory
|
|
|
|
+ if ( (subPath && (dStrncmp (subPath, "", 1) != 0)) )
|
|
|
|
+ directoryVector.push_back(StringTable->insert(subPath));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if ( (subPath && (dStrncmp(subPath, "", 1) != 0)) )
|
|
|
|
+ {
|
|
|
|
+ char szPath[1024];
|
|
|
|
+ dMemset(szPath, 0, 1024);
|
|
|
|
+ if (trail == '/')
|
|
|
|
+ {
|
|
|
|
+ if ((basePath[dStrlen(basePath) - 1]) != '/')
|
|
|
|
+ dSprintf(szPath, 1024, "%s%s", basePath, &subPath[1]);
|
|
|
|
+ else
|
|
|
|
+ dSprintf(szPath, 1024, "%s%s", basePath, subPath);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if ((basePath[dStrlen(basePath) - 1]) != '/')
|
|
|
|
+ dSprintf(szPath, 1024, "%s%s", basePath, subPath);
|
|
|
|
+ else
|
|
|
|
+ dSprintf(szPath, 1024, "%s/%s", basePath, subPath);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ directoryVector.push_back(StringTable->insert(szPath));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ directoryVector.push_back(StringTable->insert(basePath));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Iterate through and grab valid directories
|
|
// Iterate through and grab valid directories
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//////////////////////////////////////////////////////////////////////////
|