From 56b234e72331505072d126aba832be40ae0d07c2 Mon Sep 17 00:00:00 2001 From: blankie Date: Mon, 13 Nov 2023 00:18:17 +1100 Subject: [PATCH] libticalcs: fix renaming folders on the nspire --- libticalcs/trunk/src/calc_nsp.cc | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/libticalcs/trunk/src/calc_nsp.cc b/libticalcs/trunk/src/calc_nsp.cc index f28c7e65..4a72bca7 100644 --- a/libticalcs/trunk/src/calc_nsp.cc +++ b/libticalcs/trunk/src/calc_nsp.cc @@ -46,10 +46,11 @@ static gchar * build_path(CalcModel model, VarRequest * vr) { const char * dot_if_any; + const char * fext_if_any; gchar * path; - // Don't add a dot if this file type is unknown. - if (vr->type >= NSP_MAXTYPES) + // Don't add a dot if this file type is unknown or a folder. + if (vr->type >= NSP_MAXTYPES || vr->type == NSP_DIR) { dot_if_any = ""; } @@ -58,13 +59,23 @@ static gchar * build_path(CalcModel model, VarRequest * vr) dot_if_any = "."; } + // Don't add a file extension if this is a folder. + if (vr->type == NSP_DIR) + { + fext_if_any = ""; + } + else + { + fext_if_any = tifiles_vartype2fext(model, vr->type); + } + if (!strcmp(vr->folder, "")) { - path = g_strconcat("/", vr->name, dot_if_any, tifiles_vartype2fext(model, vr->type), NULL); + path = g_strconcat("/", vr->name, dot_if_any, fext_if_any, NULL); } else { - path = g_strconcat("/", vr->folder, "/", vr->name, dot_if_any, tifiles_vartype2fext(model, vr->type), NULL); + path = g_strconcat("/", vr->folder, "/", vr->name, dot_if_any, fext_if_any, NULL); } return path;