Mercurial > audlegacy
comparison src/audlegacy/playlist.c @ 4873:be6c7aea8665
Use playlist_get_mtime, not plain stat, when sorting by date (bug #20)
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Sun, 26 Apr 2009 12:32:33 -0400 |
parents | 9501ad351ac0 |
children | 1127ed19b368 |
comparison
equal
deleted
inserted
replaced
4872:9501ad351ac0 | 4873:be6c7aea8665 |
---|---|
2178 | 2178 |
2179 static gint | 2179 static gint |
2180 playlist_compare_date(PlaylistEntry * a, | 2180 playlist_compare_date(PlaylistEntry * a, |
2181 PlaylistEntry * b) | 2181 PlaylistEntry * b) |
2182 { | 2182 { |
2183 struct stat buf; | 2183 time_t a_time, b_time; |
2184 time_t modtime; | 2184 a_time = playlist_get_mtime (a->filename); |
2185 | 2185 b_time = playlist_get_mtime (b->filename); |
2186 if (stat(a->filename, &buf) == 0) { | 2186 if (a_time < b_time) |
2187 modtime = buf.st_mtime; | 2187 return -1; |
2188 | 2188 if (a_time > b_time) |
2189 if (stat(b->filename, &buf) == 0) { | 2189 return 1; |
2190 if (buf.st_mtime == modtime) | 2190 return playlist_compare_filename (a, b); |
2191 return 0; | |
2192 else | |
2193 return (buf.st_mtime - modtime) > 0 ? -1 : 1; | |
2194 } | |
2195 else | |
2196 return -1; | |
2197 } | |
2198 else if (!lstat(b->filename, &buf)) | |
2199 return 1; | |
2200 else | |
2201 return playlist_compare_filename(a, b); | |
2202 } | 2191 } |
2203 | 2192 |
2204 | 2193 |
2205 void | 2194 void |
2206 playlist_sort(Playlist *playlist, PlaylistSortType type) | 2195 playlist_sort(Playlist *playlist, PlaylistSortType type) |