mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
add fs_file_time
This commit is contained in:
parent
355466e0bf
commit
c89cdc6806
|
@ -2347,6 +2347,34 @@ int fs_rename(const char *oldname, const char *newname)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fs_file_time(const char *name, time_t *created, time_t *modified)
|
||||
{
|
||||
#if defined(CONF_FAMILY_WINDOWS)
|
||||
WIN32_FIND_DATAW finddata;
|
||||
HANDLE handle;
|
||||
WCHAR wBuffer[IO_MAX_PATH_LENGTH];
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, name, IO_MAX_PATH_LENGTH, wBuffer, IO_MAX_PATH_LENGTH);
|
||||
handle = FindFirstFileW(wBuffer, &finddata);
|
||||
if(handle == INVALID_HANDLE_VALUE)
|
||||
return 1;
|
||||
|
||||
*created = filetime_to_unixtime(&finddata.ftCreationTime);
|
||||
*modified = filetime_to_unixtime(&finddata.ftLastWriteTime);
|
||||
#elif defined(CONF_FAMILY_UNIX)
|
||||
struct stat sb;
|
||||
if(stat(name, &sb))
|
||||
return 1;
|
||||
|
||||
*created = sb.st_ctime;
|
||||
*modified = sb.st_mtime;
|
||||
#else
|
||||
#error not implemented
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void swap_endian(void *data, unsigned elem_size, unsigned num)
|
||||
{
|
||||
char *src = (char *)data;
|
||||
|
|
|
@ -1760,6 +1760,23 @@ int fs_remove(const char *filename);
|
|||
*/
|
||||
int fs_rename(const char *oldname, const char *newname);
|
||||
|
||||
/*
|
||||
Function: fs_file_time
|
||||
Gets the creation and the last modification date of a file.
|
||||
|
||||
Parameters:
|
||||
name - The filename.
|
||||
created - Pointer to time_t
|
||||
modified - Pointer to time_t
|
||||
|
||||
Returns:
|
||||
0 on success non-zero on failure
|
||||
|
||||
Remarks:
|
||||
- Returned time is in seconds since UNIX Epoch
|
||||
*/
|
||||
int fs_file_time(const char *name, time_t *created, time_t *modified);
|
||||
|
||||
/*
|
||||
Group: Undocumented
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue