/** * tnsp_file_display: * @filename: a TI file. * * Determine file class and display internal content. * * Return value: an error code, 0 otherwise. **/ int tnsp_file_display(const char *filename) { FileContent *content1; FlashContent *content3; int ret; if (tifiles_file_is_os(filename)) { content3 = tifiles_content_create_flash(CALC_NSPIRE); ret = tnsp_file_read_flash(filename, content3); if (!ret) { tnsp_content_display_flash(content3); tifiles_content_delete_flash(content3); } } else if (tifiles_file_is_regular(filename)) { content1 = tifiles_content_create_regular(CALC_NSPIRE); ret = tnsp_file_read_regular(filename, content1); if (!ret) { tifiles_file_display_regular(content1); tifiles_content_delete_regular(content1); } } else { tifiles_info("Unknown file type !"); return ERR_BAD_FILE; } return ret; }
/** * tifiles_group_del_file: * @src_filename: the file to remove from group file * @dst_filename: the group file * * Search for entry and remove it from file. * * Return value: 0 if successful, an error code otherwise. **/ TIEXPORT2 int TICALL tifiles_group_del_file(VarEntry *entry, const char *dst_filename) { CalcModel dst_model; FileContent* dst_content = NULL; int ret = 0; if (entry == NULL || dst_filename == NULL) { tifiles_critical("%s: an argument is NULL", __FUNCTION__); return ERR_INVALID_FILE; } // src can be single/group file and dst must be group file if(!tifiles_file_is_group(dst_filename)) return -1; dst_model = tifiles_file_get_model(dst_filename); dst_content = tifiles_content_create_regular(dst_model); ret = tifiles_file_read_regular(dst_filename, dst_content); if(ret) goto tgdf; tifiles_content_del_entry(dst_content, entry); tifiles_file_display_regular(dst_content); ret = tifiles_file_write_regular(dst_filename, dst_content, NULL); if(ret) goto tgdf; tgdf: tifiles_content_delete_regular(dst_content); return ret; }
/** * ti9x_file_display: * @filename: a TI file. * * Determine file class and display internal content. * * Return value: an error code, 0 otherwise. **/ int ti9x_file_display(const char *filename) { Ti9xRegular *content1; Ti9xBackup *content2; Ti9xFlash *content3; int ret; // the testing order is important: regular before backup (due to TI89/92+) if (tifiles_file_is_flash(filename) || tifiles_file_is_tib(filename)) { content3 = tifiles_content_create_flash(CALC_TI92); ret = ti9x_file_read_flash(filename, content3); if (!ret) { ti9x_content_display_flash(content3); tifiles_content_delete_flash(content3); } } else if (tifiles_file_is_regular(filename)) { content1 = tifiles_content_create_regular(CALC_TI92); ret = ti9x_file_read_regular(filename, content1); if (!ret) { tifiles_file_display_regular(content1); tifiles_content_delete_regular(content1); } } else if (tifiles_file_is_backup(filename)) { content2 = tifiles_content_create_backup(CALC_TI92); ret = ti9x_file_read_backup(filename, content2); if (!ret) { ti9x_content_display_backup(content2); tifiles_content_delete_backup(content2); } } else { tifiles_info("Unknown file type !"); return ERR_BAD_FILE; } return ret; }