this is broken
git-svn-id: https://svn.musicpd.org/mpd/trunk@2597 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
01b494a852
commit
03f02badf0
@ -66,7 +66,7 @@ int printDirectoryInDirectory(FILE * fp, Directory * directory, void * data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int printSongInDirectory(FILE * fp, Song * song, void * data) {
|
int printSongInDirectory(FILE * fp, Song * song, void * data) {
|
||||||
myfprintf(fp,"file: %s\n",song->utf8url);
|
printSongUrl(fp, song);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
src/song.c
28
src/song.c
@ -40,11 +40,12 @@ Song * newNullSong() {
|
|||||||
song->tag = NULL;
|
song->tag = NULL;
|
||||||
song->utf8url = NULL;
|
song->utf8url = NULL;
|
||||||
song->type = SONG_TYPE_FILE;
|
song->type = SONG_TYPE_FILE;
|
||||||
|
song->parentDir = NULL;
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
|
|
||||||
Song * newSong(char * utf8url, SONG_TYPE type) {
|
Song * newSong(char * url, int type, Directory * parentDir) {
|
||||||
Song * song = NULL;
|
Song * song = NULL;
|
||||||
|
|
||||||
if(strchr(utf8url, '\n')) return NULL;
|
if(strchr(utf8url, '\n')) return NULL;
|
||||||
@ -53,6 +54,9 @@ Song * newSong(char * utf8url, SONG_TYPE type) {
|
|||||||
|
|
||||||
song->utf8url = strdup(utf8url);
|
song->utf8url = strdup(utf8url);
|
||||||
song->type = type;
|
song->type = type;
|
||||||
|
song->parentDir = parentDir;
|
||||||
|
|
||||||
|
assert(type == SONG_TYPE_URL || parentDir);
|
||||||
|
|
||||||
if(song->type == SONG_TYPE_FILE) {
|
if(song->type == SONG_TYPE_FILE) {
|
||||||
InputPlugin * plugin;
|
InputPlugin * plugin;
|
||||||
@ -86,25 +90,25 @@ SongList * newSongList() {
|
|||||||
return makeList((ListFreeDataFunc *)freeSong);
|
return makeList((ListFreeDataFunc *)freeSong);
|
||||||
}
|
}
|
||||||
|
|
||||||
Song * addSongToList(SongList * list, char * key, char * utf8url,
|
Song * addSongToList(SongList * list, char * url, int songType,
|
||||||
SONG_TYPE type)
|
Directory * parentDirectory)
|
||||||
{
|
{
|
||||||
Song * song = NULL;
|
Song * song = NULL;
|
||||||
|
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case SONG_TYPE_FILE:
|
case SONG_TYPE_FILE:
|
||||||
if(isMusic(utf8url,NULL)) {
|
if(isMusic(utf8url,NULL)) {
|
||||||
song = newSong(utf8url,type);
|
song = newSong(url, type, parentDirectory);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SONG_TYPE_URL:
|
case SONG_TYPE_URL:
|
||||||
song = newSong(utf8url,type);
|
song = newSong(utf8url, type, parentDirectory);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(song==NULL) return NULL;
|
if(song==NULL) return NULL;
|
||||||
|
|
||||||
insertInList(list,key,(void *)song);
|
insertInList(list, url, (void *)song);
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
}
|
}
|
||||||
@ -113,8 +117,18 @@ void freeSongList(SongList * list) {
|
|||||||
freeList(list);
|
freeList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void printSongUrl(FILE * fp, Song * song) {
|
||||||
|
if(song->parentDir) {
|
||||||
|
myfprintf(fp, "%s%s%s\n", SONG_FILE, song->parentDir->utf8name,
|
||||||
|
song->url);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
myfprintf(fp, "%s%s\n", SONG_FILE, song->url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int printSongInfo(FILE * fp, Song * song) {
|
int printSongInfo(FILE * fp, Song * song) {
|
||||||
myfprintf(fp,"%s%s\n",SONG_FILE,song->utf8url);
|
printSongUrl(fp, song);
|
||||||
|
|
||||||
if(song->tag) printMpdTag(fp,song->tag);
|
if(song->tag) printMpdTag(fp,song->tag);
|
||||||
|
|
||||||
|
23
src/song.h
23
src/song.h
@ -21,24 +21,23 @@
|
|||||||
|
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
|
||||||
#define SONG_BEGIN "songList begin"
|
|
||||||
#define SONG_END "songList end"
|
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
typedef enum {
|
#define SONG_BEGIN "songList begin"
|
||||||
SONG_TYPE_FILE = 1,
|
#define SONG_END "songList end"
|
||||||
SONG_TYPE_URL = 2
|
|
||||||
} SONG_TYPE;
|
#define SONG_TYPE_FILE 1
|
||||||
|
#define SONG_TYPE_URL 2
|
||||||
|
|
||||||
typedef struct _Song {
|
typedef struct _Song {
|
||||||
char * utf8url;
|
char * url;
|
||||||
SONG_TYPE type;
|
mpd_sint8 type;
|
||||||
MpdTag * tag;
|
MpdTag * tag;
|
||||||
|
struct _Directory * parentDir;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
} Song;
|
} Song;
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ typedef List SongList;
|
|||||||
|
|
||||||
Song * newNullSong();
|
Song * newNullSong();
|
||||||
|
|
||||||
Song * newSong(char * utf8url, SONG_TYPE type);
|
Song * newSong(char * utf8url, int songType, struct _Directory * parentDir);
|
||||||
|
|
||||||
void freeSong(Song *);
|
void freeSong(Song *);
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ SongList * newSongList();
|
|||||||
void freeSongList(SongList * list);
|
void freeSongList(SongList * list);
|
||||||
|
|
||||||
Song * addSongToList(SongList * list, char * key, char * utf8file,
|
Song * addSongToList(SongList * list, char * key, char * utf8file,
|
||||||
SONG_TYPE type);
|
int songType, struct _Directory * parentDir);
|
||||||
|
|
||||||
int printSongInfo(FILE * fp, Song * song);
|
int printSongInfo(FILE * fp, Song * song);
|
||||||
|
|
||||||
@ -71,4 +70,6 @@ int updateSongInfo(Song * song);
|
|||||||
|
|
||||||
Song * songDup(Song * song);
|
Song * songDup(Song * song);
|
||||||
|
|
||||||
|
void printSongUrl(FILE * fp, Song * song);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user