<commit_before>package nodos

import (
	"fmt"
	"os"
	"path/filepath"
	"regexp"
	"unicode/utf8"
)

func chDriveRune(n rune) error {
	lastDir, lastDirErr := os.Getwd()

	newDir := os.Getenv(fmt.Sprintf("=%c:", n))
	if newDir == "" {
		newDir = fmt.Sprintf("%c:%c", n, os.PathSeparator)
	}
	err := os.Chdir(newDir)
	if err == nil {
		if lastDirErr == nil {
			os.Setenv("="+filepath.VolumeName(lastDir), lastDir)
		}
	} else {
		err = os.Chdir(fmt.Sprintf("%c:%c", n, os.PathSeparator))
	}
	return err
}

// Chdrive changes drive without changing the working directory there.
func Chdrive(drive string) error {
	c, _ := utf8.DecodeRuneInString(drive)
	return chDriveRune(c)
}

var rxPath = regexp.MustCompile("^([a-zA-Z]):(.*)$")

// Chdir changes the current working directory
// without changeing the working directory
// in the last drive.
func Chdir(folder string) error {
	if m := rxPath.FindStringSubmatch(folder); m != nil {
		err := chDriveRune(rune(m[1][0]))
		if err != nil {
			return err
		}
		folder = m[2]
		if len(folder) <= 0 {
			return nil
		}
	}
	err := os.Chdir(folder)
	if err == nil {
		if absFolder, err := filepath.Abs(folder); err == nil {<commit_msg>Fix: the current-dir per each drive was mistaken after `cd RELATIVE-PATH`<commit_after>package nodos

import (
	"fmt"
	"os"
	"path/filepath"
	"regexp"
	"unicode/utf8"
)

func chDriveRune(n rune) error {
	lastDir, lastDirErr := os.Getwd()

	newDir := os.Getenv(fmt.Sprintf("=%c:", n))
	if newDir == "" {
		newDir = fmt.Sprintf("%c:%c", n, os.PathSeparator)
	}
	err := os.Chdir(newDir)
	if err == nil {
		if lastDirErr == nil {
			os.Setenv("="+filepath.VolumeName(lastDir), lastDir)
		}
	} else {
		err = os.Chdir(fmt.Sprintf("%c:%c", n, os.PathSeparator))
	}
	return err
}

// Chdrive changes drive without changing the working directory there.
func Chdrive(drive string) error {
	c, _ := utf8.DecodeRuneInString(drive)
	return chDriveRune(c)
}

var rxPath = regexp.MustCompile("^([a-zA-Z]):(.*)$")

// Chdir changes the current working directory
// without changeing the working directory
// in the last drive.
func Chdir(folder string) error {
	if m := rxPath.FindStringSubmatch(folder); m != nil {
		err := chDriveRune(rune(m[1][0]))
		if err != nil {
			return err
		}
		folder = m[2]
		if len(folder) <= 0 {
			return nil
		}
	}
	absFolder, absErr := filepath.Abs(folder)
	err := os.Chdir(folder)
	if err == nil {
		if absErr == nil {
{'fraction_non_alphanumeric': 0.16334991708126037, 'fraction_numerical': 0.004975124378109453, 'mean_word_length': 3.768774703557312, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5961286', 'n_tokens_mistral': 965, 'n_tokens_neox': 917, 'n_words': 230}