static int del_var (CalcHandle* handle, VarRequest* vr) { char *utf8; char *path; int ret; ret = nsp_session_open(handle, NSP_SID_FILE_MGMT); if (ret) { return ret; } path = build_path(handle->model, vr); utf8 = ticonv_varname_to_utf8(handle->model, path, vr->type); ticalcs_slprintf(update_->text, sizeof(update_->text), _("Deleting %s..."), utf8); ticonv_utf8_free(utf8); update_label(); ret = nsp_cmd_s_del_file(handle, path); g_free(path); if (!ret) { ret = nsp_cmd_r_del_file(handle); } DO_CLOSE_SESSION(handle); return ret; }
static int del_var (CalcHandle* handle, VarRequest* vr) { char *utf8; char *path; int err; const char * dot_if_any = "."; TRYF(nsp_session_open(handle, SID_FILE_MGMT)); // Don't add a dot if this file type is unknown. if (vr->type >= NSP_MAXTYPES) dot_if_any = ""; path = g_strconcat("/", vr->folder, "/", vr->name, dot_if_any, tifiles_vartype2fext(handle->model, vr->type), NULL); utf8 = ticonv_varname_to_utf8(handle->model, path, vr->type); g_snprintf(update_->text, sizeof(update_->text), _("Deleting %s..."), utf8); g_free(utf8); update_label(); err = nsp_cmd_s_del_file(handle, path); g_free(path); if (err) { return err; } TRYF(nsp_cmd_r_del_file(handle)); TRYF(nsp_session_close(handle)); return 0; }