37 #include BLI_SYSTEM_PID_H
52 #include <sys/types.h>
60 # define _WIN32_IE 0x0400
70 #if defined(WIN32) || defined(__APPLE__)
73 # define USE_FREEDESKTOP
77 #ifdef USE_FREEDESKTOP
78 # define THUMBNAILS "thumbnails"
80 # define THUMBNAILS ".thumbnails"
83 #define URI_MAX (FILE_MAX * 3 + 8)
90 wchar_t dir_16[MAX_PATH];
92 SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
96 # if defined(USE_FREEDESKTOP)
97 const char *home_cache =
BLI_getenv(
"XDG_CACHE_HOME");
98 const char *home = home_cache ? home_cache :
BLI_getenv(
"HOME");
107 # ifdef USE_FREEDESKTOP
159 0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
161 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20,
163 0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
165 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F,
167 0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
169 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20,
173 static const char hex[17] =
"0123456789abcdef";
178 char *escaped_string,
179 int escaped_string_size,
182 #define ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a)-32] & use_mask))
193 escaped_string_size -= 1;
195 for (q = escaped_string, p =
string; (*p !=
'\0') && escaped_string_size; p++) {
196 c = (
unsigned char)*p;
199 if (escaped_string_size < 3) {
206 escaped_string_size -= 3;
210 escaped_string_size -= 1;
235 const char *dirstart = path;
242 if (strlen(path) < 2 && path[1] !=
':') {
247 vol[0] = (
unsigned char)toupper(path[0]);
250 strcat(orig_uri, vol);
253 strcat(orig_uri, dirstart);
265 const char *uri,
char *r_path,
const int path_len,
char *r_name,
int name_len,
ThumbSize size)
269 if (r_path && !r_name) {
271 name_len =
sizeof(name_buff);
276 unsigned char digest[16];
287 BLI_snprintf(r_path, path_len,
"%s%s", tmppath, r_name);
327 const char *blen_group,
337 char mtime[40] =
"0";
338 char cwidth[40] =
"0";
339 char cheight[40] =
"0";
342 float scaledx, scaledy;
401 if (
BLI_stat(file_path, &info) != -1) {
402 BLI_snprintf(mtime,
sizeof(mtime),
"%ld", (
long int)info.st_mtime);
414 printf(
"not an anim; %s\n", file_path);
422 if (
BLI_stat(file_path, &info) != -1) {
423 BLI_snprintf(mtime,
sizeof(mtime),
"%ld", (
long int)info.st_mtime);
430 if (img->
x > img->
y) {
431 scaledx = (
float)tsize;
432 scaledy = ((
float)img->
y / (
float)img->
x) * tsize;
435 scaledy = (
float)tsize;
436 scaledx = ((
float)img->
x / (
float)img->
y) * tsize;
439 ex =
MAX2(1, (
short)scaledx);
440 ey =
MAX2(1, (
short)scaledy);
453 BLI_snprintf(desc,
sizeof(desc),
"Thumbnail for %s", uri);
475 chmod(temp, S_IRUSR | S_IWUSR);
490 const char *blen_group,
496 file_path, uri, thumb, use_hash,
hash, blen_group, blen_id,
size, source,
NULL);
501 file_path, uri, thumb, use_hash,
hash, blen_group, blen_id,
THB_FAIL, source,
NULL);
569 const char *file_path;
573 char *blen_group =
NULL, *blen_id =
NULL;
575 path = file_path = org_path;
583 file_path = path_buff;
588 if (
BLI_stat(file_path, &st) == -1) {
608 uri, thumb_path,
sizeof(thumb_path), thumb_name,
sizeof(thumb_name),
size)) {
609 if (
BLI_path_ncmp(path, thumb_path,
sizeof(thumb_path)) == 0) {
615 bool regenerate =
false;
619 char thumb_hash_curr[33];
624 regenerate = (st.st_mtime != atol(mtime));
631 if (use_hash && !regenerate) {
633 img->
metadata,
"X-Blender::Hash", thumb_hash_curr,
sizeof(thumb_hash_curr))) {
634 regenerate = !
STREQ(thumb_hash, thumb_hash_curr);
649 file_path, uri, thumb_name, use_hash, thumb_hash, blen_group, blen_id,
size, source);
657 file_path, uri, thumb_name, use_hash, thumb_hash, blen_group, blen_id,
size, source);
735 const void *key = path;
typedef float(TangentPoint)[2]
#define BLI_assert_unreachable()
File and directory operations.
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_file_older(const char *file1, const char *file2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_stat(const char *path, BLI_stat_t *buffer) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
int BLI_delete(const char *file, bool dir, bool recursive) ATTR_NONNULL()
int BLI_rename(const char *from, const char *to) ATTR_NONNULL()
size_t BLI_file_size(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_dir_create_recursive(const char *dir) ATTR_NONNULL()
GSet * BLI_gset_str_new(const char *info)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
bool BLI_gset_add(GSet *gs, void *key)
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
void * BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock)
char * BLI_hash_md5_to_hexdigest(void *resblock, char r_hex_digest[33])
const char * BLI_getenv(const char *env) ATTR_NONNULL(1)
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
void BLI_str_replace_char(char *string, char src, char dst) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
void BLI_condition_notify_all(ThreadCondition *cond)
void BLI_thread_unlock(int type)
void BLI_thread_lock(int type)
pthread_cond_t ThreadCondition
void BLI_condition_end(ThreadCondition *cond)
void BLI_condition_wait_global_mutex(ThreadCondition *cond, const int type)
void BLI_condition_init(ThreadCondition *cond)
Compatibility-like things for windows.
external readfile function prototypes.
bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
#define FILE_MAX_LIBEXTRA
void imb_freerectfloatImBuf(struct ImBuf *ibuf)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
void IMB_free_anim(struct anim *anim)
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
void IMB_rect_from_float(struct ImBuf *ibuf)
void IMB_freeImBuf(struct ImBuf *ibuf)
struct anim * IMB_open_anim(const char *name, int ib_flags, int streamindex, char colorspace[IM_MAX_SPACE])
struct ImBuf * IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
struct ImBuf * IMB_anim_previewframe(struct anim *anim)
struct ImBuf * IMB_anim_absolute(struct anim *anim, int position, IMB_Timecode_Type tc, IMB_Proxy_Size preview_size)
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Contains defines and structs used throughout the imbuf module.
struct ImBuf * IMB_thumb_load_blend(const char *blen_path, const char *blen_group, const char *blen_id)
struct ImBuf * IMB_thumb_load_font(const char *filename, unsigned int x, unsigned int y)
#define PREVIEW_RENDER_DEFAULT_HEIGHT
bool IMB_thumb_load_font_get_hash(char *r_hash)
#define THUMB_DEFAULT_HASH
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void(* MEM_freeN)(void *vmemh)
struct IDProperty * metadata
ImBuf * IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, ImBuf *img)
void IMB_thumb_makedirs(void)
static void escape_uri_string(const char *string, char *escaped_string, int escaped_string_size, UnsafeCharacterSet mask)
static bool thumbpathname_from_uri(const char *uri, char *r_path, const int path_len, char *r_name, int name_len, ThumbSize size)
static bool uri_from_filename(const char *path, char *uri)
static const unsigned char acceptable[96]
void IMB_thumb_locks_release(void)
ImBuf * IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source)
void IMB_thumb_path_unlock(const char *path)
static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len)
void IMB_thumb_delete(const char *path, ThumbSize size)
static ImBuf * thumb_create_ex(const char *file_path, const char *uri, const char *thumb, const bool use_hash, const char *hash, const char *blen_group, const char *blen_id, ThumbSize size, ThumbSource source, ImBuf *img)
void IMB_thumb_path_lock(const char *path)
static bool thumbhash_from_path(const char *UNUSED(path), ThumbSource source, char *r_hash)
static const char hex[17]
static ImBuf * thumb_create_or_fail(const char *file_path, const char *uri, const char *thumb, const bool use_hash, const char *hash, const char *blen_group, const char *blen_id, ThumbSize size, ThumbSource source)
void IMB_thumb_locks_acquire(void)
static struct IMBThumbLocks thumb_locks
ImBuf * IMB_thumb_read(const char *path, ThumbSize size)
static bool thumbpath_from_uri(const char *uri, char *path, const int path_len, ThumbSize size)
static bool get_thumb_dir(char *dir, ThumbSize size)
int conv_utf_16_to_8(const wchar_t *in16, char *out8, size_t size8)
__forceinline const avxi abs(const avxi &a)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)