48 g_fsmenu = MEM_cnew<FSMenu>(__func__);
115 fsm_iter = fsm_iter->
next)
125 return fsentry->
path;
130 if ((!fsentry->
path || !path || !
STREQ(path, fsentry->
path)) && (fsentry->
path != path)) {
140 if (user_config_dir.has_value()) {
149 return (fsentry->
icon) ? fsentry->
icon : ICON_FILE_FOLDER;
154 fsentry->
icon = icon;
176 if (fsentry->
name[0]) {
177 return fsentry->
name;
181 char *name = fsentry->
name + 1;
182 size_t name_size =
sizeof(fsentry->
name) - 1;
192 size_t tmp_name_size =
sizeof(tmp_name);
195 if (!name[0] ||
STREQ(tmp_name, name)) {
197 fsentry->
name[0] =
'\0';
206 if (user_config_dir.has_value()) {
215 if (fsentry->
path && fsentry->
path[0]) {
220 const char *exceptions[] = {
"A:\\",
"B:\\",
nullptr};
221 const size_t exceptions_len[] = {strlen(exceptions[0]), strlen(exceptions[1]), 0};
224 for (i = 0; exceptions[i]; i++) {
226 fsentry->
valid =
true;
234 fsentry->
valid =
false;
243 fsm_iter = fsm_iter->
next)
248 return fsm_iter ? fsm_iter->
save : 0;
258 const uint path_len = strlen(path);
263 const bool has_trailing_slash = (path[path_len - 1] ==
SEP);
271 for (fsm_iter = fsm_head; fsm_iter; fsm_prev = fsm_iter, fsm_iter = fsm_iter->
next) {
272 if (fsm_iter->
path) {
275 if (cmp_ret == 0 &&
STREQ(fsm_iter->
path + path_len, has_trailing_slash ?
"" :
SEP_STR)) {
277 if (fsm_iter != fsm_head) {
279 fsm_iter->
next = fsm_head;
320 for (; tfsm; tfsm = tfsm->
next) {
323 if (tfsm->
name[0] && (!name || !name[0])) {
335 if (name && name[0]) {
339 fsm_iter->
name[0] =
'\0';
345 fsm_iter->
valid =
true;
353 fsm_iter->
next = fsm_head;
358 fsm_prev->
next = fsm_iter;
362 fsm_iter->
next = fsm_head;
375 for (fsm_iter = fsm_head; fsm_iter && idx; fsm_prev = fsm_iter, fsm_iter = fsm_iter->
next) {
383 if (fsm_iter->
save && fsm_iter->
path) {
390 fsm_head = fsm_iter->
next;
411 bool has_error =
false;
412 has_error |= (fprintf(fp,
"[Bookmarks]\n") < 0);
414 fsm_iter = fsm_iter->
next)
416 if (fsm_iter->
path && fsm_iter->
save) {
419 has_error |= (fprintf(fp,
"!%s\n", fsm_iter->
name) < 0);
421 has_error |= (fprintf(fp,
"%s\n", fsm_iter->
path) < 0);
424 has_error = (fprintf(fp,
"[Recent]\n") < 0);
427 fsm_iter = fsm_iter->
next, nwritten++)
429 if (fsm_iter->
path && fsm_iter->
save) {
432 has_error |= (fprintf(fp,
"!%s\n", fsm_iter->
name) < 0);
434 has_error |= (fprintf(fp,
"%s\n", fsm_iter->
path) < 0);
456 while (fgets(line,
sizeof(line), fp) !=
nullptr) {
463 else if (line[0] ==
'!') {
464 int len = strlen(line);
466 if (line[
len - 1] ==
'\n') {
467 line[
len - 1] =
'\0';
473 int len = strlen(line);
475 if (line[
len - 1] ==
'\n') {
476 line[
len - 1] =
'\0';
502 if (fsm_iter->
path) {
525 if (*fsmenu !=
nullptr) {
546 FSMenuEntry *fsm_dst_prev =
nullptr, *fsm_dst_head =
nullptr;
549 for (; fsm_src_iter !=
nullptr; fsm_src_iter = fsm_src_iter->
next) {
551 if (fsm_dst->
path !=
nullptr) {
555 if (fsm_dst_prev !=
nullptr) {
556 fsm_dst_prev->
next = fsm_dst;
559 fsm_dst_head = fsm_dst;
561 fsm_dst_prev = fsm_dst;
585 for (i = 0; fsm_iter; fsm_iter = fsm_iter->
next, i++) {
606 for (
size_t i =
ARRAY_SIZE(categories); i--;) {
608 for (; fsm_iter; fsm_iter = fsm_iter->
next) {
609 if (worker_status->
stop) {
627 for (
size_t i =
ARRAY_SIZE(categories); i--;) {
631 for (; fsm_iter_dst !=
nullptr; fsm_iter_dst = fsm_iter_dst->
next) {
632 while (fsm_iter_src !=
nullptr && !
STREQ(fsm_iter_dst->
path, fsm_iter_src->
path)) {
633 fsm_iter_src = fsm_iter_src->
next;
635 if (fsm_iter_src ==
nullptr) {
664 "Validating Bookmarks...",
#define BLENDER_BOOKMARK_FILE
std::optional< std::string > BKE_appdir_folder_id_create(int folder_id, const char *subfolder) ATTR_WARN_UNUSED_RESULT
int BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
FILE * BLI_fopen(const char *filepath, const char *mode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define BLI_path_join(...)
bool BLI_path_name_at_index(const char *__restrict path, int index, int *__restrict r_offset, int *__restrict r_len) ATTR_NONNULL(1
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
#define STRNCPY(dst, src)
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
#define BLI_string_joinN(...)
#define UNUSED_VARS_NDEBUG(...)
#define STRCASEEQLEN(a, b, n)
@ FS_CATEGORY_SYSTEM_BOOKMARKS
Read Guarded memory(de)allocation.
@ WM_JOB_TYPE_FSMENU_BOOKMARK_VALIDATE
#define ND_SPACE_FILE_LIST
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
struct wmWindow * winactive
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
void WM_jobs_kill_type(wmWindowManager *wm, const void *owner, int job_type)
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))