void GUI_OpenApplicationDataFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile(QString(ADM_getBaseDir()))); }
void GUI_OpenApplicationLog() { QDesktopServices::openUrl(QUrl::fromLocalFile(QString(ADM_getBaseDir()) + "admlog.txt")); }
int preferences::save_xml_to_file(){ char *dir_adm; char *rcfile; char *rcfilenew; dir_adm=ADM_getBaseDir(); if(!dir_adm) return RC_FAILED; rcfile=new char[strlen(dir_adm)+4+strlen(CONFIG)]; strcpy(rcfile,dir_adm); strcat(rcfile,"/"); strcat(rcfile,CONFIG); #if defined(__MINGW32__) xmlSetDocCompressMode(xdoc,9); if( xmlSaveFormatFile(rcfile,xdoc,1) == -1 ){ fprintf(stderr,"\ncan't save xml tree to file. Filesystem full?\n\n"); delete [] rcfile; return RC_FAILED; } delete [] rcfile; return RC_OK; #else rcfilenew=new char[strlen(rcfile)+5]; strcpy(rcfilenew,rcfile); strcat(rcfilenew,".new"); if( unlink(rcfilenew) == -1 && errno != ENOENT ){ fprintf(stderr,"can't unlink(%s): %d (%s)\n", rcfilenew, errno, strerror(errno)); delete [] rcfilenew; return RC_FAILED; } xmlSetDocCompressMode(xdoc,9); if( qxmlSaveFormatFile(rcfilenew,xdoc,1) == -1 ){ delete [] rcfilenew; delete [] rcfile; return RC_FAILED; } if( unlink(rcfile) == -1 && errno != ENOENT ){ fprintf(stderr,"can't unlink(%s): %d (%s)\n", rcfile, errno, strerror(errno)); delete [] rcfilenew; delete [] rcfile; return RC_FAILED; } if( link(rcfilenew,rcfile) == -1 ){ fprintf(stderr,"can't create \"%s\": %d (%s)\n", rcfile, errno, strerror(errno)); delete [] rcfilenew; delete [] rcfile; return RC_FAILED; } unlink(rcfilenew); // rc/errno handling is done on next call ;-) delete [] rcfilenew; delete [] rcfile; return RC_OK; #endif }
/** * \fn char *ADM_getHomeRelativePath(const char *base1, const char *base2=NULL,const char *base3=NULL); * \brief Returns home directory +base 1 + base 2... The return value is a copy, and must be deleted [] */ char *ADM_getHomeRelativePath(const char *base1, const char *base2, const char *base3) { return ADM_getRelativePath(ADM_getBaseDir(), base1, base2, base3); }
int preferences::load(){ xmlNodePtr p; char *rcfile; char *home; char *dir_adm; char buf[1024]; DIR *dir; dir_adm=ADM_getBaseDir(); if(!dir_adm) return RC_FAILED; rcfile=new char[strlen(dir_adm)+4+strlen(CONFIG)]; strcpy(rcfile,dir_adm); strcat(rcfile,"/"); strcat(rcfile,CONFIG); // Now build the filename if( access(rcfile,R_OK) == -1 ){ if( errno != ENOENT ) fprintf(stderr,"can't read(%s): %d (%s)\n", rcfile, errno, strerror(errno) ); delete [] rcfile; return RC_FAILED; } if( !(xdoc = xmlParseFile(rcfile)) ){ fprintf(stderr,"can't parse \"rcfile\".\n"); delete [] rcfile; return RC_FAILED; } delete [] rcfile; erase_blank_nodes(xdoc->children); p = xdoc->children; // ->avidemux buf[0] = '\0'; if( p ) p = p->children; // ->avidemux->??? while( p ){ if( strlen(buf) ){ strncpy(&buf[strlen(buf)],".",1024-strlen(buf)); buf[1023] = '\0'; } strncpy(&buf[strlen(buf)],(char*)p->name,1024-strlen(buf)); buf[1023] = '\0'; if( p->content ){ set_content(buf, p); }else if( p->children ){ xmlNodePtr c = p->children; if( c->type == XML_TEXT_NODE && ! c->children && ! c->next && ! c->prev ){ set_content(buf, c); // the routine below will go to c->parent->next (p->next) if we do: p = c; strncpy(&buf[strlen(buf)],".DUMMY",1024-strlen(buf)); buf[1023] = '\0'; } } if( p->children ){ // go down first p = p->children; }else if( p->next ){ // than go next char *t = rindex(buf,'.'); if( t ) *t = '\0'; else buf[0] = '\0'; p = p->next; }else{ // and last go up AND next do{ if( p->parent == xdoc->children ){ p = NULL; }else{ char *t = rindex(buf,'.'); if( t ) *t = '\0'; else buf[0] = '\0'; p = p->parent; } }while( p && ! p->next ); if( p ){ char *t = rindex(buf,'.'); if( t ) *t = '\0'; else buf[0] = '\0'; p = p->next; } } } // load xml to preferences // check ranges foreach val // set to min if <min or to max if >max - generate warning // warn about unused options printf("Preferences found and loaded\n"); return RC_OK; }