* @param the status info given by <code>lstat()</code>
*/
struct stat& ReDirectory::currentLStat(){
+#if defined linux
if (m_stat.st_gid == (mode_t)-1 && filetimeIsUndefined(m_stat.st_mtim)){
lstat(currentFull().str(), &m_stat);
}
+#elif defined __WIN32__
+ if (m_stat.st_mtime == (time_t) -1){
+ stat(currentFull().str(), &m_stat);
+ }
+#endif
return m_stat;
}
#if defined __linux__
return S_ISDIR(currentLStat().st_mode);
#elif defined __WIN32__
- return
+ return (m_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
#endif
}
#if defined __linux__
return currentLStat().st_mtim;
#elif defined __WIN32__
- return
+ return m_data.ftLastWriteTime;
#endif
}
bool rc = stat(filename, &info) == 0;
if (rc){
if (modified != NULL)
- ;
+ *m_modified = info.st_mtim;
+ if (created != NULL)
+ *created = info.st_ctim;
+ if (accessed != NULL
+ *accessed = info.st_atim;
}
#elif defined __WIN32__
+ HANDLE handle = CreateFile(filename, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);\r
+ bool rc = handle != INVALID_HANDLE_VALUE;\r
+ if (rc){\r
+ if (GetFileTime(handle, created, accessed, modified) == 0)\r
+ rc = false;\r
+ CloseHandle(handle);\r
+ }
#endif
return rc;
}
bool rc = false;
m_currentFull.clear();
m_stat.st_gid = -1;
+#ifdef linux
setFiletimeUndef(m_stat.st_mtim);
+#elif defined __WIN32__
+ m_stat.st_mtime = (time_t) -1;
+#endif
if (m_valid) {
#if defined __linux__
while (!rc && (m_entry = readdir(m_dir)) != NULL) {
#if defined __linux__
return op1.tv_sec == op2.tv_sec && op1.tv_nsec == op2.tv_nsec;
#else
- return time1.dwHighDateTime == time2.dwHighDateTime
- && time1.dwLowDateTime == time2.dwLowDateTime;
+ return op1.dwHighDateTime == op2.dwHighDateTime
+ && op1.dwLowDateTime == op2.dwLowDateTime;
#endif
}
/** Returns whether a filetime is equal than another.
#if defined __linux__
return op1.tv_sec > op2.tv_sec || op1.tv_sec == op2.tv_sec && op1.tv_nsec > op2.tv_nsec;
#else
- return time1.dwHighDateTime > time2.dwHighDateTime
- || (time1.dwHighDateTime == time2.dwHighDateTime
- && time1.dwLowDateTime > time2.dwLowDateTime);
+ return op1.dwHighDateTime > op2.dwHighDateTime
+ || (op1.dwHighDateTime == op2.dwHighDateTime
+ && op1.dwLowDateTime > op2.dwLowDateTime);
#endif
}
/** Returns whether a filetime is greater (younger) or equal than another.
#if defined __linux__
return op1.tv_sec > op2.tv_sec || op1.tv_sec == op2.tv_sec && op1.tv_nsec >= op2.tv_nsec;
#else
- return time1.dwHighDateTime > time2.dwHighDateTime
- || (time1.dwHighDateTime == time2.dwHighDateTime
- && time1.dwLowDateTime >= time2.dwLowDateTime);
+ return op1.dwHighDateTime > op2.dwHighDateTime
+ || (op1.dwHighDateTime == op2.dwHighDateTime
+ && op1.dwLowDateTime >= op2.dwLowDateTime);
#endif
}
/** Returns whether a filetime is lower (younger) than another.
*/
void ReSerializable::packFileTime(ReByteArray& sequence,
const ReFileTime_t& time) {
- uint64_t value;
#if defined __linux__
- value = (time.tv_sec << 32) + time.tv_nsec;
- sequence.appendBits64(int64_t(value));
+ sequence.appendBits64(((int64_t) time.tv_sec << 32) + time.tv_nsec);
#elif defined __WIN32__
-//#error "missing impl"
- assert(false);
+ sequence.appendBits64((int64_t(time.dwHighDateTime) << 32) + time.dwLowDateTime);
#endif
}
/**
typedef u_int8_t uint8_t;
typedef __off_t ReFileSize_t;
typedef struct timespec ReFileTime_t;
+# define _unlink unlink
# define _strdup strdup
# define _unlink unlink
# define _strnicmp(s1, s2, n) strncasecmp(s1, s2, n)
#if defined __linux__
return data.tv_sec;
#elif defined __WIN32__
- return (int) ReDirStatus_t::filetimeToTime(&data);
+ return (int) ReFileUtils::filetimeToTime(&data);
#endif
}
const char* makeDir(const char* relPath) {
for(const char** pFile = s_allFiles; *pFile != NULL; pFile++){
ReByteArray fullTarget(target);
fullTarget.append(*pFile);
- if (fullTarget.endsWith(".txt") || ! fullTarget.contains("cache") >= 0){
- checkT(stat(fullTarget.str(), &info));
+ if (fullTarget.endsWith(".txt") || ! fullTarget.contains("cache")){
+ checkT(stat(fullTarget.str(), &info) != 0);
} else {
- checkF(stat(fullTarget.str(), &info));
+ checkF(stat(fullTarget.str(), &info) != 0);
}
}
static const char* content =
void testSetFiles(){
ReByteArray name = ReFileUtils::tempFile("setfile_test.dat");
struct stat info;
- unlink(name.str());
+ _unlink(name.str());
ReFileUtils::writeString(name.str(), "");
checkEqu(0, stat(name.str(), &info));
struct tm time1;
ReFileUtils::timeToFiletime(time2 + diff, time4);
ReFileUtils::setTimes(name.str(), time3, &time4, NULL);
checkEqu(0, stat(name.str(), &info));
+#if defined __linux__
checkT(time2 == info.st_mtim.tv_sec);
checkT(time2 + diff == info.st_atim.tv_sec);
+#elif defined __WIN32__
+ checkT(time2 == info.st_mtime);
+ checkT(time2 + diff == info.st_atime);
+#endif
}
void testTempFile(){
const char* subdir = "refileutiltest";
} while (rc != ReNetCommandHandler::PS_STOP && !m_shouldStop);
m_pool->setShouldStop();
} catch (ReTCPDisconnectException& e) {
+ reUseParam(e);
rc = ReNetCommandHandler::PS_CLOSED;
}
close();
fprintf(output, "%c%s%s\n", prefix, source, changed.str());
}
#else
-#error "not implemented"
+ // nothing to do
#endif
return rc;
}
return rc;
}
-static void printStatus(FILE* fp, double duration, int files, int sumSizes,
+static void printStatus(FILE* fp, double duration, int files, int64_t sumSizes,
int treeDirs, int treeFiles, int64_t treeSumSizes) {
fprintf(fp,
i18n(
ReFileProperties_t* srcProps, const char* target, struct stat* trgProps,
VerboseLevel verbose = V_QUIET, char prefix = ':', FILE* output = NULL,
ReLogger* logger = NULL);
+
static bool copyFile(const char* source, bool isLink,
ReFileProperties_t* properties, const char* target, ReByteArray& buffer,
ReLogger* logger = NULL);
sequence.appendBits64(int64_t(value));
value = (m_minAge.tv_sec << 32) + m_minAge.tv_nsec;
#elif defined __WIN32__
-// #error "missing impl"
- assert(false);
+ value = (int64_t(m_minAge.dwHighDateTime) << 32) + m_minAge.dwLowDateTime;
#endif
sequence.appendBits64(int64_t(value));
packBool(sequence, m_allDirectories);