file exist reject empty path

This commit is contained in:
Tanasart 2023-12-08 09:50:09 +07:00
parent 458c7f3ae8
commit ed708fe974
63 changed files with 119 additions and 115 deletions

View file

@ -19,7 +19,7 @@ event_inherited();
context_menus = {};
panels = {};
if(file_exists(propPath)) {
if(file_exists_empty(propPath)) {
var meta = json_load_struct(propPath);
if(struct_has(meta, "panels")) {
panels = meta.panels;
@ -52,7 +52,7 @@ event_inherited();
}
scriptPath = directory + "\\script.lua";
if(!file_exists(scriptPath)) {
if(!file_exists_empty(scriptPath)) {
noti_warning(title + " Addon error: script.lua not found.");
return self;
}

View file

@ -24,7 +24,7 @@
}
var perstPath = APP_DIRECTORY + "persistPreference.json";
if(file_exists(perstPath)) {
if(file_exists_empty(perstPath)) {
PRESIST_PREF = json_load_struct(perstPath);
DIRECTORY = struct_has(PRESIST_PREF, "path")? PRESIST_PREF.path : "";
}
@ -35,7 +35,7 @@
#region log
path = DIRECTORY + "log/crash_log.txt";
if(!file_exists(path)) game_end(1);
if(!file_exists_empty(path)) game_end(1);
crash_content = file_read_all(path);
log_surface = surface_create(1, 1);

View file

@ -46,6 +46,6 @@ draw_set_alpha(1);
draw_text(bx0 + bw / 2, by0 + bh / 2, __txtx("crashed_log", "Log file") + "...");
if(b == 2) {
var path = string(DIRECTORY) + "crash_log.txt";
if(file_exists(path)) shellOpenExplorer(path);
if(file_exists_empty(path)) shellOpenExplorer(path);
}
#endregion

View file

@ -70,7 +70,7 @@
if(_newPath != updating.path) {
file_rename(updating.path, _newPath);
file_rename(updating.meta_path, _newMeta);
if(file_exists(_oldSpr)) file_rename(_oldSpr, _newSpr);
if(file_exists_empty(_oldSpr)) file_rename(_oldSpr, _newSpr);
}
updating.path = _newPath;

View file

@ -482,7 +482,7 @@ event_inherited();
var _path = $"{DIRECTORY}themes/{f}";
if(directory_exists(_path)) {
var _metaPath = _path + "/meta.json";
if(!file_exists(_metaPath)) {
if(!file_exists_empty(_metaPath)) {
var _item = new scrollItem(f, THEME.circle);
_item.spr_blend = COLORS._main_accent;
_item.tooltip = "Theme made for earlier version.";

View file

@ -56,7 +56,7 @@ if !ready exit;
var b = buttonInstant(THEME.button_hide, bx, py, ui(32), ui(32), mouse_ui, sFOCUS, sHOVER, _txt, THEME.refresh);
if(b == 2) {
var path = $"{DIRECTORY}themes/{PREFERENCES.theme}/override.json";
if(file_exists(path)) file_delete(path);
if(file_exists_empty(path)) file_delete(path);
loadColor(PREFERENCES.theme);
}

View file

@ -64,7 +64,7 @@ event_inherited();
var _rec = RECENT_FILES[| ind];
var _dat = RECENT_FILE_DATA[| ind];
if(!file_exists(_rec)) continue;
if(!file_exists_empty(_rec)) continue;
var thmb = recent_thumbnail? _dat.getThumbnail() : noone;
var fx = j * (ww + ui(8));

View file

@ -112,7 +112,7 @@ for( var i = 0, n = array_length(keys); i < n; i++ ) {
var path = att[1];
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
attachment[? keys[i]] = noone;
exit;
}

View file

@ -2,6 +2,6 @@
#region prefload
__migration_check();
if(!file_exists(file_open_parameter) && PREFERENCES.show_splash)
if(!file_exists_empty(file_open_parameter) && PREFERENCES.show_splash)
dialogCall(o_dialog_splash);
#endregion

View file

@ -20,7 +20,7 @@
directory_verify(APP_DIRECTORY);
var perstPath = APP_DIRECTORY + "persistPreference.json";
if(file_exists(perstPath)) {
if(file_exists_empty(perstPath)) {
PRESIST_PREF = json_load_struct(perstPath);
DIRECTORY = struct_has(PRESIST_PREF, "path")? PRESIST_PREF.path : "";
}
@ -100,7 +100,7 @@
__initPanel();
if(file_exists("icon.png"))
if(file_exists_empty("icon.png"))
file_copy("icon.png", DIRECTORY + "icon.png");
environment_set_variable("IMGUI_DIALOG_WIDTH", string(800));
@ -126,7 +126,7 @@
path = string_replace_all(path, "\n", "");
path = string_replace_all(path, "\"", "");
if(file_exists(path) && filename_ext(path) == ".pxc") {
if(file_exists_empty(path) && filename_ext(path) == ".pxc") {
file_open_parameter = path;
alarm[2] = 3;
}

View file

@ -22,7 +22,7 @@ function __initAddon() {
var _path = dirPath + "\\" + f;
var _meta = _path + "\\meta.json";
if(!file_exists(_meta)) {
if(!file_exists_empty(_meta)) {
f = file_find_next();
continue;
}
@ -45,7 +45,7 @@ function __initAddon() {
function loadAddon() {
var _path = DIRECTORY + "Addons\\__init.json";
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
ADDONS_ON_START = json_load_struct(_path);
for( var i = 0, n = array_length(ADDONS_ON_START); i < n; i++ )

View file

@ -122,7 +122,7 @@ function __Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
var matY = y - (array_length(materials) - 1) / 2 * (128 + 32);
var mat = materials[m_index];
if(file_exists(mat.diff_path)) {
if(file_exists_empty(mat.diff_path)) {
var sol = Node_create_Image_path(x - (w + 64), matY + m_index * (128 + 32), mat.diff_path);
sol.name = mat.name + " texture";
@ -138,7 +138,7 @@ function __Node_3D_Obj(_x, _y, _group = noone) : Node(_x, _y, _group) constructo
static updateObj = function(updateMat = true) {
var _path = getInputData(0);
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
var _flip = getInputData(12);
var _dir = filename_dir(_path);

View file

@ -96,7 +96,7 @@
// var matY = y - (array_length(materials) - 1) / 2 * (128 + 32);
// var mat = materials[m_index];
// if(file_exists(mat.diff_path)) {
// if(file_exists_empty(mat.diff_path)) {
// var sol = Node_create_Image_path(x - (w + 64), matY + m_index * (128 + 32), mat.diff_path);
// sol.name = mat.name + " texture";

View file

@ -7,7 +7,7 @@ function Node_create_Custom(_x, _y, _group = noone, _param = {}) {
}
function Node_create_Custom_path(_x, _y, path) {
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Custom(_x, _y, PANEL_GRAPH.getCurrentContext());
if(!node.setPath(path)) return noone;
@ -31,7 +31,7 @@ function Node_Custom(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) co
static setPath = function(_path) {
var _info = _path + "/info.json";
if(!file_exists(_info)) return false;
if(!file_exists_empty(_info)) return false;
info = json_load_struct(_info);
path = _path;
@ -191,7 +191,7 @@ function __initNodeCustom(list) { #region
_n.tooltip = _info.tooltip;
var _tol = _dir + _info.tooltip_spr;
if(file_exists(_tol)) _n.tooltip_spr = sprite_add(_tol, 0, false, false, 0, 0);
if(file_exists_empty(_tol)) _n.tooltip_spr = sprite_add(_tol, 0, false, false, 0, 0);
ds_list_add(list, _n);

View file

@ -641,7 +641,7 @@
[ "rectangle_in_circle", rectangle_in_circle ],
//file
[ "file_exists", file_exists ],
[ "file_exists_empty", file_exists_empty ],
[ "file_delete", file_delete ],
[ "file_rename", file_rename ],
[ "file_copy", file_copy ],

View file

@ -46,7 +46,7 @@ function buffer_from_surface(surface, header = true) {
}
function buffer_from_file(path) {
if(!file_exists(path)) return;
if(!file_exists_empty(path)) return;
var _b = buffer_load(path);
return _b;
}

View file

@ -16,17 +16,17 @@ function loadColor(theme = "default") {
}
function _loadColor(theme = "default", replace = false) {
var dirr = DIRECTORY + "themes/" + theme;
var dirr = DIRECTORY + "Themes/" + theme;
var path = dirr + "/values.json";
var pathO = dirr + "/override.json";
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
noti_status("Colors not defined at " + path + ", rollback to default color.");
return;
}
var clrs = json_load_struct(path);
var oclr = file_exists(pathO)? json_load_struct(pathO) : {};
var oclr = file_exists_empty(pathO)? json_load_struct(pathO) : {};
if(!struct_has(clrs, "values")) {
print("Load color error");

View file

@ -54,7 +54,7 @@ function log_newline() {
function log_clear() {
var path = DIRECTORY + "log/log.txt";
if(file_exists(path))
if(file_exists_empty(path))
file_delete(path);
}

View file

@ -95,11 +95,11 @@ function FileObject(_name, _path) constructor { #region
if(meta != noone) return meta;
if(meta == undefined) return noone;
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
meta = new MetaDataManager();
if(file_exists(meta_path)) {
if(file_exists_empty(meta_path)) {
meta.deserialize(json_load_struct(meta_path));
} else {
var m = json_load_struct(path);
@ -170,7 +170,7 @@ function DirectoryObject(name, path) constructor { #region
f.spr_path = [icon_path, amo, false];
} else {
var icon_path = path + "/" + filename_change_ext(file, ".png");
if(!file_exists(icon_path)) continue;
if(!file_exists_empty(icon_path)) continue;
var _temp = sprite_add(icon_path, 0, false, false, 0, 0);
var ww = sprite_get_width(_temp);

View file

@ -28,11 +28,11 @@ function exportPortable(project = PROJECT) {
for( var k = 0, o = array_length(_input.raw_value); k < o; k++ ) {
var _val = _input.raw_value[k][1];
if(is_string(_val) && file_exists(_val))
if(is_string(_val) && file_exists_empty(_val))
_input.raw_value[k][1] = __pack_file_strip(zip, _val);
else if(is_array(_val)) {
for( var l = 0, p = array_length(_val); l < p; l++ ) {
if(is_string(_val[l]) && file_exists(_val[l]))
if(is_string(_val[l]) && file_exists_empty(_val[l]))
_input.raw_value[k][1][l] = __pack_file_strip(zip, _val[l]);
}
}

View file

@ -1,5 +1,7 @@
function file_exists_empty(path) { INLINE return path != "" && file_exists(path); }
function file_copy_override(src, dest) {
if(file_exists(dest)) file_delete(dest);
if(file_exists_empty(dest)) file_delete(dest);
file_copy(src, dest);
}

View file

@ -43,14 +43,13 @@ function _font_extend_locale(baseFont, localFont, override = false) { #region
function _font_path(rel) { #region
rel = string_replace_all(rel, "./", "");
var defPath = $"{DIRECTORY}themes/{PREFERENCES.theme}/fonts/{rel}";
var defPath = $"{DIRECTORY}Themes/{PREFERENCES.theme}/fonts/{rel}";
if(LOCALE.fontDir == noone)
return defPath;
var overridePath = $"{LOCALE.fontDir}{rel}";
if(file_exists(overridePath))
if(file_exists_empty(overridePath))
return overridePath;
return defPath;
@ -62,13 +61,14 @@ function _font_load_from_struct(str, name, def, over = true) { #region
var font = str[$ name];
var path = "";
if(over && file_exists(PREFERENCES.font_overwrite)) path = PREFERENCES.font_overwrite;
else {
if(over && file_exists_empty(PREFERENCES.font_overwrite))
path = PREFERENCES.font_overwrite;
else
path = _font_path(font.path);
if(!file_exists(path)) {
noti_status($"Font resource {path} not found. Rollback to default font.");
return def;
}
if(!file_exists_empty(path)) {
noti_status($"Font resource {path} not found. Rollback to default font.");
return def;
}
font_add_enable_aa(THEME_VALUE.font_aa);
@ -101,7 +101,7 @@ function loadFonts() { #region
var path = _font_path("./fonts.json");
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
noti_status("Font not defined at " + path + ", rollback to default fonts.");
f_h1 = _f_h1;
f_h2 = _f_h2;

View file

@ -213,7 +213,7 @@ function gradientObject(color = c_black) constructor { #region
function loadGradient(path) { #region
if(path == "") return noone;
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var grad = new gradientObject();
grad.keys = [];

View file

@ -13,7 +13,7 @@ function json_stringify_minify(map) {
function json_load(path) {
gml_pragma("forceinline");
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var s = file_read_all(path);
var js = json_decode(s);
@ -33,7 +33,7 @@ function json_save(path, map) {
function json_load_struct(path) {
gml_pragma("forceinline");
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var s = file_read_all(path);
var js = json_try_parse(s);

View file

@ -52,7 +52,7 @@ function LOAD_PATH(path, readonly = false, safe_mode = false) { #region
function __LOAD_PATH(path, readonly = false, override = false) { #region
if(DEMO) return false;
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
log_warning("LOAD", "File not found");
return false;
}
@ -77,7 +77,7 @@ function __LOAD_PATH(path, readonly = false, override = false) { #region
directory_verify(temp_path);
var temp_file_path = TEMPDIR + string(UUID_generate(6));
if(file_exists(temp_file_path)) file_delete(temp_file_path);
if(file_exists_empty(temp_file_path)) file_delete(temp_file_path);
file_copy(path, temp_file_path);
PROJECT.readonly = readonly;
@ -267,7 +267,7 @@ function __IMPORT_ZIP() { #region
var _f = file_find_first(_dir + "/*.pxc", fa_none);
var _proj = $"{_dir}/{_f}";
print(_proj);
if(!file_exists(_proj)) return false;
if(!file_exists_empty(_proj)) return false;
LOAD_PATH(_proj, true);
} #endregion

View file

@ -17,7 +17,7 @@
function __locale_file(file) { #region
var dirr = $"{DIRECTORY}Locale/{PREFERENCES.local}";
if(!directory_exists(dirr) || !file_exists(dirr + file))
if(!directory_exists(dirr) || !file_exists_empty(dirr + file))
dirr = $"{DIRECTORY}Locale/en";
return dirr + file;
} #endregion

View file

@ -233,7 +233,7 @@ function MetaDataManager() constructor {
var meta = new MetaDataManager();
var path = DIRECTORY + "meta.json";
if(!file_exists(path)) return meta;
if(!file_exists_empty(path)) return meta;
var over = json_load_struct(path);
return meta.deserialize(over);
}

View file

@ -3,7 +3,7 @@ function __migration_check() {
if(!directory_exists(oldDir)) return;
var mig = oldDir + "migration";
if(file_exists(mig)) return;
if(file_exists_empty(mig)) return;
var f = file_text_open_write(mig);
file_text_close(f);

View file

@ -17,7 +17,7 @@ function str_strip_nr(str) {
}
function readMtl(path) {
if(!file_exists(path)) return [];
if(!file_exists_empty(path)) return [];
var mat = [];
var cur_mat = noone;

View file

@ -12,7 +12,7 @@ function Node_create_3D_Obj(_x, _y, _group = noone) { #region
} #endregion
function Node_create_3D_Obj_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_3D_Mesh_Obj(_x, _y, PANEL_GRAPH.getCurrentContext());
node.setPath(path);
@ -82,7 +82,7 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
var mat = materials[m_index];
inputs[| index].name = materialNames[m_index] + " Material";
if(file_exists(mat.diff_path)) {
if(file_exists_empty(mat.diff_path)) {
var sol = Node_create_Image_path(x - (w + 128), matY + m_index * (128 + 32), mat.diff_path);
sol.name = mat.name + " texture";
@ -97,7 +97,7 @@ function Node_3D_Mesh_Obj(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _group)
} #endregion
static updateObj = function(_path) { #region
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
current_path = _path;
readObj_init();

View file

@ -88,7 +88,7 @@
if(struct_has(map, "sprPath")) {
var _path = string_replace(map.sprPath, "./", filename_dir(path) + "/");
if(file_exists(_path)) {
if(file_exists_empty(_path)) {
spr = sprite_add(_path, 1, false, false, 0, 0);
sprite_set_offset(spr, sprite_get_width(spr) / 2, sprite_get_height(spr) / 2);
}

View file

@ -14,7 +14,7 @@ function Node_create_ASE_File_Read(_x, _y, _group = noone) { #region
} #endregion
function Node_create_ASE_File_Read_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_ASE_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -14,7 +14,7 @@ function Node_create_CSV_File_Read(_x, _y, _group = noone) { #region
} #endregion
function Node_create_CSV_File_Read_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_CSV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -13,7 +13,7 @@ function Node_create_Display_Image(_x, _y, _group = noone) { #region
} #endregion
function Node_create_Display_Image_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Display_Image(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -218,10 +218,10 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
gifski = filepath_resolve(PREFERENCES.gifski_path) + "win/gifski.exe";
ffmpeg = filepath_resolve(PREFERENCES.ffmpeg_path) + "bin/ffmpeg.exe";
if(!file_exists(converter) || !file_exists(magick)) noti_warning($"No ImageMagick detected at {magick}, please make sure the installation is complete and ImageMagick path is set properly in preference.");
if(!file_exists(webp)) noti_warning($"No webp detected at {webp}, please make sure the installation is complete and webp path is set properly in preference.");
if(!file_exists(gifski)) noti_warning($"No gifski detected at {gifski}, please make sure the installation is complete and gifski path is set properly in preference.");
if(!file_exists(ffmpeg)) noti_warning($"No ffmpeg detected at {ffmpeg}, please make sure the installation is complete and ffmpeg path is set properly in preference.");
if(!file_exists_empty(converter) || !file_exists_empty(magick)) noti_warning($"No ImageMagick detected at {magick}, please make sure the installation is complete and ImageMagick path is set properly in preference.");
if(!file_exists_empty(webp)) noti_warning($"No webp detected at {webp}, please make sure the installation is complete and webp path is set properly in preference.");
if(!file_exists_empty(gifski)) noti_warning($"No gifski detected at {gifski}, please make sure the installation is complete and gifski path is set properly in preference.");
if(!file_exists_empty(ffmpeg)) noti_warning($"No ffmpeg detected at {ffmpeg}, please make sure the installation is complete and ffmpeg path is set properly in preference.");
static onValueUpdate = function(_index) { #region
var form = getInputData(3);
@ -353,7 +353,7 @@ function Node_Export(_x, _y, _group = noone) : Node(_x, _y, _group) constructor
var rate = getInputData( 8);
if(rate == 0) rate = 1;
if(file_exists(target_path)) file_delete(target_path);
if(file_exists_empty(target_path)) file_delete(target_path);
temp_path = string_replace_all(temp_path, "/", "\\");
target_path = string_replace_all(target_path, "/", "\\");

View file

@ -149,10 +149,10 @@ function __initNodeData() {
var nodeDir = DIRECTORY + "Nodes/";
if(file_exists("data/tooltip.zip"))
if(file_exists_empty("data/tooltip.zip"))
zip_unzip("data/tooltip.zip", nodeDir);
if(file_exists("data/nodes.json")) {
if(file_exists_empty("data/nodes.json")) {
file_delete(nodeDir + "nodes.json");
file_copy_override("data/nodes.json", nodeDir + "nodes.json");
}
@ -162,7 +162,7 @@ function __initNodeData() {
directory_verify(nodeDir + "Related");
file_copy_override(_relFrom, _relTo);
//print($"Copying related nodes from {_relFrom} to {_relTo}\n\t{file_exists(_relFrom)}, {file_exists(_relTo)}");
//print($"Copying related nodes from {_relFrom} to {_relTo}\n\t{file_exists_empty(_relFrom)}, {file_exists_empty(_relTo)}");
__initNodeReleated();
}

View file

@ -13,7 +13,7 @@ function Node_create_Image(_x, _y, _group = noone) {
}
function Node_create_Image_path(_x, _y, path) {
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Image(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -14,7 +14,7 @@ function Node_create_Image_gif(_x, _y, _group = noone) { #region
} #endregion
function Node_create_Image_gif_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Image_gif(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -14,7 +14,7 @@ function Node_create_Json_File_Read(_x, _y, _group = noone) {
}
function Node_create_Json_File_Read_path(_x, _y, path) {
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Json_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -14,7 +14,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor { #regio
is_patreon_extra = false;
var pth = DIRECTORY + "Nodes/tooltip/" + node + ".png";
if(file_exists(pth))
if(file_exists_empty(pth))
tooltip_spr = sprite_add(pth, 0, false, false, 0, 0);
new_node = false;
@ -228,11 +228,11 @@ function __initNodes() {
global.__currPage = "";
var favPath = DIRECTORY + "Nodes/fav.json";
global.FAV_NODES = file_exists(favPath)? json_load_struct(favPath) : [];
global.FAV_NODES = file_exists_empty(favPath)? json_load_struct(favPath) : [];
if(!is_array(global.FAV_NODES)) global.FAV_NODES = [];
var recPath = DIRECTORY + "Nodes/recent.json";
global.RECENT_NODES = file_exists(recPath)? json_load_struct(recPath) : [];
global.RECENT_NODES = file_exists_empty(recPath)? json_load_struct(recPath) : [];
if(!is_array(global.RECENT_NODES)) global.RECENT_NODES = [];
NODE_PAGE_DEFAULT = ds_list_size(NODE_CATEGORY);

View file

@ -71,7 +71,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
_size_current = _size;
_aa_current = _aa;
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
if(font != f_p0 && font_exists(font))
font_delete(font);

View file

@ -14,7 +14,7 @@ function Node_create_Text_File_Read(_x, _y, _group = noone) {
}
function Node_create_Text_File_Read_path(_x, _y, path) {
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_Text_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -14,7 +14,7 @@ function Node_create_WAV_File_Read(_x, _y, _group = noone) { #region
} #endregion
function Node_create_WAV_File_Read_path(_x, _y, path) { #region
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var node = new Node_WAV_File_Read(_x, _y, PANEL_GRAPH.getCurrentContext());
node.inputs[| 0].setValue(path);

View file

@ -127,7 +127,7 @@ function Node_Websocket_Sender(_x, _y, _group = noone) : Node(_x, _y, _group) co
break;
case 2 :
var _path = getInputData(4);
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
_buff = buffer_from_file(_path);
break;
case 3 :

View file

@ -12,7 +12,7 @@ function isPaletteFile(path) { #region
} #endregion
function loadPalette(path) { #region
if(!file_exists(path)) return [];
if(!file_exists_empty(path)) return [];
if(!isPaletteFile(path)) return [];
var ext = string_lower(filename_ext(path));

View file

@ -137,7 +137,7 @@
panelObjectInit();
var file = $"{DIRECTORY}layouts/{PREFERENCES.panel_layout_file}.json";
if(!file_exists(file))
if(!file_exists_empty(file))
file = DIRECTORY + "layouts/Horizontal.json";
loadPanel(file, PANEL_MAIN);

View file

@ -1705,7 +1705,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
else if(filename_ext(txt) == ".pxcc")
APPEND(txt);
else if(filename_ext(txt) == ".png") {
if(file_exists(txt)) {
if(file_exists_empty(txt)) {
Node_create_Image_path(0, 0, txt);
return;
}

View file

@ -807,7 +807,7 @@ function Panel_Inspector() : PanelContent() constructor {
var txt = "Untitled";
var context = PANEL_GRAPH.getCurrentContext();
if(context == noone && file_exists(PROJECT.path))
if(context == noone && file_exists_empty(PROJECT.path))
txt = string_replace(filename_name(PROJECT.path), filename_ext(PROJECT.path), "");
else if(context != noone)
txt = context.name;

View file

@ -1,9 +1,9 @@
function try_get_path(path) {
if(file_exists(path))
if(file_exists_empty(path))
return path;
var local_path = filename_dir(PROJECT.path) + "/" + path;
if(file_exists(local_path))
if(file_exists_empty(local_path))
return local_path;
return -1;

View file

@ -33,14 +33,14 @@ function paths_to_array(paths, recur = false, _filter = "") {
}
ds_stack_destroy(st);
} else if(file_exists(paths))
} else if(file_exists_empty(paths))
array_push(_paths, paths);
return _paths;
}
function path_is_image(path) {
if(!file_exists(path)) return false;
if(!file_exists_empty(path)) return false;
var ext = filename_ext(path);
switch(ext) {

View file

@ -22,7 +22,7 @@ function __initPatreon() {
IS_PATREON = false;
var _path = DIRECTORY + "patreon";
if(!file_exists(_path)) return;
if(!file_exists_empty(_path)) return;
var _map = ds_map_secure_load(_path);

View file

@ -115,7 +115,7 @@
function RECENT_LOAD() {
var path = DIRECTORY + "recent.json";
if(!file_exists(path)) return;
if(!file_exists_empty(path)) return;
var file = file_text_open_read(path);
var load_str = "";
@ -130,7 +130,7 @@
ds_list_clear(RECENT_FILES);
for(var i = 0; i < ds_list_size(l); i++) {
if(!file_exists(l[| i])) continue;
if(!file_exists_empty(l[| i])) continue;
ds_list_add(RECENT_FILES, l[| i]);
}
}
@ -182,7 +182,7 @@
function PREF_LOAD() {
var path = DIRECTORY + "keys.json";
if(!file_exists(path)) return;
if(!file_exists_empty(path)) return;
var map = json_load_struct(path);
if(array_empty(variable_struct_get_names(map))) return;

View file

@ -7,7 +7,7 @@
var _preset_path = "data/Preset.zip";
var root = DIRECTORY + "Presets";
directory_verify(root);
if(check_version($"{root}/version") && file_exists(_preset_path))
if(check_version($"{root}/version") && file_exists_empty(_preset_path))
zip_unzip(_preset_path, root);
global.PRESETS = new DirectoryObject("Presets", root);

View file

@ -6,11 +6,11 @@
function Project() constructor {
active = true; /// @is {bool}
meta = __getdefaultMetaData();
path = ""; /// @is {string}
thumbnail = "";
version = SAVE_VERSION; /// @is {number}
seed = irandom_range(100000, 999999); /// @is {number}
meta = __getdefaultMetaData();
path = ""; /// @is {string}
thumbnail = "";
version = SAVE_VERSION; /// @is {number}
seed = irandom_range(100000, 999999); /// @is {number}
modified = false; /// @is {bool}
readonly = false; /// @is {bool}
@ -23,7 +23,6 @@
nodeTopo = ds_list_create();
animator = new AnimationManager();
globalNode = new Node_Global();
previewGrid = { #region

View file

@ -13,7 +13,7 @@ function LOAD_FOLDER(list, folder) { #region
var f = new FileObject(filename_name_only(file), full_path);
var icon_path = string_replace(full_path, filename_ext(full_path), ".png");
if(file_exists(icon_path)) {
if(file_exists_empty(icon_path)) {
f.spr = sprite_add(icon_path, 0, false, false, 0, 0);
sprite_set_offset(f.spr, sprite_get_width(f.spr) / 2, sprite_get_height(f.spr) / 2);
}

View file

@ -98,7 +98,7 @@ function SAVE_AS(project = PROJECT) { #region
if(filename_ext(path) != ".pxc")
path += ".pxc";
if(file_exists(path))
if(file_exists_empty(path))
log_warning("SAVE", "Overrided file : " + path);
SAVE_AT(project, path);
SET_PATH(project, path);
@ -113,7 +113,7 @@ function SAVE_AT(project = PROJECT, path = "", log = "save at ") { #region
//if(TESTING && string_char_at(filename_name(path), 1) != "[")
// path = $"{filename_dir(path)}/[{VERSION_STRING}] {filename_name(path)}";
if(file_exists(path)) file_delete(path);
if(file_exists_empty(path)) file_delete(path);
file_text_write_all(path, save_serialize(project));
SAVING = false;

View file

@ -1,5 +1,5 @@
function sprite_add_center(path) {
if(!file_exists(path)) return noone;
if(!file_exists_empty(path)) return noone;
var _s = sprite_add(path, 0, 0, 0, 0, 0);

View file

@ -14,7 +14,7 @@ function __initTheme() { #region
function _sprite_path(rel, theme) { #region
INLINE
return $"{DIRECTORY}themes/{theme}/graphics/{string_replace_all(rel, "./", "")}";
return $"{DIRECTORY}Themes/{theme}/graphics/{string_replace_all(rel, "./", "")}";
} #endregion
function _sprite_load_from_struct(str, theme, key) { #region
@ -51,7 +51,8 @@ function __getGraphicList() { #region
function loadGraphic(theme = "default") { #region
var sprDef = __getGraphicList();
var _metaP = $"{DIRECTORY}Themes/{theme}/meta.json";
if(!file_exists(_metaP))
if(!file_exists_empty(_metaP))
noti_warning("Loading theme made for older version.");
else {
var _meta = json_load_struct(_metaP);
@ -62,7 +63,7 @@ function loadGraphic(theme = "default") { #region
var path = _sprite_path("./graphics.json", theme);
print($"Loading theme {theme}");
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
print("Theme not defined at " + path + ", rollback to default theme.");
return;
}

View file

@ -50,7 +50,7 @@ function steam_ugc_update_collection(file, update_preview = false, update_note =
steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, tgs);
steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, DIRECTORY + "steamUGC");
if(file_exists(TEMPDIR + "steamUGCthumbnail.png"))
if(file_exists_empty(TEMPDIR + "steamUGCthumbnail.png"))
steam_ugc_set_item_preview(STEAM_UGC_UPDATE_HANDLE, TEMPDIR + "steamUGCthumbnail.png");
STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, update_note);

View file

@ -61,7 +61,7 @@ function __loadSteamUGCCollection(file_id, f, path) {
var name = string_replace(filename_name(f), ".pxcc", "");
var file = new FileObject(name, path + "/" + f);
var icon_path = string_replace(path + "/" + f, ".pxcc", ".png");
if(file_exists(icon_path)) {
if(file_exists_empty(icon_path)) {
var _temp = sprite_add(icon_path, 0, false, false, 0, 0);
var ww = sprite_get_width(_temp);
var hh = sprite_get_height(_temp);

View file

@ -37,7 +37,7 @@ function steam_ugc_update_project(update_preview = false, update_note = "Updated
directory_create(DIRECTORY + "steamUGC");
file_copy(file.path, DIRECTORY + "steamUGC/" + filename_name(file.path));
if(file_exists(PROJECT.thumbnail))
if(file_exists_empty(PROJECT.thumbnail))
file_copy(PROJECT.thumbnail, DIRECTORY + "steamUGC/thumbnail.png");
STEAM_UGC_PUBLISH_ID = file.meta.file_id;
@ -55,7 +55,7 @@ function steam_ugc_update_project(update_preview = false, update_note = "Updated
steam_ugc_set_item_tags(STEAM_UGC_UPDATE_HANDLE, tgs);
steam_ugc_set_item_content(STEAM_UGC_UPDATE_HANDLE, DIRECTORY + "steamUGC");
if(file_exists(TEMPDIR + "steamUGCthumbnail.png"))
if(file_exists_empty(TEMPDIR + "steamUGCthumbnail.png"))
steam_ugc_set_item_preview(STEAM_UGC_UPDATE_HANDLE, TEMPDIR + "steamUGCthumbnail.png");
STEAM_UGC_SUBMIT_ID = steam_ugc_submit_item_update(STEAM_UGC_UPDATE_HANDLE, update_note);

View file

@ -1,14 +1,16 @@
function file_read_all(path) {
gml_pragma("forceinline");
INLINE
var f = file_text_open_read(path);
var s = file_text_read_all(f);
var s = "";
while(!file_text_eof(f))
s += file_text_readln(f);
file_text_close(f);
return s;
}
function file_text_read_all_lines(path) {
gml_pragma("forceinline");
INLINE
var f = file_text_open_read(path);
var s = [];
@ -19,9 +21,9 @@ function file_text_read_all_lines(path) {
}
function file_text_write_all(path, str) {
gml_pragma("forceinline");
INLINE
if(file_exists(path)) file_delete(path);
if(file_exists_empty(path)) file_delete(path);
var f = file_text_open_write(path);
file_text_write_string(f, str);

View file

@ -1,5 +1,5 @@
function check_version(path) {
if(!file_exists(path)) {
if(!file_exists_empty(path)) {
json_save_struct(path, { version: BUILD_NUMBER });
return true;
}