Code

screen_lyrics.c: wrapped some duplicate code
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Sat, 3 Apr 2010 19:35:34 +0000 (21:35 +0200)
committerMax Kellermann <max@duempel.org>
Mon, 5 Apr 2010 17:05:00 +0000 (19:05 +0200)
src/screen_lyrics.c

index ba197a04c22a54905f3eba51fd217662aa62c3e3..6cb7b46efddf71590f40d010936a701f18b80d46 100644 (file)
@@ -87,14 +87,21 @@ lyrics_repaint_if_active(void)
        }
 }
 
+static void
+path_lyr_file(char *path, size_t size,
+               const char *artist, const char *title)
+{
+       snprintf(path, size, "%s/.lyrics/%s - %s.txt",
+                       getenv("HOME"), artist, title);
+}
+
 static bool
 exists_lyr_file(const char *artist, const char *title)
 {
        char path[1024];
        struct stat result;
 
-       snprintf(path, 1024, "%s/.lyrics/%s - %s.txt",
-                getenv("HOME"), artist, title);
+       path_lyr_file(path, 1024, artist, title);
 
        return (stat(path, &result) == 0);
 }
@@ -108,8 +115,7 @@ create_lyr_file(const char *artist, const char *title)
                 getenv("HOME"));
        mkdir(path, S_IRWXU);
 
-       snprintf(path, 1024, "%s/.lyrics/%s - %s.txt",
-                getenv("HOME"), artist, title);
+       path_lyr_file(path, 1024, artist, title);
 
        return fopen(path, "w");
 }