You could probably:
cd to dir1
getcwd
cd to dir2
getcwd
repeat
cd ..
getcwd
if getcwd == dir1's cwd, then under
until at /
cd to dir1
repeat
cd ..
getcwd
if getcwd == dir2's cwd, then under
until at /
This should deal with symlinks and junctions, as long as you aren't worried
Hi Thomas,
Thomas Jollans wrote:
> On 07/11/2010 03:37 PM, Gelonida wrote:
>> #
>> import os
>> def is_below_dir(fname,topdir):
>> relpath = os.path.relpath(fname,topdir)
>> return not relpath.startswith('..'+os.sep)
>>
>> print is_below_dir(
On 07/11/2010 03:37 PM, Gelonida wrote:
> #
> import os
> def is_below_dir(fname,topdir):
> relpath = os.path.relpath(fname,topdir)
> return not relpath.startswith('..'+os.sep)
>
> print is_below_dir(path1,path2)
> ###