Is a File a Subdirectory of Another Directory

Fuzzyman michael at foord.net
Fri Feb 13 04:19:11 EST 2004


I wish to restrict access to a program to certain directories. I also
wish to prevent access to certain directories.

What this means is that given a path, I need to work out if that path
is in a certain directory... or in a subdirectory of that directory.
(On a Linux server).

The only way I can think of so far is to turn both paths into absolute
paths, strip off the filename and compare... is this the most elegant
way ?

Fuzzy

http://www.voidspace.org.uk/atlantibots/pythonutils.html



More information about the Python-list mailing list