bool Frame::write_aov_images(const char* file_path) const { assert(file_path); const ImageAttributes image_attributes = ImageAttributes::create_default_attributes(); bool result = true; if (!impl->m_aov_images->empty()) { const filesystem::path boost_file_path(file_path); const filesystem::path directory = boost_file_path.parent_path(); const string base_file_name = boost_file_path.stem().string(); const string extension = boost_file_path.extension().string(); for (size_t i = 0; i < impl->m_aov_images->size(); ++i) { const string aov_name = impl->m_aov_images->get_name(i); const string safe_aov_name = make_safe_filename(aov_name); const string aov_file_name = base_file_name + "." + safe_aov_name + extension; const string aov_file_path = (directory / aov_file_name).string(); // Note: AOVs are always in the linear color space. if (!write_image( aov_file_path.c_str(), impl->m_aov_images->get_image(i), image_attributes)) result = false; } } return result; }
static int ls_open_log( ChannelLog *cl ) { static char fname[MAXPATH]; /* first, make sure the logdir dir exists */ if( os_create_dir( LogServ.logdir ) != NS_SUCCESS ) { return NS_FAILURE; } /* copy name to the filename holder( in case of invalid paths ) */ strlcpy( cl->filename, cl->channame, MAXPATH ); ircsnprintf( fname, MAXPATH, "%s/%s.log", LogServ.logdir, make_safe_filename( cl->filename ) ); /* open the file */ cl->logfile = os_fopen( fname, "a" ); if( cl->logfile == NULL ) { nlog( LOG_CRITICAL, "Could not open %s for appending: %s", cl->filename, os_strerror() ); return NS_FAILURE; } dlog( DEBUG1, "Opened %s for appending", cl->filename ); cl->ts_open = me.now; logging_funcs[LogServ.logtype][LGSMSG_START]( cl, NULL ); return NS_SUCCESS; }
int load_contacts_from_file(const char *file) { FILE *fp; extern int contactparse(); extern FILE *contactin; LList *cts = NULL; if (!(fp = fopen(file, "r"))) return 0; contactin = fp; contactparse(); fclose(fp); /* rename logs from old format (contact->nick) to new (contact->nick "-" contact->group->name) */ if (temp_groups && groups) { while (temp_groups) { grouplist *grp = (grouplist *)temp_groups->data; grouplist *oldgrp = NULL; if ((oldgrp = find_grouplist_by_name(grp->name)) == NULL) { eb_debug(DBG_CORE, "adding group %s\n", grp->name); add_group(grp->name); oldgrp = find_grouplist_by_name(grp->name); } while (grp->members) { struct contact *con = (struct contact *)grp->members->data; if (!find_contact_in_group_by_nick(con->nick, oldgrp)) { LList *w = con->accounts; int sid = 0; while (w) { eb_account *ea = (eb_account *)w->data; if (find_account_by_handle(ea-> handle, ea-> service_id)) { con->accounts = l_list_remove (con->accounts, ea); w = con->accounts; } else { sid = ea->service_id; w = w->next; } } if (!l_list_empty(con->accounts) && con->accounts->data) { eb_debug(DBG_CORE, " adding contact %s\n", con->nick); add_new_contact(grp->name, con->nick, sid); w = con->accounts; while (w) { add_account_silent(con-> nick, (eb_account *) w->data); eb_debug(DBG_CORE, " adding account %s\n", ((eb_account *) w-> data)-> handle); w = w->next; } } } else { while (con->accounts) { eb_account *ea = (eb_account *)con-> accounts->data; if (!find_account_by_handle(ea-> handle, ea-> service_id)) { add_account_silent(con-> nick, ea); eb_debug(DBG_CORE, " adding account to ex.ct %s\n", ea->handle); } con->accounts = con->accounts->next; } } grp->members = grp->members->next; } temp_groups = temp_groups->next; } } else if (temp_groups) { eb_debug(DBG_CORE, "First pass\n"); groups = temp_groups; } if (groups) { update_contact_list(); write_contact_list(); } cts = get_all_contacts(); for (; cts && cts->data; cts = cts->next) { struct contact *c = (struct contact *)cts->data; FILE *test = NULL; char buff[NAME_MAX]; eb_debug(DBG_CORE, "contact:%s\n", c->nick); make_safe_filename(buff, c->nick, c->group->name); if ((test = fopen(buff, "r")) != NULL) fclose(test); else rename_nick_log(NULL, c->nick, c->group->name, c->nick); } return 1; }