parameters: (source, target)
docstring: link(source, target) -> None
  
      Attempt to hard link the source file to the target file name.
      On OS/2, this creates a complete copy of the source file.
docstring_summary: link(source, target) -> None
docstring_tokens: link ( source target ) - > None
function: def link(source, target):
      """link(source, target) -> None
  
      Attempt to hard link the source file to the target file name.
      On OS/2, this creates a complete copy of the source file.
      """
  
      s = os.open(source, os.O_RDONLY | os.O_BINARY)
      if os.isatty(s):
          raise OSError, (errno.EXDEV, 'Cross-device link')
      data = os.read(s, 1024)
  
      try:
          t = os.open(target, os.O_WRONLY | os.O_BINARY | os.O_CREAT | os.O_EXCL)
      except OSError:
          os.close(s)
          raise
  
      try:
          while data:
              os.write(t, data)
              data = os.read(s, 1024)
      except OSError:
          os.close(s)
          os.close(t)
          os.unlink(target)
          raise
  
      os.close(s)
      os.close(t)
function_tokens: def link ( source , target ) : s = os . open ( source , os . O_RDONLY | os . O_BINARY ) if os . isatty ( s ) : raise OSError , ( errno . EXDEV , 'Cross-device link' ) data = os . read ( s , 1024 ) try : t = os . open ( target , os . O_WRONLY | os . O_BINARY | os . O_CREAT | os . O_EXCL ) except OSError : os . close ( s ) raise try : while data : os . write ( t , data ) data = os . read ( s , 1024 ) except OSError : os . close ( s ) os . close ( t ) os . unlink ( target ) raise os . close ( s ) os . close ( t )