21 #include BLI_SYSTEM_PID_H
35 #include <sys/types.h>
43 # define _WIN32_IE 0x0400
53 #if defined(WIN32) || defined(__APPLE__)
56 # define USE_FREEDESKTOP
60 #ifdef USE_FREEDESKTOP
61 # define THUMBNAILS "thumbnails"
63 # define THUMBNAILS ".thumbnails"
66 #define URI_MAX (FILE_MAX * 3 + 8)
73 wchar_t dir_16[MAX_PATH];
75 SHGetSpecialFolderPathW(0, dir_16, CSIDL_PROFILE, 0);
79 # if defined(USE_FREEDESKTOP)
80 const char *home_cache =
BLI_getenv(
"XDG_CACHE_HOME");
81 const char *home = home_cache ? home_cache :
BLI_getenv(
"HOME");
90 # ifdef USE_FREEDESKTOP
142 0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C,
144 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20,
146 0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
148 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F,
150 0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,
152 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20,
156 static const char hex[17] =
"0123456789abcdef";
161 char *escaped_string,
162 int escaped_string_size,
165 #define ACCEPTABLE(a) ((a) >= 32 && (a) < 128 && (acceptable[(a)-32] & use_mask))
176 escaped_string_size -= 1;
178 for (q = escaped_string, p =
string; (*p !=
'\0') && escaped_string_size; p++) {
179 c = (
unsigned char)*p;
182 if (escaped_string_size < 3) {
189 escaped_string_size -= 3;
193 escaped_string_size -= 1;
218 const char *dirstart = path;
225 if (strlen(path) < 2 && path[1] !=
':') {
230 vol[0] = (
unsigned char)toupper(path[0]);
233 strcat(orig_uri, vol);
236 strcat(orig_uri, dirstart);
248 const char *uri,
char *r_path,
const int path_len,
char *r_name,
int name_len,
ThumbSize size)
252 if (r_path && !r_name) {
254 name_len =
sizeof(name_buff);
259 unsigned char digest[16];
270 BLI_snprintf(r_path, path_len,
"%s%s", tmppath, r_name);
310 const char *blen_group,
320 char mtime[40] =
"0";
371 if (
BLI_stat(file_path, &info) != -1) {
372 BLI_snprintf(mtime,
sizeof(mtime),
"%ld", (
long int)info.st_mtime);
382 printf(
"not an anim; %s\n", file_path);
390 if (
BLI_stat(file_path, &info) != -1) {
391 BLI_snprintf(mtime,
sizeof(mtime),
"%ld", (
long int)info.st_mtime);
398 if (img->
x > tsize || img->
y > tsize) {
399 float scale =
MIN2((
float)tsize / (
float)img->
x, (
float)tsize / (
float)img->
y);
401 short ex =
MAX2(1, (
short)(img->
x * scale));
402 short ey =
MAX2(1, (
short)(img->
y * scale));
413 BLI_snprintf(desc,
sizeof(desc),
"Thumbnail for %s", uri);
431 chmod(temp, S_IRUSR | S_IWUSR);
446 const char *blen_group,
452 file_path, uri, thumb, use_hash,
hash, blen_group, blen_id,
size, source,
NULL);
457 file_path, uri, thumb, use_hash,
hash, blen_group, blen_id,
THB_FAIL, source,
NULL);
522 const char *file_path;
526 char *blen_group =
NULL, *blen_id =
NULL;
528 path = file_path = filepath;
536 file_path = path_buff;
561 uri, thumb_path,
sizeof(thumb_path), thumb_name,
sizeof(thumb_name),
size)) {
562 if (
BLI_path_ncmp(path, thumb_path,
sizeof(thumb_path)) == 0) {
568 bool regenerate =
false;
572 char thumb_hash_curr[33];
577 regenerate = (
st.st_mtime != atol(mtime));
584 if (use_hash && !regenerate) {
586 img->
metadata,
"X-Blender::Hash", thumb_hash_curr,
sizeof(thumb_hash_curr))) {
587 regenerate = !
STREQ(thumb_hash, thumb_hash_curr);
602 file_path, uri, thumb_name, use_hash, thumb_hash, blen_group, blen_id,
size, source);
610 file_path, uri, thumb_name, use_hash, thumb_hash, blen_group, blen_id,
size, source);
688 const void *key = path;
#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()
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) ATTR_WARN_UNUSED_RESULT
void BLI_str_replace_char(char *str, char src, char dst) ATTR_NONNULL()
size_t BLI_strncpy_rlen(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL() ATTR_MALLOC
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL()
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLI_condition_notify_all(ThreadCondition *cond)
void BLI_thread_unlock(int type)
void BLI_thread_lock(int type)
void BLI_condition_wait_global_mutex(ThreadCondition *cond, int type)
pthread_cond_t ThreadCondition
void BLI_condition_end(ThreadCondition *cond)
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)
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_thumb_load_image(const char *filepath, const size_t max_thumb_size, char colorspace[IM_MAX_SPACE])
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)
#define PREVIEW_RENDER_DEFAULT_HEIGHT
bool IMB_thumb_load_font_get_hash(char *r_hash)
#define PREVIEW_RENDER_LARGE_HEIGHT
struct ImBuf * IMB_thumb_load_font(const char *filepath, unsigned int x, unsigned int y)
#define THUMB_DEFAULT_HASH
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SyclQueue void void size_t num_bytes void
void IMB_freeImBuf(ImBuf *UNUSED(ibuf))
void(* MEM_freeN)(void *vmemh)
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
static const pxr::TfToken st("st", pxr::TfToken::Immortal)
struct IDProperty * metadata
ImBuf * IMB_thumb_manage(const char *filepath, ThumbSize size, ThumbSource source)
void IMB_thumb_makedirs(void)
ImBuf * IMB_thumb_create(const char *filepath, ThumbSize size, ThumbSource source, ImBuf *img)
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)
void IMB_thumb_path_unlock(const char *path)
ImBuf * IMB_thumb_read(const char *filepath, ThumbSize size)
static void thumbname_from_uri(const char *uri, char *thumb, const int thumb_len)
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_delete(const char *filepath, ThumbSize size)
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
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)