<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 fs

import (
	"github.com/jacobsa/comeback/blob"
	"github.com/jacobsa/comeback/sys"
	"os"
	"time"
)

type EntryType uint32

const (
	TypeFile EntryType = iota
	TypeDirectory
	TypeSymlink
	TypeBlockDevice
	TypeCharDevice
	TypeNamedPipe
)

// DirectoryEntry gives enough information to reconstruct a single entry within
// a backed up directory.
type DirectoryEntry struct {
	Type EntryType

	// The name of this entry within its directory.
	Name string

	// The permissions for this entry, including the {setuid,setgid,sticky} bits.
	// That is, the things that chmod(2) cares about. This does *not* include
	// type information such as os.ModeDevice or options such as os.ModeAppend.
	Permissions os.FileMode

	// The owning user's UID, and their username if known.
	Uid      sys.UserId
	Username *string

	// The owning group's GID, and its groupname if known.
	Gid       sys.GroupId
	Groupname *string

	// The modification time of this entry.
	MTime time.Time

	// The containing device's device number, and the inode on the device. These
	// are defined only for regular files.
	ContainingDevice int32
	Inode            uint64

	// The scores of zero or more blobs that make up a regular file's contents,
	// to be concatenated in order. For directories, this is exactly one blob
	// whose contents can be processed using repr.Unmarshal.
	//
	// Scores are present only if HardLinkTarget is not present.
	Scores []blob.Score

	// If this regular file belongs to a backup containing another regular file
	// to which it is hard linked, this is the target of the hard link relative
	// to the root of the backup.
	HardLinkTarget *string

	// The target, if this is a symlink.<commit_msg>Added a Size field.<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 fs

import (
	"github.com/jacobsa/comeback/blob"
	"github.com/jacobsa/comeback/sys"
	"os"
	"time"
)

type EntryType uint32

const (
	TypeFile EntryType = iota
	TypeDirectory
	TypeSymlink
	TypeBlockDevice
	TypeCharDevice
	TypeNamedPipe
)

// DirectoryEntry gives enough information to reconstruct a single entry within
// a backed up directory.
type DirectoryEntry struct {
	Type EntryType

	// The name of this entry within its directory.
	Name string

	// The permissions for this entry, including the {setuid,setgid,sticky} bits.
	// That is, the things that chmod(2) cares about. This does *not* include
	// type information such as os.ModeDevice or options such as os.ModeAppend.
	Permissions os.FileMode

	// The owning user's UID, and their username if known.
	Uid      sys.UserId
	Username *string

	// The owning group's GID, and its groupname if known.
	Gid       sys.GroupId
	Groupname *string

	// The modification time of this entry.
	MTime time.Time

	// The size of regular files. Undefined for other types.
	Size uint64

	// The containing device's device number, and the inode on the device. These
	// are defined only for regular files.
	ContainingDevice int32
	Inode            uint64

	// The scores of zero or more blobs that make up a regular file's contents,
	// to be concatenated in order. For directories, this is exactly one blob
	// whose contents can be processed using repr.Unmarshal.
	//
	// Scores are present only if HardLinkTarget is not present.
	Scores []blob.Score

	// If this regular file belongs to a backup containing another regular file
	// to which it is hard linked, this is the target of the hard link relative
	// to the root of the backup.
	HardLinkTarget *string

	// The target, if this is a symlink.
{'fraction_non_alphanumeric': 0.07526205450733753, 'fraction_numerical': 0.0067085953878406705, 'mean_word_length': 3.305956678700361, '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': '1395446', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1312, 'n_words': 635}