summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-10-06 13:53:32 +0000
committerLarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b>2005-10-06 13:53:32 +0000
commit2b1e09174a2e6778e8decaff8b946454d6343288 (patch)
treee718221b30eb3c62185bedba5a058a8a547760b0
parentea2fb28071fee9f56ebdecc6878df4801888a1bb (diff)
downloadvdr-plugin-muggle-2b1e09174a2e6778e8decaff8b946454d6343288.tar.gz
vdr-plugin-muggle-2b1e09174a2e6778e8decaff8b946454d6343288.tar.bz2
Use realpath for comparing directories
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@846 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r--mg_tools.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/mg_tools.c b/mg_tools.c
index d691976..7b8a83c 100644
--- a/mg_tools.c
+++ b/mg_tools.c
@@ -178,42 +178,20 @@ notempty(const char *s)
bool samedir( const char *d1, const char *d2 )
{
- bool result;
-
- if( !strcmp( d1, d2 ) )
- {
- result = true;
- }
- else
- {
- // check for trailing slash
- int l1 = strlen( d1 );
- int l2 = strlen( d2 );
-
- if( l1 == l2 + 1 )
- {
- if( !strncmp( d1, d2, l2 ) && d1[l1-1] == '/' )
- {
- result = true;
- }
- else
- {
- result = false;
- }
- }
- else
- {
- if( l2 == l1 + 1 )
- {
- if( !strncmp( d1, d2, l1 ) && d2[l2-1] == '/' )
- {
- result = true;
- }
- else
- {
- result = false;
- }
- }
- }
- }
+ int path_max;
+
+#ifdef PATH_MAX
+ path_max = PATH_MAX;
+#else
+ path_max = pathconf (path, _PC_PATH_MAX);
+ if (path_max <= 0)
+ path_max = 4096;
+#endif
+
+ char rp1[path_max], rp2[path_max];
+
+ realpath(d1, rp1);
+ realpath(d2, rp2);
+
+ return (!strcmp( d1, d2 ) );
}