disk_cache: move get_cache_file() to an OS specific helper

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6197>
diff --git a/src/util/disk_cache.c b/src/util/disk_cache.c
index 577c7b9..8d6817f 100644
--- a/src/util/disk_cache.c
+++ b/src/util/disk_cache.c
@@ -224,34 +224,12 @@
    util_queue_finish(&cache->cache_queue);
 }
 
-/* Return a filename within the cache's directory corresponding to 'key'. The
- * returned filename is ralloced with 'cache' as the parent context.
- *
- * Returns NULL if out of memory.
- */
-static char *
-get_cache_file(struct disk_cache *cache, const cache_key key)
-{
-   char buf[41];
-   char *filename;
-
-   if (cache->path_init_failed)
-      return NULL;
-
-   _mesa_sha1_format(buf, key);
-   if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
-                buf[1], buf + 2) == -1)
-      return NULL;
-
-   return filename;
-}
-
 void
 disk_cache_remove(struct disk_cache *cache, const cache_key key)
 {
    struct stat sb;
 
-   char *filename = get_cache_file(cache, key);
+   char *filename = disk_cache_get_cache_filename(cache, key);
    if (filename == NULL) {
       return;
    }
@@ -348,7 +326,7 @@
    char *filename = NULL;
    struct disk_cache_put_job *dc_job = (struct disk_cache_put_job *) job;
 
-   filename = get_cache_file(dc_job->cache, dc_job->key);
+   filename = disk_cache_get_cache_filename(dc_job->cache, dc_job->key);
    if (filename == NULL)
       goto done;
 
@@ -474,7 +452,7 @@
       return blob;
    }
 
-   filename = get_cache_file(cache, key);
+   filename = disk_cache_get_cache_filename(cache, key);
    if (filename == NULL)
       goto fail;
 
diff --git a/src/util/disk_cache_os.c b/src/util/disk_cache_os.c
index a6c7504..2888582 100644
--- a/src/util/disk_cache_os.c
+++ b/src/util/disk_cache_os.c
@@ -438,6 +438,28 @@
       p_atomic_add(cache->size, - (uint64_t)size);
 }
 
+/* Return a filename within the cache's directory corresponding to 'key'. The
+ * returned filename is ralloced with 'cache' as the parent context.
+ *
+ * Returns NULL if out of memory.
+ */
+char *
+disk_cache_get_cache_filename(struct disk_cache *cache, const cache_key key)
+{
+   char buf[41];
+   char *filename;
+
+   if (cache->path_init_failed)
+      return NULL;
+
+   _mesa_sha1_format(buf, key);
+   if (asprintf(&filename, "%s/%c%c/%s", cache->path, buf[0],
+                buf[1], buf + 2) == -1)
+      return NULL;
+
+   return filename;
+}
+
 void
 disk_cache_write_item_to_disk(struct disk_cache_put_job *dc_job,
                               struct cache_entry_file_data *cf_data,
diff --git a/src/util/disk_cache_os.h b/src/util/disk_cache_os.h
index da5b6a3..0410254 100644
--- a/src/util/disk_cache_os.h
+++ b/src/util/disk_cache_os.h
@@ -100,6 +100,9 @@
 void
 disk_cache_evict_lru_item(struct disk_cache *cache);
 
+char *
+disk_cache_get_cache_filename(struct disk_cache *cache, const cache_key key);
+
 void
 disk_cache_write_item_to_disk(struct disk_cache_put_job *dc_job,
                               struct cache_entry_file_data *cf_data,