<commit_before>// Copyright 2012 <NAME>. All Rights Reserved.
// Author: <EMAIL> (<NAME>)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package repr contains functions useful for serializing and deserializing
// directory listing structs.
package repr

import (
	"code.google.com/p/goprotobuf/proto"
	"fmt"
	"github.com/jacobsa/comeback/fs"
)

func convertType(t fs.EntryType) DirectoryEntryProto_Type {
	switch t {
	case fs.TypeFile:
		return DirectoryEntryProto_TYPE_FILE
	case fs.TypeDirectory:
		return DirectoryEntryProto_TYPE_DIRECTORY
	case fs.TypeSymlink:
		return DirectoryEntryProto_TYPE_SYMLINK
	}

	panic(fmt.Sprintf("Unrecognized EntryType: %v", t))
}

func makeEntryProto(entry fs.DirectoryEntry) *DirectoryEntryProto {
	blobs := []*BlobInfoProto{}
	for _, score := range entry.Scores {
		proto := &BlobInfoProto{Hash: score.Sha1Hash()}
		blobs = append(blobs, proto)
	}

	return &DirectoryEntryProto{
		Type:        convertType(entry.Type).Enum(),
		Permissions: proto.Uint32(entry.Permissions),
		Name:        entry.Name,
		Mtime: &TimeProto{
			Second:     proto.Int64(entry.MTime.Unix()),
			Nanosecond: proto.Uint32(uint32(entry.MTime.Nanosecond())),
		},
		Blob: blobs,
	}
}

// Marshal turns a list of directory entries into bytes that can later be used
// with Unmarshal.
func Marshal(entries []fs.DirectoryEntry) (d []byte, err error) {
	return "TODO", nil
}

// Unmarshal recovers a list of directory entries from bytes previously
// returned by Marshal.
func Unmarshal(d []byte) (entries []fs.DirectoryEntry, err error) {
	return nil, fmt.Errorf("TODO")
}<commit_msg>Fixed build errors.<commit_after>// Copyright 2012 <NAME>. All Rights Reserved.
// Author: <EMAIL> (<NAME>)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Package repr contains functions useful for serializing and deserializing
// directory listing structs.
package repr

import (
	"code.google.com/p/goprotobuf/proto"
	"fmt"
	"github.com/jacobsa/comeback/fs"
)

func convertType(t fs.EntryType) DirectoryEntryProto_Type {
	switch t {
	case fs.TypeFile:
		return DirectoryEntryProto_TYPE_FILE
	case fs.TypeDirectory:
		return DirectoryEntryProto_TYPE_DIRECTORY
	case fs.TypeSymlink:
		return DirectoryEntryProto_TYPE_SYMLINK
	}

	panic(fmt.Sprintf("Unrecognized EntryType: %v", t))
}

func makeEntryProto(entry fs.DirectoryEntry) *DirectoryEntryProto {
	blobs := []*BlobInfoProto{}
	for _, score := range entry.Scores {
		proto := &BlobInfoProto{Hash: score.Sha1Hash()}
		blobs = append(blobs, proto)
	}

	return &DirectoryEntryProto{
		Type:        convertType(entry.Type).Enum(),
		Permissions: proto.Uint32(entry.Permissions),
		Name:        entry.Name,
		Mtime: &TimeProto{
			Second:     proto.Int64(entry.MTime.Unix()),
			Nanosecond: proto.Uint32(uint32(entry.MTime.Nanosecond())),
		},
		Blob: blobs,
	}
}

// Marshal turns a list of directory entries into bytes that can later be used
// with Unmarshal.
func Marshal(entries []fs.DirectoryEntry) (d []byte, err error) {
	return nil, fmt.Errorf("TODO")
}

// Unmarshal recovers a list of directory entries from bytes previously
// returned by Marshal.
func Unmarshal(d []byte) (entries []fs.DirectoryEntry, err error) {
	return nil, fmt.Errorf("TODO")
}
{'fraction_non_alphanumeric': 0.11100614076523382, 'fraction_numerical': 0.00803023145961266, 'mean_word_length': 4.133333333333334, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6761016', 'n_tokens_mistral': 1347, 'n_tokens_neox': 1261, 'n_words': 420}