Gabriel Genellina wrote:
> En Thu, 01 Feb 2007 21:33:03 -0300, Gigs_ <[EMAIL PROTECTED]> escribió:
>
>> class CVisitor(FileVisitor):
>> def __init__(self, fromdir, todir):
>> self.fromdirLen = len(fromdir) + 1 # here is my problem
>> self.todir = todir
>> FileVisitor.__init__(self, fromdir)
>> def visitdir(self, dirpath):
>> topath = os.path.join(self.todir, dirpath[self.fromdirLen:])
>> os.mkdir(topath)
>> def visitfile(self, filepath):
>> topath = os.path.join(self.todir, filepath[self.fromdirLen:])
>> cpfile(filepath, topath) #copy contents from filepath to
>> topath[/code]
>>
>>
>> When I copy contents from C:\IronPython to C:\temp
>> its all goes fine when self.fromdirLen = len(fromdir) + 1 is like this
>> self.fromdirLen = len(fromdir) + 1
>> but when I change self.fromdirLen = len(fromdir) + 1 to self.fromdirLen
>> = len(fromdir) i get contents copied to C:\ (actually to parent dir)
>
> Instead of actually doing os.mkdir and cpfile, use a print statement to
> output the involved variables, and try with and without +1. You'll see
> yourself what happens.
>
> --Gabriel Genellina
>
but when I change
self.fromdirLen = len(fromdir) + 1 to self.fromdirLen = len(fromdir) i
get contents copied to C:\ (actually to parent dir) instead to C:\temp
--
http://mail.python.org/mailman/listinfo/python-list