You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: rar.go
    path of file: ./repos/scan4all/vendor/github.com/mholt/archiver
    
    the code of the file until where you have to start completion: package archiver

import (
	"bytes"
	"fmt"
	"io"
	"log"
	"os"
	"path"
	"path/filepath"
	"strings"
	"time"

	"github.com/nwaples/rardecode"
)

// Rar provides facilities for reading RAR archives.
// See https://www.ra
    
func (r *Rar) unrarFile(f File, to string) error {
	// do not overwrite existing files, if configured
	if !f.IsDir() && !r.OverwriteExisting && fileExists(to) {
		return fmt.Errorf("file already exists: %s", to)
	}

	hdr, ok := f.Header.(*rardecode.FileHeader)
	if !ok {
		return fmt.Errorf("expected header to be *rardecode.FileHeader but was %T", f.Header)
	}

	// if files come before their containing folders, then we must
	// create their folders before writing the file
	err := mkdir(filepath.Dir(to))
	if err != nil {
		return fmt.Errorf("making parent directories: %v", err)
	}

	return writeNewFile(to, r.rr, hdr.Mode())
}