Commit 362862e486092553b574ae6e21bff42f0529cf91

Authored by perry.werneck@gmail.com
1 parent 67471cd9

Corrigindo deteccao automatica do diretorio de dados em linux

Showing 1 changed file with 2 additions and 78 deletions   Show diff stats
src/gtk/common/config.c
... ... @@ -522,83 +522,6 @@ gchar * build_data_filename(const gchar *first_element, ...)
522 522 }
523 523 #endif // WIN_REGISTRY_ENABLED
524 524  
525   -/*
526   -#if defined( WIN_REGISTRY_ENABLED )
527   -
528   - gchar *reg_datadir = g_strconcat("SOFTWARE\\",g_get_application_name(),"\\datadir",NULL);
529   -
530   - HKEY hKey = 0;
531   - LONG rc = 0;
532   -
533   - // Note: This could be needed: http://support.microsoft.com/kb/556009
534   - // http://msdn.microsoft.com/en-us/library/windows/desktop/aa384129(v=vs.85).aspx
535   -
536   - rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,reg_datadir,0,KEY_QUERY_VALUE|KEY_WOW64_64KEY,&hKey);
537   - SetLastError(rc);
538   -
539   - if(rc == ERROR_SUCCESS)
540   - {
541   - char data[4096];
542   - unsigned long datalen = sizeof(data); // data field length(in), data returned length(out)
543   - unsigned long datatype; // #defined in winnt.h (predefined types 0-11)
544   -
545   - if(RegQueryValueExA(hKey,NULL,NULL,&datatype,(LPBYTE) data,&datalen) == ERROR_SUCCESS)
546   - {
547   - result = g_string_new(g_strchomp(data));
548   - }
549   - else
550   - {
551   - gchar *msg = get_last_error_msg();
552   - g_warning("Error \"%s\" getting value from HKLM\\%s",msg,reg_datadir);
553   - g_free(msg);
554   - result = g_string_new(".");
555   - }
556   - RegCloseKey(hKey);
557   - }
558   - else
559   - {
560   - static const gchar *datadir = NULL;
561   -
562   - gchar *msg = get_last_error_msg();
563   - g_warning("Error \"%s\" opening HKLM\\%s, searching system config dirs",msg,reg_datadir);
564   - g_free(msg);
565   -
566   - if(!datadir)
567   - {
568   - const gchar * const * dir = g_get_system_config_dirs();
569   - int f;
570   -
571   - for(f=0;dir[f] && !datadir;f++)
572   - {
573   - gchar *name = g_build_filename(dir[f],PACKAGE_NAME,NULL);
574   -
575   - trace("Searching for \"%s\"",name);
576   -
577   - if(g_file_test(name,G_FILE_TEST_IS_DIR))
578   - datadir = name;
579   - else
580   - g_free(name);
581   - }
582   -
583   - if(!datadir)
584   - {
585   - datadir = g_get_current_dir();
586   - g_warning("Unable to find application datadir, using %s",datadir);
587   - }
588   -
589   - }
590   -
591   - result = g_string_new(datadir);
592   -
593   - }
594   -
595   -#elif defined(APPDATA) && !defined(WIN32)
596   -
597   - result = g_string_new(APPDATA);
598   -
599   -#endif
600   -
601   -*/
602 525  
603 526 if(!result)
604 527 {
... ... @@ -613,8 +536,9 @@ gchar * build_data_filename(const gchar *first_element, ...)
613 536 for(f=0;dir[f] && !datadir;f++)
614 537 {
615 538 gchar *name = g_build_filename(dir[f],appname[p],NULL);
  539 + trace("Searching for %s: %s",name,g_file_test(name,G_FILE_TEST_IS_DIR) ? "Ok" : "Not found");
616 540 if(g_file_test(name,G_FILE_TEST_IS_DIR))
617   - datadir = name;
  541 + result = g_string_new(datadir = name);
618 542 else
619 543 g_free(name);
620 544 }
... ...