Skip to content

Commit

Permalink
libticalcs: fix renaming folders on the nspire.
Browse files Browse the repository at this point in the history
  • Loading branch information
the-blank-x authored and debrouxl committed Nov 13, 2023
1 parent dab8afe commit 5db5620
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions libticalcs/trunk/src/calc_nsp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
}
Expand All @@ -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;
Expand Down

0 comments on commit 5db5620

Please sign in to comment.