summaryrefslogtreecommitdiffstats
path: root/Modules/posixmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-07-18 18:16:52 (GMT)
committerGuido van Rossum <guido@python.org>1995-07-18 18:16:52 (GMT)
commit24f42ac74c360eab36721bb01293940d2a743dd5 (patch)
tree52a9fd6d81cd28b4e72d48d0b3356ceff44bcbc8 /Modules/posixmodule.c
parent681d79aaf397850778608f35585d091fa7fe370a (diff)
downloadcpython-24f42ac74c360eab36721bb01293940d2a743dd5.zip
cpython-24f42ac74c360eab36721bb01293940d2a743dd5.tar.gz
cpython-24f42ac74c360eab36721bb01293940d2a743dd5.tar.bz2
suppress . and .. in listdir return value
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r--Modules/posixmodule.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 3d4bdcf..ffddd09 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -408,6 +408,11 @@ posix_listdir(self, args)
return posix_error();
}
do {
+ if (FileData.cFileName[0] == '.' &&
+ (FileData.cFileName[1] == '\0' ||
+ FileData.cFileName[1] == '.' &&
+ FileData.cFileName[2] == '\0'))
+ continue;
v = newstringobject(FileData.cFileName);
if (v == NULL) {
DECREF(d);
@@ -449,6 +454,10 @@ posix_listdir(self, args)
return NULL;
}
while ((ep = readdir(dirp)) != NULL) {
+ if (ep->d_name[0] == '.' &&
+ (NAMLEN(ep) == 1 ||
+ ep->d_name[1] == '.' && NAMLEN(ep) == 2))
+ continue;
v = newsizedstringobject(ep->d_name, NAMLEN(ep));
if (v == NULL) {
DECREF(d);