2557
|
1
|
|
2 char *get_path(char *filename){
|
|
3 char *homedir;
|
|
4 char *buff;
|
|
5 static char *config_dir = "/.mplayer";
|
|
6 int len;
|
|
7
|
|
8 if ((homedir = getenv("HOME")) == NULL)
|
|
9 return NULL;
|
|
10 len = strlen(homedir) + strlen(config_dir) + 1;
|
|
11 if (filename == NULL) {
|
|
12 if ((buff = (char *) malloc(len)) == NULL)
|
|
13 return NULL;
|
|
14 sprintf(buff, "%s%s", homedir, config_dir);
|
|
15 } else {
|
|
16 len += strlen(filename) + 1;
|
|
17 if ((buff = (char *) malloc(len)) == NULL)
|
|
18 return NULL;
|
|
19 sprintf(buff, "%s%s/%s", homedir, config_dir, filename);
|
|
20 }
|
|
21 return buff;
|
|
22 }
|