comparison io.c @ 1294:a719e2c98b54

Allow variables in screenshot_path like initial_path
author Michael Pavone <pavone@retrodev.com>
date Tue, 21 Mar 2017 19:56:50 -0700
parents a4fa897c99ce
children 071e761bcdcf
comparison
equal deleted inserted replaced
1293:72ea3885e7b5 1294:a719e2c98b54
494 current_system->soft_reset(current_system); 494 current_system->soft_reset(current_system);
495 break; 495 break;
496 case UI_SCREENSHOT: { 496 case UI_SCREENSHOT: {
497 char *screenshot_base = tern_find_path(config, "ui\0screenshot_path\0").ptrval; 497 char *screenshot_base = tern_find_path(config, "ui\0screenshot_path\0").ptrval;
498 if (!screenshot_base) { 498 if (!screenshot_base) {
499 screenshot_base = get_home_dir(); 499 screenshot_base = "$HOME";
500 } 500 }
501 tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir());
502 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir());
503 screenshot_base = replace_vars(screenshot_base, vars, 1);
504 tern_free(vars);
501 time_t now = time(NULL); 505 time_t now = time(NULL);
502 struct tm local_store; 506 struct tm local_store;
503 char fname_part[256]; 507 char fname_part[256];
504 char *template = tern_find_path(config, "ui\0screenshot_template\0").ptrval; 508 char *template = tern_find_path(config, "ui\0screenshot_template\0").ptrval;
505 if (!template) { 509 if (!template) {
506 template = "blastem_%c.ppm"; 510 template = "blastem_%c.ppm";
507 } 511 }
508 strftime(fname_part, sizeof(fname_part), template, localtime_r(&now, &local_store)); 512 strftime(fname_part, sizeof(fname_part), template, localtime_r(&now, &local_store));
509 char const *parts[] = {screenshot_base, PATH_SEP, fname_part}; 513 char const *parts[] = {screenshot_base, PATH_SEP, fname_part};
510 char *path = alloc_concat_m(3, parts); 514 char *path = alloc_concat_m(3, parts);
515 free(screenshot_base);
511 render_save_screenshot(path); 516 render_save_screenshot(path);
512 break; 517 break;
513 } 518 }
514 case UI_EXIT: 519 case UI_EXIT:
515 current_system->request_exit(current_system); 520 current_system->request_exit(current_system);