about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2004-04-01 18:33:05 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2004-04-01 18:33:05 +0000
commitfda060370fe0f6abe71be309c71ee7658adfc647 (patch)
treece0606288081e9ea16bf4d5138962a19654c2a81 /Src
parent1f03c7a78412984bd7153c996be2a9c530893bf2 (diff)
downloadzsh-fda060370fe0f6abe71be309c71ee7658adfc647.tar.gz
zsh-fda060370fe0f6abe71be309c71ee7658adfc647.tar.xz
zsh-fda060370fe0f6abe71be309c71ee7658adfc647.zip
19717: (F) glob qualifier for full directories
Diffstat (limited to 'Src')
-rw-r--r--Src/glob.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Src/glob.c b/Src/glob.c
index 857afc5fd..c0d23aa00 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1322,6 +1322,9 @@ zglob(LinkList list, LinkNode np, int nountok)
 		    func = qualmodeflags;
 		    data = qgetmodespec(&s);
 		    break;
+		case 'F':
+		    func = qualnonemptydir;
+		    break;
 		case 'M':
 		    /* Mark directories with a / */
 		    if ((gf_markdirs = !(sense & 1)))
@@ -2799,3 +2802,24 @@ qualsheval(char *name, struct stat *buf, off_t days, char *str)
     }
     return 0;
 }
+
+/**/
+static int
+qualnonemptydir(char *name, struct stat *buf, off_t days, char *str)
+{
+    DIR *dirh = opendir(name);
+    struct dirent *de;
+
+    if (dirh == NULL)
+	return 0;
+
+    while ((de = readdir(dirh))) {
+	if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
+	    closedir(dirh);
+	    return 1;
+	}
+    }
+
+    closedir(dirh);
+    return 0;
+}