extern void* memcpy (void* dest, const void* src, size_t n);
extern void* memmove (void* dest, const void* src, size_t n);
extern int _memcmp (const void* s1, const void* s2, size_t n);
-extern int snprintf (char* s, size_t maxlen, const char* format, ...);
+extern int _snprintf (char* s, size_t maxlen, const char* format, ...);
#endif
/** @brief Constructor.
ReByteBuffer& ReByteBuffer::appendInt(int number, const char* format){
char buffer [128];
- snprintf(buffer, sizeof buffer, format, number);
+ _snprintf(buffer, sizeof buffer, format, number);
size_t length = strlen(buffer);
ensureSize(m_length + length);
int rc = -1;
if (start < 0)
rc = 0;
- else if (start < m_length){
+ else if (start < (int) m_length){
if (length == -1)
length = strlen(source);
int count = length > m_length - start ? m_length - start : length;
m_message(NULL)
{
char buffer[512];
- snprintf(buffer, sizeof buffer, "%s [%.100s-%d]", message, file, lineNo);
+ _snprintf(buffer, sizeof buffer, "%s [%.100s-%d]", message, file, lineNo);
m_message = _strdup(buffer);
}
/** @brief Destructor.
ReException()
{
char buffer[512];
- snprintf(buffer, sizeof buffer, "%s%s", message, format == NULL ? "" : format);
+ _snprintf(buffer, sizeof buffer, "%s%s", message, format == NULL ? "" : format);
m_message = _strdup(buffer);
}
ReException()
{
char buffer[512];
- snprintf(buffer, sizeof buffer, "%s%s [%.100s-%d]",
+ _snprintf(buffer, sizeof buffer, "%s%s [%.100s-%d]",
message, format == NULL ? "" : format, file, lineNo);
m_message = _strdup(buffer);
}
char buffer[256];
const char* format = index < bound
? i18n("%s: index underflow: %d / %d") : i18n("%s: index overflow: %d / %d");
- snprintf(buffer, sizeof buffer, format, name, index, bound);
+ _snprintf(buffer, sizeof buffer, format, name, index, bound);
m_message = _strdup(buffer);
}
/** @brief Constructor.
char buffer[256];
const char* format = index < bound
? i18n("%s: index underflow: %d / %d [%s-%d]") : i18n("%s: index overflow: %d / %d [%s-%d]");
- snprintf(buffer, sizeof buffer, format, name, index, bound, file, line);
+ _snprintf(buffer, sizeof buffer, format, name, index, bound, file, line);
m_message = _strdup(buffer);
}
const char* first = strchr(pattern, '*');
size_t len;
if (first == NULL){
- snprintf(m_filePattern, sizeof m_filePattern, "%s.%s.log", pattern, placeholder);
+ _snprintf(m_filePattern, sizeof m_filePattern, "%s.%s.log", pattern, placeholder);
} else {
len = first - pattern;
memcpy(m_filePattern, pattern, len);
// Delete some of the oldest files to make room for the new:
for (int ii = 0; ii < int(FILENO_UBOUND - m_maxFiles); ii++){
int fileNo = (FILENO_UBOUND + m_currentFileNo - m_maxFiles - ii) % m_maxFiles;
- snprintf(filename, sizeof filename, m_filePattern, fileNo);
+ _snprintf(filename, sizeof filename, m_filePattern, fileNo);
struct stat info;
if (lstat(filename, &info) == 0)
_unlink(filename);
}
if (++m_currentFileNo >= FILENO_UBOUND)
m_currentFileNo = 0;
- snprintf(filename, sizeof filename, m_filePattern, m_currentFileNo);
+ _snprintf(filename, sizeof filename, m_filePattern, m_currentFileNo);
m_stream = fopen(filename, "w");
m_currentSize = 0;
}
const char* format){
if (m_locationOfOpenSayF != 0){
char message[128];
- snprintf(message, sizeof message, "missing ReLogger::end(): Location: %d",
+ _snprintf(message, sizeof message, "missing ReLogger::end(): Location: %d",
m_locationOfOpenSayF);
say(LOG_ERROR|GRAN_USER|CAT_LIB, LC_LOGGER_SAYF_OPEN, message);
}
"%Y.%m.%d %H:%M:%S", now1);
size_t len = strlen(m_standardPrefix);
char* ptr = m_standardPrefix + len;
- snprintf (ptr, sizeof m_standardPrefix - len, " %ld: ",
+ _snprintf (ptr, sizeof m_standardPrefix - len, " %ld: ",
(long) m_location);
}
return m_standardPrefix;
if (ix < 0){
ReByteBuffer line1(list1.strOf(ix), list1.strLengthOf(ix));
int ixLine = line1.firstDifference(list2.strOf(ix), list2.strLengthOf(ix));
- logF(true, i18n("%s-%d: Files differ in line %d-%d\%s\n%s\n%s"),
+ logF(true, i18n("%s-%d: Files differ in line %d-%d\n%s\n%s\n%s"),
m_sourceFile, lineNo, ix, ixLine, list1.strOf(ix), list2.strOf(ix),
colMarker(ixLine));
}
_mkdir(name);
else{
char cmd[512 + 128];
- snprintf(cmd, sizeof cmd, "rm -Rf %s*", name);
+ _snprintf(cmd, sizeof cmd, "rm -Rf %s*", name);
system(cmd);
}
strcpy(m_tempDir, name);
for (int ii = 1; ii < m_maxArgNo; ii++)
if (m_args[ii] == 0){
char msg[128];
- snprintf(msg, sizeof msg, i18n("missing $%d in format: "), ii);
+ _snprintf(msg, sizeof msg, i18n("missing $%d in format: "), ii);
throw ReFormatException(msg, format);
}
*/
ReVarArgs& ReVarArgs::arg(int value, const char* format){
char number[256];
- snprintf(number, sizeof number, format, value);
+ _snprintf(number, sizeof number, format, value);
store(number);
return *this;
}
*/
ReVarArgs& ReVarArgs::arg(long value, const char* format){
char number[256];
- snprintf(number, sizeof number, format, value);
+ _snprintf(number, sizeof number, format, value);
store(number);
return *this;
}
*/
ReVarArgs& ReVarArgs::arg(double value, const char* format){
char number[256];
- snprintf(number, sizeof number, format, value);
+ _snprintf(number, sizeof number, format, value);
store(number);
return *this;
}
#elif defined __WIN32__
# include <direct.h>
# include <windows.h>
+# define _memcmp(t,s,n) memcmp(t,s,n)
typedef _int64 int64_t;
# define S_ISDIR(mode) (((mode) & _S_IFDIR) != 0)
#endif
testDirStatistic();
testBasic();
testCopyFile();
+ testList();
}
+ void testList(){
+ ReDirTools tools;
+ const char* argv[] = { "list", m_base.str(), NULL };
+ tools.list(2, argv);
+ }
void testCopyFile(){
ReByteBuffer src(m_base);
src.append("dir1/dir1_2/dir1_2_1/x1.txt");
ReByteBuffer buffer;
buffer.ensureSize(5);
ReDirSync::copyFile(src.str(), 0, -1ll, trg.str(), buffer, ReLogger::globalLogger());
- //checkFile();
+ checkFileEqu(src.str(), trg.str());
}
+
void checkRelDate(time_t absTime, int relTime){
int diff = int(time(NULL) - relTime - absTime);
if (diff < 0)
void testBase(){
extern void testReTestUnit();
- testReTestUnit();
+ //testReTestUnit();
extern void testReByteBuffer();
testReByteBuffer();
extern void testReSeqList(void);
line.setLength(0);
// Round up to the next KiByte:
char buffer[256];
- snprintf(buffer, sizeof buffer, "%14.6f MB %7d %7d\t",
+ _snprintf(buffer, sizeof buffer, "%14.6f MB %7d %7d\t",
data.m_sizes / 1E6, data.m_files, data.m_dirs);
line.append(buffer, -1).append(data.m_path);
}
bool verbose = ! m_programArgs.getBool("quiet");
bool shortOutput = m_programArgs.getBool("short");
setFilterFromProgramArgs(filter);
- if (m_programArgs.getArgCount() == 0)
- help(i18n("no arguments given (missing path)"));
+ bool noPath = m_programArgs.getArgCount() == 0;
ReByteBuffer bufferRights;
ReByteBuffer bufferTime;
int64_t sumSizes = 0;
int files = 0;
int dirs = 0;
- for (int ix = 0; ix < m_programArgs.getArgCount(); ix++){
- ReTraverser traverser(m_programArgs.getArg(ix));
+
+ for (int ix = 0; noPath || ix < m_programArgs.getArgCount(); ix++){
+ ReTraverser traverser(noPath ? "." : m_programArgs.getArg(ix));
+ noPath = false;
traverser.setMinLevel(filter.m_maxDepth);
traverser.setMaxLevel(filter.m_maxDepth);
int level;