summaryrefslogtreecommitdiff
path: root/mg_tools.c
diff options
context:
space:
mode:
Diffstat (limited to 'mg_tools.c')
-rw-r--r--mg_tools.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/mg_tools.c b/mg_tools.c
index 1f8654b..d691976 100644
--- a/mg_tools.c
+++ b/mg_tools.c
@@ -175,3 +175,45 @@ notempty(const char *s)
else
return strlen(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;
+ }
+ }
+ }
+ }
+}