X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=include%2Fwimlib.h;h=d22eb5811ffab8584caa3d30db7291ad0f606319;hp=09bf1052331b0369fecf6de5b8711621e30c6760;hb=ef01d3a49d4a0e83f0fb5bd6604a1b7ebeee71a1;hpb=cfa7869f8c1c7f69d9042ca2d3bc53edb31c16dd diff --git a/include/wimlib.h b/include/wimlib.h index 09bf1052..d22eb581 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -389,7 +389,7 @@ #include #include #include -#include +#include #include /** @addtogroup G_general @@ -408,6 +408,29 @@ extern "C" { #endif +/* + * To represent file timestamps, wimlib's API uses the POSIX 'struct timespec'. + * This was probably a mistake because it doesn't play well with Visual Studio. + * In old VS versions it isn't present at all; in newer VS versions it is + * supposedly present, but I wouldn't trust it to be the same size as the one + * MinGW uses. The solution is to define a compatible structure ourselves when + * this header is included on Windows and the compiler is not MinGW. + */ +#if defined(_WIN32) && !defined(__GNUC__) +typedef struct { + /* Seconds since start of UNIX epoch (January 1, 1970) */ +#ifdef _WIN64 + int64_t tv_sec; +#else + int32_t tv_sec; +#endif + /* Nanoseconds (0-999999999) */ + int32_t tv_nsec; +} wimlib_timespec; +#else +# define wimlib_timespec struct timespec /* standard definition */ +#endif + /** * Opaque structure that represents a WIM, possibly backed by an on-disk file. * See @ref sec_basic_wim_handling_concepts for more information. @@ -417,14 +440,14 @@ typedef struct WIMStruct WIMStruct; #define WIMLIB_WIMSTRUCT_DECLARED #endif -#ifdef __WIN32__ +#ifdef _WIN32 typedef wchar_t wimlib_tchar; #else /** See @ref sec_encodings */ typedef char wimlib_tchar; #endif -#ifdef __WIN32__ +#ifdef _WIN32 /** Path separator for WIM paths passed back to progress callbacks. * This is forward slash on UNIX and backslash on Windows. */ # define WIMLIB_WIM_PATH_SEPARATOR '\\' @@ -1559,13 +1582,13 @@ struct wimlib_dir_entry { uint64_t hard_link_group_id; /** Time this file was created. */ - struct timespec creation_time; + wimlib_timespec creation_time; /** Time this file was last written to. */ - struct timespec last_write_time; + wimlib_timespec last_write_time; /** Time this file was last accessed. */ - struct timespec last_access_time; + wimlib_timespec last_access_time; /** The UNIX user ID of this file. This is a wimlib extension. *