]> wimlib.net Git - wimlib/blobdiff - src/util.c
More accurate timestamps
[wimlib] / src / util.c
index e14ddd403f64eef883594f7a805ffec19c1e8a15..a2a50faa0614d873d8611db6fd4ee3179616d502 100644 (file)
@@ -25,6 +25,8 @@
 #include "wimlib_internal.h"
 #include "endianness.h"
 #include "sha1.h"
+#include "timestamp.h"
+#include <sys/time.h>
 
 
 #include <iconv.h>
@@ -167,8 +169,12 @@ static const char *error_strings[] = {
                = "Failed to open a directory",
        [WIMLIB_ERR_READ] 
                = "Could not read data from a file",
+       [WIMLIB_ERR_READLINK]
+               = "Could not read the target of a symbolic link",
        [WIMLIB_ERR_RENAME] 
                = "Could not rename a file",
+       [WIMLIB_ERR_SPECIAL_FILE]
+               = "Encountered a special file that cannot be archived",
        [WIMLIB_ERR_SPLIT_INVALID] 
                = "The WIM is part of an invalid split WIM",
        [WIMLIB_ERR_SPLIT_UNSUPPORTED] 
@@ -383,10 +389,8 @@ void randomize_char_array_with_alnum(char p[], size_t n)
 }
 
 /* Fills @n bytes pointer to by @p with random numbers. */
-void randomize_byte_array(void *__p, size_t n)
+void randomize_byte_array(u8 *p, size_t n)
 {
-       u8 *p = __p;
-
        if (!seeded) {
                srand(time(NULL));
                seeded = true;
@@ -428,6 +432,10 @@ const char *path_basename(const char *path)
        return p + 1;
 }
 
+/* 
+ * Returns a pointer to the part of @path following the first colon in the last
+ * path component, or NULL if the last path component does not contain a colon.
+ */
 const char *path_stream_name(const char *path)
 {
        const char *base = path_basename(path);
@@ -497,3 +505,12 @@ void print_string(const void *string, size_t len)
                p++;
        }
 }
+
+u64 get_wim_timestamp()
+{
+       struct timeval tv;
+       gettimeofday(&tv, NULL);
+       return timeval_to_wim_timestamp(&tv);
+}
+
+