Mercurial > audlegacy
comparison src/audacious/main.c @ 2317:49d285f6008b trunk
[svn] Full support for XDG basedir added. The old config doesn't get automatically converted yet.
author | js |
---|---|
date | Sat, 13 Jan 2007 09:19:52 -0800 |
parents | 3149d4b1a9a9 |
children | 7868edc8e0af |
comparison
equal
deleted
inserted
replaced
2316:c22fe69a842d | 2317:49d285f6008b |
---|---|
450 } | 450 } |
451 | 451 |
452 void | 452 void |
453 make_directory(const gchar * path, mode_t mode) | 453 make_directory(const gchar * path, mode_t mode) |
454 { | 454 { |
455 if (mkdir(path, mode) == 0) | 455 if (g_mkdir_with_parents(path, mode) == 0) |
456 return; | 456 return; |
457 | 457 |
458 if (errno == EEXIST) | 458 g_printerr(_("Could not create directory (%s): %s\n"), path, |
459 return; | |
460 | |
461 g_printerr(_("Could not create directory (%s): %s"), path, | |
462 g_strerror(errno)); | 459 g_strerror(errno)); |
463 } | 460 } |
464 | 461 |
465 static void | 462 static void |
466 bmp_make_user_dir(void) | 463 bmp_make_user_dir(void) |
483 g_free(bmp_paths[i]); | 480 g_free(bmp_paths[i]); |
484 bmp_paths[i] = 0; | 481 bmp_paths[i] = 0; |
485 } | 482 } |
486 } | 483 } |
487 | 484 |
488 | |
489 #define USER_PATH(path) \ | |
490 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], path, NULL); | |
491 | |
492 static void | 485 static void |
493 bmp_init_paths(void) | 486 bmp_init_paths() |
494 { | 487 { |
495 bmp_paths[BMP_PATH_USER_DIR] = g_build_filename(g_get_home_dir(), BMP_RCPATH, NULL); | 488 char *xdg_config_home; |
496 | 489 char *xdg_data_home; |
497 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = USER_PATH(BMP_USER_PLUGIN_DIR_BASENAME); | 490 char *xdg_cache_home; |
498 bmp_paths[BMP_PATH_USER_SKIN_DIR] = USER_PATH(BMP_SKIN_DIR_BASENAME); | 491 |
499 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = USER_PATH(BMP_SKIN_THUMB_DIR_BASENAME); | 492 xdg_config_home = (getenv("XDG_CONFIG_HOME") == NULL |
500 bmp_paths[BMP_PATH_CONFIG_FILE] = USER_PATH(BMP_CONFIG_BASENAME); | 493 ? g_build_filename(g_get_home_dir(), ".config", NULL) |
501 bmp_paths[BMP_PATH_PLAYLIST_FILE] = USER_PATH(BMP_PLAYLIST_BASENAME); | 494 : g_strdup(getenv("XDG_CONFIG_HOME"))); |
502 bmp_paths[BMP_PATH_ACCEL_FILE] = USER_PATH(BMP_ACCEL_BASENAME); | 495 xdg_data_home = (getenv("XDG_DATA_HOME") == NULL |
503 bmp_paths[BMP_PATH_LOG_FILE] = USER_PATH(BMP_LOG_BASENAME); | 496 ? g_build_filename(g_get_home_dir(), ".local", "share", NULL) |
504 | 497 : g_strdup(getenv("XDG_DATA_HOME"))); |
505 g_atexit(bmp_free_paths); | 498 xdg_cache_home = (getenv("XDG_CACHE_HOME") == NULL |
506 } | 499 ? g_build_filename(g_get_home_dir(), ".cache", NULL) |
507 | 500 : g_strdup(getenv("XDG_CACHE_HOME"))); |
501 | |
502 bmp_paths[BMP_PATH_USER_DIR] = | |
503 g_build_filename(xdg_config_home, "audacious", NULL); | |
504 bmp_paths[BMP_PATH_USER_SKIN_DIR] = | |
505 g_build_filename(xdg_data_home, "audacious", "Skins", NULL); | |
506 // FIXME: Think of something better for Plugins, XDG is missing this | |
507 bmp_paths[BMP_PATH_USER_PLUGIN_DIR] = | |
508 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "Plugins", NULL); | |
509 bmp_paths[BMP_PATH_SKIN_THUMB_DIR] = | |
510 g_build_filename(xdg_cache_home, "audacious", "thumbs", NULL); | |
511 | |
512 bmp_paths[BMP_PATH_CONFIG_FILE] = | |
513 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "config", NULL); | |
514 #ifdef HAVE_XSPF_PLAYLIST | |
515 bmp_paths[BMP_PATH_PLAYLIST_FILE] = | |
516 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
517 "playlist.xspf", NULL); | |
518 #else | |
519 bmp_paths[BMP_PATH_PLAYLIST_FILE] = | |
520 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], | |
521 "playlist.m3u", NULL); | |
522 #endif | |
523 bmp_paths[BMP_PATH_ACCEL_FILE] = | |
524 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "accel", NULL); | |
525 bmp_paths[BMP_PATH_LOG_FILE] = | |
526 g_build_filename(bmp_paths[BMP_PATH_USER_DIR], "log", NULL); | |
527 | |
528 g_free(xdg_config_home); | |
529 g_free(xdg_data_home); | |
530 g_free(xdg_cache_home); | |
531 | |
532 g_atexit(bmp_free_paths); | |
533 } | |
508 | 534 |
509 void | 535 void |
510 bmp_config_load(void) | 536 bmp_config_load(void) |
511 { | 537 { |
512 ConfigDb *db; | 538 ConfigDb *db; |