Add all items in the PLS file to the population of the current node. Definition at line 71 of file vfs_playlist.c. 00072 { 00073 FILE *fio; 00074 char fbuf[1024]; 00075 char *ch, *dn, **out; 00076 int idxoff, nidx; 00077 00078 /* Current item */ 00079 int idx = -1; 00080 char *fn = NULL; 00081 char *title = NULL; 00082 00083 if ((fio = fopen(ve->filename, "r")) == NULL) 00084 return (-1); 00085 dn = g_path_get_dirname(ve->filename); 00086 00087 while (vfs_fgets(fbuf, sizeof fbuf, fio) == 0) { 00088 if (strncmp(fbuf, "File", 4) == 0) { 00089 /* Filename */ 00090 out = &fn; 00091 idxoff = 4; 00092 } else if (strncmp(fbuf, "Title", 5) == 0) { 00093 /* Song title */ 00094 out = &title; 00095 idxoff = 5; 00096 } else { 00097 continue; 00098 } 00099 00100 /* Parse the index number */ 00101 if ((nidx = atoi(fbuf + idxoff)) == 0) 00102 continue; 00103 00104 /* See if we have a value */ 00105 ch = strchr(fbuf + idxoff, '='); 00106 if ((ch == NULL) || (ch[1] == '\0')) 00107 continue; 00108 00109 if (nidx != idx) { 00110 /* We've arrived at the next entry */ 00111 if (fn != NULL) 00112 vfs_playlist_add_tail(ve, fn, title, dn); 00113 00114 g_free(fn); fn = NULL; 00115 g_free(title); title = NULL; 00116 idx = nidx; 00117 } 00118 00119 /* Copy the new value */ 00120 g_free(*out); 00121 *out = g_strdup(ch + 1); 00122 } 00123 00124 /* Don't forget our trailing entry */ 00125 if (fn != NULL) 00126 vfs_playlist_add_tail(ve, fn, title, dn); 00127 00128 g_free(fn); 00129 g_free(title); 00130 00131 fclose(fio); 00132 g_free(dn); 00133 00134 return (0); 00135 }
Here is the call graph for this function:
![]() |
1.6.3