diff --git a/src/matoya.h b/src/matoya.h index 6643f062b..2f2c021d5 100644 --- a/src/matoya.h +++ b/src/matoya.h @@ -1836,10 +1836,11 @@ typedef enum { /// @brief File properties. typedef struct { - char *path; ///< The base path to the file. - char *name; ///< The file name. - uint64_t size; ///< The file size in bytes. - bool dir; ///< The file is a directory. + char *path; ///< The base path to the file. + char *name; ///< The file name. + uint64_t size; ///< The file size in bytes. + uint64_t modified_time; ///< the modified time in seconds. + bool dir; ///< The file is a directory. } MTY_FileDesc; /// @brief A list of files. @@ -2727,6 +2728,10 @@ MTY_ThreadDetach(MTY_ThreadFunc func, void *opaque); MTY_EXPORT int64_t MTY_ThreadGetID(MTY_Thread *ctx); +/// @brief Returns the process ID of the current thread. +MTY_EXPORT uint64_t +MTY_GetCurrentProcessID(); + /// @brief Create an MTY_Mutex for synchronization. /// @details A mutex can be locked by only one thread at a time. Other threads trying /// to take the same mutex will block until it becomes unlocked. diff --git a/src/unix/file.c b/src/unix/file.c index 4ef270ac7..e89e629ec 100644 --- a/src/unix/file.c +++ b/src/unix/file.c @@ -235,6 +235,7 @@ MTY_FileList *MTY_GetFileList(const char *path, const char *filter) struct stat st; if (!is_dir && stat(jpath, &st) == 0) fl->files[fl->len].size = st.st_size; + fl->files[fl->len].modified_time = st.st_mtime; fl->len++; } diff --git a/src/unix/system.c b/src/unix/system.c index eee98ba06..32abb2a6c 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -115,3 +115,8 @@ bool MTY_GetRunOnStartup(const char *name) void MTY_SetRunOnStartup(const char *name, const char *path, const char *args) { } + +uint64_t MTY_GetCurrentProcessID() +{ + return (uint64_t)getpid(); +} diff --git a/src/windows/filew.c b/src/windows/filew.c index 6f1cebf8d..04e5fce1b 100644 --- a/src/windows/filew.c +++ b/src/windows/filew.c @@ -259,6 +259,7 @@ MTY_FileList *MTY_GetFileList(const char *path, const char *filter) fl->files[fl->len].path = MTY_Strdup(MTY_JoinPath(pathd, name)); fl->files[fl->len].dir = is_dir; fl->files[fl->len].size = (uint64_t) ent.nFileSizeHigh << 32 | ent.nFileSizeLow; + fl->files[fl->len].modified_time = (uint64_t) ent.ftLastWriteTime.dwHighDateTime << 32 | ent.ftLastWriteTime.dwLowDateTime; fl->len++; } else { diff --git a/src/windows/systemw.c b/src/windows/systemw.c index 457b416aa..baf8acebc 100644 --- a/src/windows/systemw.c +++ b/src/windows/systemw.c @@ -391,3 +391,8 @@ void *MTY_GetJNIEnv(void) { return NULL; } + +uint64_t MTY_GetCurrentProcessID() +{ + return (uint64_t)GetCurrentProcessId(); +}