Pixel-Composer/scripts/file_functions/file_functions.gml

60 lines
1.6 KiB
Text
Raw Normal View History

function file_exists_empty(path) { INLINE path = string(path); return path != "" && file_exists(path); }
2023-12-08 03:50:09 +01:00
function file_copy_override(src, dest) {
2023-12-08 03:50:09 +01:00
if(file_exists_empty(dest)) file_delete(dest);
file_copy(src, dest);
}
2023-11-01 08:10:25 +01:00
function filepath_resolve(path) {
2023-11-08 08:38:04 +01:00
INLINE
2023-11-01 08:10:25 +01:00
2024-09-13 08:25:00 +02:00
path = string_replace_all(path, "%DIR%/", DIRECTORY);
path = string_replace_all(path, "%APP%/", APP_LOCATION);
path = string_replace_all(path, "\\", "/");
2023-11-01 08:10:25 +01:00
2024-09-13 08:25:00 +02:00
return path;
}
2023-11-08 04:48:09 +01:00
function get_open_filenames_compat(ext, sel, caption = "Open") {
2023-12-12 14:41:50 +01:00
INLINE
2023-12-13 11:09:06 +01:00
var pat = OS == os_windows? get_open_filenames_ext(ext, sel, PREFERENCES.dialog_path, caption) : get_open_filename_pxc(ext, sel, caption);
key_release();
2024-02-15 14:23:26 +01:00
return pat;
}
function file_get_modify_s(path) {
2024-02-15 14:23:26 +01:00
INLINE
2024-05-16 10:37:44 +02:00
if(!file_exists_empty(path)) return 0;
2024-02-15 14:23:26 +01:00
var _y = file_datetime_modified_year(path);
var _m = file_datetime_modified_month(path);
var _d = file_datetime_modified_day(path);
var _h = file_datetime_modified_hour(path);
var _n = file_datetime_modified_minute(path);
var _s = file_datetime_modified_second(path);
return ((((_y * 12 + _m) * 31 + _d) * 24 + _h) * 60 + _n) * 60 + _s;
}
2024-05-16 15:28:45 +02:00
function get_save_filename_pxc(filter, name, caption = "Save as") {
INLINE
var path = get_save_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
path = string(path);
2024-05-16 15:28:45 +02:00
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
return path;
}
function get_open_filename_pxc(filter, name, caption = "Open") {
INLINE
var path = get_open_filename_ext(filter, name, PREFERENCES.dialog_path, caption);
path = string(path);
2024-05-16 15:28:45 +02:00
if(path != "") PREFERENCES.dialog_path = filename_dir(path);
2024-05-16 15:28:45 +02:00
return path;
}