From 99edf86bacf8876f72efb383a4d9ddef0850fec3 Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Thu, 8 Sep 2011 22:22:48 +0000
Subject: [PATCH] GLOB_ONLYDIR is non-standard, not supported on FreeBSD, and
 when it is supported, doesn't always work correctly (e.g. it's just a
 "hint").

---
 src/xpdev/dirwrap.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c
index bf8c2474ad..a6e902aadb 100644
--- a/src/xpdev/dirwrap.c
+++ b/src/xpdev/dirwrap.c
@@ -313,13 +313,19 @@ long DLLCALL getdirsize(const char* path, BOOL include_subdirs, BOOL subdir_only
 	SAFECOPY(match,path);
 	backslash(match);
 	strcat(match,ALLFILES);
-	glob(match,subdir_only ? GLOB_ONLYDIR:GLOB_MARK,NULL,&g);
-	if(include_subdirs || subdir_only)
+	glob(match,GLOB_MARK,NULL,&g);
+	if(include_subdirs && !subdir_only)
 		count=g.gl_pathc;
 	else
-   		for(gi=0;gi<g.gl_pathc;gi++)
-			if(*lastchar(g.gl_pathv[gi])!='/')
-				count++;
+		for(gi=0;gi<g.gl_pathc;gi++) {
+			if(*lastchar(g.gl_pathv[gi])=='/') {
+				if(!include_subdirs)
+					continue;
+			} else
+				if(subdir_only)
+					continue;
+			count++;
+		}
 	globfree(&g);
 	return(count);
 }
-- 
GitLab