summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-08-10 20:47:12 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-08-10 20:47:12 +0200
commit60623784ba8afcbed579a725d77b8eb8df357d75 (patch)
tree3ba1b7867734e19046a4cec368a7e2d1a92713fe /playlist.c
parentfdf80efad030a51ba49380606c4e1bf18f9fa687 (diff)
added "follow symlinks" option to Add Folder(s) dialog
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/playlist.c b/playlist.c
index 29ca4560..9d4b2caa 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1356,15 +1356,19 @@ static int dirent_alphasort (const struct dirent **a, const struct dirent **b) {
return strcmp ((*a)->d_name, (*b)->d_name);
}
+static int follow_symlinks = 0;
+
playItem_t *
-pl_insert_dir (playItem_t *after, const char *dirname, int *pabort, int (*cb)(playItem_t *it, void *data), void *user_data) {
+pl_insert_dir_int (playItem_t *after, const char *dirname, int *pabort, int (*cb)(playItem_t *it, void *data), void *user_data) {
if (!memcmp (dirname, "file://", 7)) {
dirname += 7;
}
- struct stat buf;
- lstat (dirname, &buf);
- if (S_ISLNK(buf.st_mode)) {
- return NULL;
+ if (!follow_symlinks) {
+ struct stat buf;
+ lstat (dirname, &buf);
+ if (S_ISLNK(buf.st_mode)) {
+ return NULL;
+ }
}
struct dirent **namelist = NULL;
int n;
@@ -1386,7 +1390,7 @@ pl_insert_dir (playItem_t *after, const char *dirname, int *pabort, int (*cb)(pl
{
char fullname[PATH_MAX];
snprintf (fullname, sizeof (fullname), "%s/%s", dirname, namelist[i]->d_name);
- playItem_t *inserted = pl_insert_dir (after, fullname, pabort, cb, user_data);
+ playItem_t *inserted = pl_insert_dir_int (after, fullname, pabort, cb, user_data);
if (!inserted) {
inserted = pl_insert_file (after, fullname, pabort, cb, user_data);
}
@@ -1404,6 +1408,12 @@ pl_insert_dir (playItem_t *after, const char *dirname, int *pabort, int (*cb)(pl
return after;
}
+playItem_t *
+pl_insert_dir (playItem_t *after, const char *dirname, int *pabort, int (*cb)(playItem_t *it, void *data), void *user_data) {
+ follow_symlinks = conf_get_int ("add_folders_follow_symlinks", 0);
+ return pl_insert_dir_int (after, dirname, pabort, cb, user_data);
+}
+
int
pl_add_file (const char *fname, int (*cb)(playItem_t *it, void *data), void *user_data) {
int abort = 0;