2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 01:50:24 +00:00
|
|
|
* limitations under the License.
|
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-10 23:47:58 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2014-01-23 00:13:09 +00:00
|
|
|
#include "util_set.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
#include "util_string.h"
|
2011-09-09 16:38:15 +00:00
|
|
|
#include "util_types.h"
|
2011-09-09 12:04:39 +00:00
|
|
|
#include "util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2014-01-23 00:13:09 +00:00
|
|
|
/* program paths */
|
2011-09-09 12:04:39 +00: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 = "");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-01-23 00:13:09 +00: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 16:22:41 +00:00
|
|
|
bool path_is_relative(const string& path);
|
2014-01-23 00:13:09 +00:00
|
|
|
|
|
|
|
/* file info */
|
2016-02-05 08:09:39 +00: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 08:09:39 +00: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 00:13:09 +00:00
|
|
|
uint64_t path_modified_time(const string& path);
|
2011-09-03 10:49:54 +00:00
|
|
|
|
2014-01-23 00:13:09 +00:00
|
|
|
/* directory utility */
|
2011-09-12 13:13:56 +00:00
|
|
|
void path_create_directories(const string& path);
|
2014-01-23 00:13:09 +00: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 08:09:39 +00:00
|
|
|
/* File manipulation. */
|
|
|
|
bool path_remove(const string& path);
|
|
|
|
|
2014-01-23 00:13:09 +00:00
|
|
|
/* source code utility */
|
2011-11-22 16:38:58 +00:00
|
|
|
string path_source_replace_includes(const string& source, const string& path);
|
|
|
|
|
2014-01-23 00:13:09 +00:00
|
|
|
/* cache utility */
|
|
|
|
void path_cache_clear_except(const string& name, const set<string>& except);
|
2014-01-10 23:47:58 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|