exit(1);
}
-static char *format_file_hash(struct file_hash *file_hash)
-{
- char *ret;
- int i;
-
- ret = x_malloc(53);
- for (i = 0; i < 16; i++) {
- sprintf(&ret[i*2], "%02x", (unsigned)file_hash->hash[i]);
- }
- sprintf(&ret[i*2], "-%u", (unsigned)file_hash->size);
-
- return ret;
-}
-
/*
* Transform a name to a full path into the cache directory, creating needed
* sublevels if needed. Caller frees.
break;
}
- object_name = format_file_hash(object_hash);
+ object_name = format_hash_as_string(object_hash->hash, object_hash->size);
cached_obj = get_path_in_cache(object_name, ".o");
cached_stderr = get_path_in_cache(object_name, ".stderr");
cached_dep = get_path_in_cache(object_name, ".d");
int create_dir(const char *dir);
const char *tmp_string(void);
+char *format_hash_as_string(const unsigned char *hash, unsigned size);
int create_hash_dir(char **dir, const char *hash, const char *cache_dir);
int create_cachedirtag(const char *dir);
void x_asprintf(char **ptr, const char *format, ...) ATTR_FORMAT(printf, 2, 3);
return ret;
}
+char *format_hash_as_string(const unsigned char *hash, unsigned size)
+{
+ char *ret;
+ int i;
+
+ ret = x_malloc(53);
+ for (i = 0; i < 16; i++) {
+ sprintf(&ret[i*2], "%02x", (unsigned) hash[i]);
+ }
+ sprintf(&ret[i*2], "-%u", size);
+
+ return ret;
+}
+
char const CACHEDIR_TAG[] =
"Signature: 8a477f597d28d172789f06886806bc55\n"
"# This file is a cache directory tag created by ccache.\n"