Commit aa1c52ee76eb5901e4c76c8924f4368063bb9a33
1 parent
89ba1584
Exists in
develop
Fixing keypad path.
Showing
4 changed files
with
56 additions
and
14 deletions
Show diff stats
src/include/pw3270.h
src/main/linux/tools.c
... | ... | @@ -20,12 +20,24 @@ |
20 | 20 | #include <config.h> |
21 | 21 | #include <pw3270.h> |
22 | 22 | |
23 | + gchar * pw3270_build_data_path(const char *name) { | |
24 | + | |
25 | + gchar * path = g_build_filename(G_STRINGIFY(DATADIR),name,NULL); | |
26 | + | |
27 | + if(g_file_test(path,G_FILE_TEST_IS_DIR)) { | |
28 | + return path; | |
29 | + } | |
30 | + g_free(path); | |
31 | + | |
32 | + g_message("Cant find path for '%s'",path); | |
33 | + return NULL; | |
34 | + | |
35 | + } | |
36 | + | |
23 | 37 | gchar * pw3270_build_data_filename(const char *filename) { |
24 | 38 | |
25 | 39 | gchar * path = g_build_filename(G_STRINGIFY(DATADIR),filename,NULL); |
26 | 40 | |
27 | - printf("\n\n\n%s\n\n\n",path); | |
28 | - | |
29 | 41 | if(g_file_test(path,G_FILE_TEST_IS_REGULAR)) { |
30 | 42 | return path; |
31 | 43 | } | ... | ... |
src/main/windows/tools.c
... | ... | @@ -20,6 +20,27 @@ |
20 | 20 | #include <config.h> |
21 | 21 | #include <pw3270.h> |
22 | 22 | |
23 | + gchar * pw3270_build_data_path(const char *name) { | |
24 | + | |
25 | + g_autofree gchar * pkgdir = g_win32_get_package_installation_directory_of_module(NULL); | |
26 | + | |
27 | + gchar * path = g_build_filename(pkgdir,name,NULL); | |
28 | + if(g_file_test(path,G_FILE_TEST_IS_DIR)) { | |
29 | + return path; | |
30 | + } | |
31 | + g_free(path); | |
32 | + | |
33 | + path = g_build_filename(pkgdir,"share",G_STRINGIFY(PRODUCT_NAME),name,NULL); | |
34 | + if(g_file_test(path,G_FILE_TEST_IS_DIR)) { | |
35 | + return path; | |
36 | + } | |
37 | + | |
38 | + g_free(path); | |
39 | + g_message("Cant find path for '%s'",path); | |
40 | + return NULL; | |
41 | + | |
42 | + } | |
43 | + | |
23 | 44 | gchar * pw3270_build_data_filename(const char *filename) { |
24 | 45 | |
25 | 46 | g_autofree gchar * pkgdir = g_win32_get_package_installation_directory_of_module(NULL); | ... | ... |
src/objects/application/application.c
... | ... | @@ -486,25 +486,33 @@ void startup(GApplication *application) { |
486 | 486 | // Load keypad models |
487 | 487 | // |
488 | 488 | { |
489 | - lib3270_autoptr(char) keypad_path = lib3270_build_data_filename("keypad",NULL); | |
489 | + g_autofree gchar *keypad_path = pw3270_build_data_path("keypad"); | |
490 | 490 | |
491 | - g_autoptr(GError) error = NULL; | |
492 | - g_autoptr(GDir) dir = g_dir_open(keypad_path,0,&error); | |
491 | + if(keypad_path) { | |
493 | 492 | |
494 | - if(dir) { | |
493 | + g_message("Searching for keypads in '%s'",keypad_path); | |
494 | + | |
495 | + g_autoptr(GError) error = NULL; | |
496 | + g_autoptr(GDir) dir = g_dir_open(keypad_path,0,&error); | |
497 | + | |
498 | + if(dir) { | |
499 | + | |
500 | + const gchar *name = g_dir_read_name(dir); | |
501 | + while(!error && name) { | |
502 | + g_autofree gchar * path = g_build_filename(keypad_path,name,NULL); | |
503 | + app->keypads = pw3270_keypad_model_new_from_xml(app->keypads,path); | |
504 | + name = g_dir_read_name(dir); | |
505 | + } | |
495 | 506 | |
496 | - const gchar *name = g_dir_read_name(dir); | |
497 | - while(!error && name) { | |
498 | - g_autofree gchar * path = g_build_filename(keypad_path,name,NULL); | |
499 | - app->keypads = pw3270_keypad_model_new_from_xml(app->keypads,path); | |
500 | - name = g_dir_read_name(dir); | |
501 | 507 | } |
502 | 508 | |
503 | - } | |
509 | + if(error) { | |
510 | + g_message("Can't read %s: %s",keypad_path,error->message); | |
511 | + } | |
512 | + | |
504 | 513 | |
505 | - if(error) { | |
506 | - g_message("Can't read %s: %s",keypad_path,error->message); | |
507 | 514 | } |
515 | + | |
508 | 516 | } |
509 | 517 | |
510 | 518 | // | ... | ... |