From cd2a2251d1a739b5d84f2543c280cf399eba47d0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Mon, 23 Jan 2012 15:04:53 +0100 Subject: [PATCH] make locateSyncProfile() a "tad" less convoluted Change-Id: I261b6c6b42bed576edb8a1d8420da19d34bd87a1 Reviewed-by: Marius Storm-Olsen Reviewed-by: Joerg Bornemann --- bin/syncqt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/bin/syncqt b/bin/syncqt index 15814df3f9..07b9d2432e 100755 --- a/bin/syncqt +++ b/bin/syncqt @@ -607,22 +607,14 @@ sub loadSyncProfile { sub locateSyncProfile { my ($directory) = @_; - my $syncprofile; $directory = abs_path($directory); - while(!defined $syncprofile) { - local(*D); - if (opendir(D, $directory)) { - foreach my $file (sort readdir(D)) { - next if ($file =~ /^\.\.?$/); - $syncprofile = "$directory/$file" if ($file =~ /^sync\.profile$/); - last if (defined $syncprofile); - } - closedir(D); - } - last if (defined $syncprofile || $directory eq "/" || $directory =~ /^?:[\/\\]$/); + while (1) { + my $file = $directory."/sync.profile"; + return $file if (-e $file); + my $odir = $directory; $directory = dirname($directory); + return undef if ($directory eq $odir); } - return $syncprofile; } # check if this is an in-source build, and if so use that as the basedir too