<commit_before>package tcfs

import (
	"encoding/binary"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"os"
)

type TcfsConn struct {
	RootDir    string
	Conn       net.Conn
	Buf        []byte
	OpenedFile map[uintptr]*os.File

	Cipher *Cipher
}

func (c *TcfsConn) Read(b []byte) (int, error) {
	if c.Cipher == nil {
		return c.Conn.Read(b)
	}
	cipherData := make([]byte, len(b))
	n, err := c.Conn.Read(cipherData)
	if n > 0 {
		c.Cipher.Decrypt(b[0:n], cipherData[0:n])
	}
	return n, err
}

func (c *TcfsConn) Write(b []byte) (int, error) {
	if c.Cipher == nil {
		return c.Conn.Write(b)
	}
	cipherData := make([]byte, len(b))
	c.Cipher.Encrypt(cipherData, b)
	return c.Conn.Write(cipherData)
}

func (c *TcfsConn) Close() {
	c.Conn.Close()
}

const (
	GETATTR  uint32 = 0x01<commit_msg>update Conn.Read() Conn.Write()<commit_after>package tcfs

import (
	"encoding/binary"
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"net"
	"os"
)

type TcfsConn struct {
	RootDir    string
	Conn       net.Conn
	Buf        []byte
	OpenedFile map[uintptr]*os.File

	Cipher *Cipher
}

func (c *TcfsConn) Read(b []byte) (int, error) {
	if c.Cipher == nil {
		return c.Conn.Read(b)
	}
	n, err := c.Conn.Read(b)
	if n > 0 {
		c.Cipher.Decrypt(b[0:n], b[0:n])
	}
	return n, err
}

func (c *TcfsConn) Write(b []byte) (int, error) {
	if c.Cipher == nil {
		return c.Conn.Write(b)
	}
	c.Cipher.Encrypt(b, b)
	return c.Conn.Write(b)
}

func (c *TcfsConn) Close() {
	c.Conn.Close()
}

const (
	GETATTR  uint32 = 0x01
{'fraction_non_alphanumeric': 0.17479674796747968, 'fraction_numerical': 0.01084010840108401, 'mean_word_length': 3.2564841498559076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6040393', 'n_tokens_mistral': 707, 'n_tokens_neox': 678, 'n_words': 149}