2024-05-16 09:42:34 +02:00
|
|
|
function path_search(paths, _filter = ".png") {
|
2022-12-16 09:18:09 +01:00
|
|
|
var _paths = [];
|
2024-05-16 04:26:35 +02:00
|
|
|
for( var i = 0, n = array_length(paths); i < n; i++ )
|
2024-05-16 09:42:34 +02:00
|
|
|
array_append(_paths, paths_to_array_ext(paths[i], _filter));
|
2022-12-16 09:18:09 +01:00
|
|
|
return _paths;
|
|
|
|
}
|
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
function path_dir_get_files(paths, _extension = ".png", _recur = true) {
|
2024-05-16 04:26:35 +02:00
|
|
|
paths = string_trim_end(paths, ["/", "\\"]);
|
|
|
|
var _ext = string_splice(_extension, ";", false, false);
|
|
|
|
var _paths = [];
|
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
if(!directory_exists(paths)) return _paths;
|
2024-05-16 04:26:35 +02:00
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
var st = ds_stack_create();
|
|
|
|
var _root = true;
|
2024-05-16 04:26:35 +02:00
|
|
|
ds_stack_push(st, paths);
|
|
|
|
|
|
|
|
while(!ds_stack_empty(st)) {
|
|
|
|
var curr_path = ds_stack_pop(st);
|
|
|
|
var file = file_find_first(curr_path + "/*", fa_none);
|
|
|
|
|
|
|
|
while(file != "") {
|
|
|
|
var file_full = curr_path + "/" + file;
|
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
if((_recur || _root) && directory_exists(file_full))
|
2024-05-16 04:26:35 +02:00
|
|
|
ds_stack_push(st, file_full);
|
|
|
|
|
2024-05-25 04:51:52 +02:00
|
|
|
else if(array_exists(_ext, string_lower(filename_ext(file))))
|
2024-05-16 04:26:35 +02:00
|
|
|
array_push(_paths, file_full);
|
|
|
|
|
|
|
|
file = file_find_next();
|
|
|
|
}
|
|
|
|
file_find_close();
|
2024-05-25 04:51:52 +02:00
|
|
|
|
|
|
|
_root = false;
|
2024-05-16 04:26:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ds_stack_destroy(st);
|
|
|
|
|
|
|
|
return _paths;
|
2024-05-16 09:42:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function paths_to_array_ext(paths, _extension = ".png") {
|
|
|
|
var _ext = string_splice(_extension, ";", false, false);
|
|
|
|
var _p = [];
|
|
|
|
|
|
|
|
for(var i = array_length(paths) - 1; i >= 0; i--) {
|
|
|
|
if(file_exists(paths[i]) && array_exists(_ext, filename_ext(paths[i])))
|
|
|
|
array_push(_p, paths[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return _p;
|
|
|
|
}
|
|
|
|
|
|
|
|
function path_is_image(path) {
|
|
|
|
if(!file_exists_empty(path)) return false;
|
|
|
|
|
|
|
|
var ext = filename_ext(path);
|
|
|
|
switch(ext) {
|
|
|
|
case ".png":
|
|
|
|
case ".jpg":
|
|
|
|
case ".jpeg":
|
|
|
|
case ".gif":
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2024-05-16 15:28:45 +02:00
|
|
|
|
2024-06-03 09:34:59 +02:00
|
|
|
function path_is_project(path, checkExist = true) {
|
|
|
|
if(checkExist && !file_exists_empty(path)) return false;
|
2024-05-16 15:28:45 +02:00
|
|
|
|
|
|
|
var ext = filename_ext(path);
|
2024-06-03 09:34:59 +02:00
|
|
|
ext = string_lower(string_letters(ext));
|
|
|
|
|
2024-05-16 15:28:45 +02:00
|
|
|
switch(ext) {
|
2024-06-03 09:34:59 +02:00
|
|
|
case "pxc":
|
|
|
|
case "cpxc":
|
2024-05-16 15:28:45 +02:00
|
|
|
return true;
|
2024-12-02 05:31:44 +01:00
|
|
|
|
|
|
|
default :
|
|
|
|
return string_starts_with(ext, "pxc");
|
2024-05-16 15:28:45 +02:00
|
|
|
}
|
2024-12-02 05:31:44 +01:00
|
|
|
|
2024-05-16 15:28:45 +02:00
|
|
|
return false;
|
|
|
|
}
|
2024-06-03 09:34:59 +02:00
|
|
|
|
|
|
|
function path_is_backup(path) {
|
|
|
|
if(!path_is_project(path)) return false;
|
|
|
|
|
|
|
|
var ext = string_lower(filename_ext(path));
|
|
|
|
ext = string_replace(ext, ".", "");
|
|
|
|
|
|
|
|
return string_letters(ext) != ext;
|
|
|
|
}
|
|
|
|
|
2024-09-16 09:29:37 +02:00
|
|
|
function filename_ext_raw(path) { return string_lower(string_replace(filename_ext(path), ".", "")); }
|