Logo Search packages:      
Sourcecode: hardlink version File versions

def hardlink::File::link (   self,
  other 
)

Link the current file to another one

Definition at line 100 of file hardlink.py.

00100                          :
        '''Link the current file to another one'''
        backup = other.path + '.bak'
        try:
            if not self.opts.dry_run:
                os.rename(other.path, backup)
        except OSError, err:
            print 'E: Renaming %s to %s failed - ' % (other.path, backup), err
            return
        try:
            if not self.opts.dry_run:
                os.link(self.path, other.path)
        except OSError, err:
            print 'E: Linking %s to %s failed -' % (self.path, other.path), err
            try:
                if not self.opts.dry_run:
                    os.rename(backup, other.path)
            except OSError, err:
                print 'E: Can not restore %s from backup -' % other.path, err
        else:
            if not self.opts.dry_run:
                os.unlink(backup)
            elif self.opts.verbose:
                print '[DryRun]',
            if self.opts.verbose:
                print 'Linking %s to %s (-%s)' % (self.path, other.path,
                                                  format(self.stat.st_size))
            other.link_count = self.link_count = self.link_count + 1
            self.linker.linked += 1
            self.linker.saved += self.stat.st_size
            return True

    def __lt__(self, other):


Generated by  Doxygen 1.6.0   Back to index