LC_SET_PROPERTIES_2, // 50110
LC_SET_PROPERTIES_3, // 50111
};
-const char* ReDirTools::m_version = "2015.01.06";
+const char* ReDirTools::m_version = "2015.01.30";
static const char* s_helpSummary[] = {
"dirtool or dt <command> <opts>",
#elif defined __WIN32__
BOOL dummy;
rc = CopyFileEx(source, target, NULL, NULL, &dummy, COPY_FILE_NO_BUFFERING) != 0;
+ int errNo = 0;
+ if (! rc)
+ errNo = GetLastError();
#endif
return rc;
}
// for all parents and the full path itself:
while(ixSlash >= 0){
ixSlash = path.indexOf(OS_SEPARATOR_CHAR, ixSlash + 1);
+ if (ixSlash >= path.length() - 1)
+ break;
// is the slash in front of the first node, e.g. 'e:\'?
if (ixSlash == start + 1)
// not a real node: take the next node
if (m_programArgs.getArgCount() < 2)
help(i18n("missing argument(s) (source / target)"));
ReByteBuffer target(m_programArgs.getArg(m_programArgs.getArgCount() - 1));
- if (! target.endsWith(sep, 1))
- target.append(sep, 1);
+ if (target.endsWith(sep, 1))
+ target.setLength(target.length() - 1);
if (stat(target.str(), &info) != 0)
help(i18n("target does not exist: $1"), target.str());
else if (! S_ISDIR(info.st_mode))
for (int ix = 0; ix < m_programArgs.getArgCount() - 1; ix++){
source.set(m_programArgs.getArg(ix), -1);
target.setLength(lengthTargetBase);
-
- if (stat(target.str(), &info) != 0)
+ bool endsWithSlash = source.endsWith(sep, 1);
+ if (endsWithSlash)
+ source.setLength(source.length() - 1);
+ if (stat(source.str(), &info) != 0)
help(i18n("source does not exist: $1"), source.str());
else if (! S_ISDIR(info.st_mode))
help(i18n("source is not a directory: $1"), source.str());
- if (! source.endsWith(sep, 1)){
+ if (! endsWithSlash){
// the basename of the source will be appended to the target:
int startNode = source.rindexOf(sep, 1, 0, source.length() - 1);
+ target.append(OS_SEPARATOR, 1);
target.append(source.str() + startNode + 1, -1);
}
size_t ixSourceRelative = source.length();