2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
* Copyright 2011-2022 Blender Foundation */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
#ifndef __UTIL_PATH_H__
|
|
|
|
|
#define __UTIL_PATH_H__
|
|
|
|
|
|
|
|
|
|
/* Utility functions to get paths to files distributed with the program. For
|
|
|
|
|
* the standalone apps, paths are relative to the executable, for dynamically
|
|
|
|
|
* linked libraries, the path to the library may be set with path_init, which
|
|
|
|
|
* then makes all paths relative to that. */
|
|
|
|
|
|
2014-01-11 00:47:58 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/set.h"
|
|
|
|
|
#include "util/string.h"
|
|
|
|
|
#include "util/types.h"
|
|
|
|
|
#include "util/vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2014-01-23 01:13:09 +01:00
|
|
|
/* program paths */
|
2022-01-10 16:05:17 +01:00
|
|
|
void path_init(const string &path = "", const string &user_path = "");
|
2011-04-27 11:58:34 +00:00
|
|
|
string path_get(const string &sub = "");
|
2011-09-09 12:04:39 +00:00
|
|
|
string path_user_get(const string &sub = "");
|
2016-09-05 16:41:08 +02:00
|
|
|
string path_cache_get(const string &sub = "");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-01-23 01:13:09 +01:00
|
|
|
/* path string manipulation */
|
2011-04-27 11:58:34 +00:00
|
|
|
string path_filename(const string &path);
|
|
|
|
|
string path_dirname(const string &path);
|
|
|
|
|
string path_join(const string &dir, const string &file);
|
2011-09-08 18:58:07 +00:00
|
|
|
string path_escape(const string &path);
|
2014-03-21 17:22:41 +01:00
|
|
|
bool path_is_relative(const string &path);
|
2014-01-23 01:13:09 +01:00
|
|
|
|
|
|
|
|
/* file info */
|
2016-02-05 09:09:39 +01:00
|
|
|
size_t path_file_size(const string &path);
|
2011-09-08 18:58:07 +00:00
|
|
|
bool path_exists(const string &path);
|
2016-02-05 09:09:39 +01:00
|
|
|
bool path_is_directory(const string &path);
|
2011-09-03 10:49:54 +00:00
|
|
|
string path_files_md5_hash(const string &dir);
|
2014-01-23 01:13:09 +01:00
|
|
|
uint64_t path_modified_time(const string &path);
|
2011-09-03 10:49:54 +00:00
|
|
|
|
2014-01-23 01:13:09 +01:00
|
|
|
/* directory utility */
|
2011-09-12 13:13:56 +00:00
|
|
|
void path_create_directories(const string &path);
|
2014-01-23 01:13:09 +01:00
|
|
|
|
|
|
|
|
/* file read/write utilities */
|
|
|
|
|
FILE *path_fopen(const string &path, const string &mode);
|
|
|
|
|
|
2011-09-09 12:04:39 +00:00
|
|
|
bool path_write_binary(const string &path, const vector<uint8_t> &binary);
|
2013-05-27 16:21:07 +00:00
|
|
|
bool path_write_text(const string &path, string &text);
|
2011-09-09 12:04:39 +00:00
|
|
|
bool path_read_binary(const string &path, vector<uint8_t> &binary);
|
2012-11-03 14:32:35 +00:00
|
|
|
bool path_read_text(const string &path, string &text);
|
|
|
|
|
|
2016-02-05 09:09:39 +01:00
|
|
|
/* File manipulation. */
|
|
|
|
|
bool path_remove(const string &path);
|
|
|
|
|
|
2021-12-07 15:11:35 +00:00
|
|
|
/* source code utility */
|
|
|
|
|
string path_source_replace_includes(const string &source, const string &path);
|
|
|
|
|
|
2014-01-23 01:13:09 +01:00
|
|
|
/* cache utility */
|
|
|
|
|
void path_cache_clear_except(const string &name, const set<string> &except);
|
2014-01-11 00:47:58 +01:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
|
|
#endif
|