code: func stat(name string) (*info, error) {
  	f, err := os.Open(filepath.Clean(name))
  	if err != nil {
  		return nil, err
  	}
  
  	var di info
  
  	var buf bytes.Buffer
  
  	_, err = io.CopyN(&buf, f, int64(binary.Size(di.Header)))
  	if err != nil {
  		return nil, err
  	}
  
  	fi, err := f.Stat()
  	if err != nil {
  		return nil, err
  	}
  
  	err = f.Close()
  	if err != nil {
  		return nil, err
  	}
  
  	err = binary.Read(&buf, binary.LittleEndian, &di.Header)
  	if err != nil {
  		return nil, err
  	}
  
  	if di.Header.MagicNumber != 0x564d444b { // SPARSE_MAGICNUMBER
  		return nil, ErrInvalidFormat
  	}
  
  	if di.Header.Flags&(1<<16) == 0 { // SPARSEFLAG_COMPRESSED
  		// Needs to be converted, for example:
  		//   vmware-vdiskmanager -r src.vmdk -t 5 dst.vmdk
  		//   qemu-img convert -O vmdk -o subformat=streamOptimized src.vmdk dst.vmdk
  		return nil, ErrInvalidFormat
  	}
  
  	di.Capacity = di.Header.Capacity * 512 // VMDK_SECTOR_SIZE
  	di.Size = fi.Size()
  	di.Name = filepath.Base(name)
  	di.ImportName = strings.TrimSuffix(di.Name, ".vmdk")
  
  	return &di, nil
  }
docs: // stat looks at the vmdk header to make sure the format is streamOptimized and
  // extracts the disk capacity required to properly generate the ovf descriptor.