- size_t i;
- const char *next_part;
-
- i = 0;
- while (path[i] != '/' && path[i] != '\0')
- i++;
- if (first_part_len_ret)
- *first_part_len_ret = i;
- next_part = &path[i];
- while (*next_part == '/')
- next_part++;
- return next_part;
-}
-
-/* Returns the number of components of @path. */
-int
-get_num_path_components(const char *path)
-{
- int num_components = 0;
- while (*path) {
- while (*path == '/')
- path++;
- if (*path)
- num_components++;
- while (*path && *path != '/')
- path++;
- }
- return num_components;
-}
-
-
-/*
- * Prints a string. Printable characters are printed as-is, while unprintable
- * characters are printed as their octal escape codes.
- */
-void
-print_string(const void *string, size_t len)
-{
- const u8 *p = string;
-
- while (len--) {
- if (isprint(*p))
- putchar(*p);
- else
- printf("\\%03hho", *p);
- p++;
- }
-}
-
-u64
-get_wim_timestamp()
-{
- struct timeval tv;
- gettimeofday(&tv, NULL);
- return timeval_to_wim_timestamp(tv);
-}
-
-void
-wim_timestamp_to_str(u64 timestamp, char *buf, size_t len)
-{
- struct tm tm;
- time_t t = wim_timestamp_to_unix(timestamp);
- gmtime_r(&t, &tm);
- strftime(buf, len, "%a %b %d %H:%M:%S %Y UTC", &tm);