Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/matoya.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/unix/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down
5 changes: 5 additions & 0 deletions src/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
1 change: 1 addition & 0 deletions src/windows/filew.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/windows/systemw.c
Original file line number Diff line number Diff line change
Expand Up @@ -391,3 +391,8 @@ void *MTY_GetJNIEnv(void)
{
return NULL;
}

uint64_t MTY_GetCurrentProcessID()
{
return (uint64_t)GetCurrentProcessId();
}