<commit_before>package main

import (
	"github.com/mitchellh/go-homedir"
	"path/filepath"
	"os"
	"io/ioutil"
	"errors"
)

type LocalCache struct {
	uri string
}

func (l *LocalCache) WriteSimulation(hoverfile Hoverfile, data []byte) error {
	hoverfileUri := buildHoverfileUri(l.uri, hoverfile.GetFileName())

	return ioutil.WriteFile(hoverfileUri, data, 0644)
}


func (l *LocalCache) ReadSimulation(hoverfile Hoverfile) ([]byte, error) {
	hoverfileUri := buildHoverfileUri(l.uri, hoverfile.GetFileName())

	if !fileIsPresent(hoverfileUri) {
		return nil, errors.New("Simulation not found")
	}

	return ioutil.ReadFile(hoverfileUri)
}

func createHomeDirectory() (string, error) {
	homeDirectory, _ := homedir.Dir()
	hoverflyDirectory := filepath.Join(homeDirectory, "/.hoverfly")


	if !fileIsPresent(hoverflyDirectory) {
		err := os.Mkdir(hoverflyDirectory, 0777)
		if err == nil {
			return hoverflyDirectory, err
		} else {
			return "", err
		}
	}

	return hoverflyDirectory, nil
}

func createCacheDirectory(baseUri string) (string, error) {
	cacheDirectory := filepath.Join(baseUri, "cache/")

	if _, err := os.Stat(cacheDirectory); err != nil {
		if os.IsNotExist(err) {
			os.Mkdir(cacheDirectory, 0777)
		} else {
			return "", err
		}
	}

	return cacheDirectory, nil
}

func fileIsPresent(fileUri string) bool {
	if _, err := os.Stat(fileUri); err != nil {
		return os.IsExist(err)
	}

	return true
}

func buildHoverfileUri(baseUri string, fileName string) string {
	return filepath.Join(baseUri, fileName)
}<commit_msg>Renamed buildHoverfileUri function to buildAbsolutePath<commit_after>package main

import (
	"github.com/mitchellh/go-homedir"
	"path/filepath"
	"os"
	"io/ioutil"
	"errors"
)

type LocalCache struct {
	uri string
}

func (l *LocalCache) WriteSimulation(hoverfile Hoverfile, data []byte) error {
	hoverfileUri := buildAbsoluteFilePath(l.uri, hoverfile.GetFileName())

	return ioutil.WriteFile(hoverfileUri, data, 0644)
}


func (l *LocalCache) ReadSimulation(hoverfile Hoverfile) ([]byte, error) {
	hoverfileUri := buildAbsoluteFilePath(l.uri, hoverfile.GetFileName())

	if !fileIsPresent(hoverfileUri) {
		return nil, errors.New("Simulation not found")
	}

	return ioutil.ReadFile(hoverfileUri)
}

func createHomeDirectory() (string, error) {
	homeDirectory, _ := homedir.Dir()
	hoverflyDirectory := filepath.Join(homeDirectory, "/.hoverfly")


	if !fileIsPresent(hoverflyDirectory) {
		err := os.Mkdir(hoverflyDirectory, 0777)
		if err == nil {
			return hoverflyDirectory, err
		} else {
			return "", err
		}
	}

	return hoverflyDirectory, nil
}

func createCacheDirectory(baseUri string) (string, error) {
	cacheDirectory := filepath.Join(baseUri, "cache/")

	if _, err := os.Stat(cacheDirectory); err != nil {
		if os.IsNotExist(err) {
			os.Mkdir(cacheDirectory, 0777)
		} else {
			return "", err
		}
	}

	return cacheDirectory, nil
}

func fileIsPresent(fileUri string) bool {
	if _, err := os.Stat(fileUri); err != nil {
		return os.IsExist(err)
	}

	return true
}

func buildAbsoluteFilePath(baseUri string, fileName string) string {
	return filepath.Join(baseUri, fileName)
}
{'fraction_non_alphanumeric': 0.12572161642078256, 'fraction_numerical': 0.007697241821680564, 'mean_word_length': 4.8517823639774855, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3043917', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1082, 'n_words': 240}