updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / gsopcast-svn / gsopcast-xdg.patch
blob5e5eae8495e4a68e9bbee2f837bb3f98389f294f
1 --- src/loadsave.cc.orig 2008-11-16 21:06:54.954719930 +0800
2 +++ src/loadsave.cc 2008-11-16 21:16:50.287993666 +0800
3 @@ -36,7 +36,7 @@
4 void load_config()
6 //initialize by default
7 - strcpy(channels_url, "http://www.sopcast.com/gchlxml");
8 + strcpy(channels_url, "http://www.sopcast.cn/gchlxml");
9 strcpy(channels_url_header, "sop://");
10 strcpy(record_dir, getenv("HOME"));
11 strcat(record_dir, "/SOPCAST/");
12 @@ -53,8 +53,15 @@
13 size_t len = 0;
14 char *strtok_buffer = NULL;
15 char *ptr;
16 - std::string data_path = getenv("HOME");
17 - data_path += "/.gsopcast/config";
18 + std::string data_path;
19 + if( getenv("XDG_CONFIG_HOME") != NULL ){
20 + data_path = getenv("XDG_CONFIG_HOME");
21 + data_path += "/gsopcast/config";
22 + }
23 + else{
24 + data_path = getenv("HOME");
25 + data_path += "/.config/gsopcast/config";
26 + }
27 FILE *fp = fopen(data_path.c_str(), "r");
28 if (fp == NULL)
29 return;
30 @@ -125,8 +131,15 @@
31 //-----------------------------------------------------
32 void save_config()
34 - std::string data_path = getenv("HOME");
35 - data_path += "/.gsopcast/";
36 + std::string data_path;
37 + if( getenv("XDG_CONFIG_HOME") != NULL ){
38 + data_path = getenv("XDG_CONFIG_HOME");
39 + data_path += "/gsopcast/";
40 + }
41 + else{
42 + data_path = getenv("HOME");
43 + data_path += "/.config/gsopcast/";
44 + }
45 if (access(data_path.c_str(), F_OK))
46 mkdir(data_path.c_str(), S_IRWXU);
47 data_path += "config";
48 @@ -187,8 +201,15 @@
49 memset(tree_state, 0, sizeof(tree_state));
50 memset(org_tree_state, 0, sizeof(org_tree_state));
52 - std::string data_path = getenv("HOME");
53 - data_path += "/.gsopcast/tree";
54 + std::string data_path;
55 + if( getenv("XDG_CONFIG_HOME") != NULL ){
56 + data_path = getenv("XDG_CONFIG_HOME");
57 + data_path += "/gsopcast/tree";
58 + }
59 + else{
60 + std::string data_path = getenv("HOME");
61 + data_path += "/.config/gsopcast/tree";
62 + }
64 FILE *fp = fopen(data_path.c_str(), "r");
65 if (fp != NULL) {
66 @@ -207,8 +228,15 @@
67 if (memcmp(tree_state, org_tree_state, sizeof(tree_state))) ////if different
69 ////save tree state
70 - std::string data_path = getenv("HOME");
71 - data_path += "/.gsopcast/";
72 + std::string data_path;
73 + if( getenv("XDG_CONFIG_HOME") != NULL ){
74 + data_path = getenv("XDG_CONFIG_HOME");
75 + data_path += "/gsopcast/";
76 + }
77 + else{
78 + data_path = getenv("HOME");
79 + data_path += "/.config/gsopcast/";
80 + }
81 if (access(data_path.c_str(), F_OK))
82 mkdir(data_path.c_str(), S_IRWXU);
83 data_path += "tree";