<commit_before>/**
 * Copyright © 2014 <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 net.alphadev.ntfslib.structures.entries;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;

import net.alphadev.ntfslib.api.BlockDevice;
import net.alphadev.ntfslib.structures.Volume;
import net.alphadev.ntfslib.structures.attributes.Attribute;
import net.alphadev.ntfslib.structures.attributes.AttributeType;

public class FileRecord {
    public static final int FILE_SIGNATURE = 0x454c4946;
    public static final int BAAD_SIGNATURE = 0x44414142;

    private Map<AttributeType, ? extends Attribute> attributes;
    private Volume volume;
    private final long offset;
    private int length;
    private long attributeOffset;

    public FileRecord(Volume volume, long offset) throws IOException {
        this.volume = volume;
        this.offset = offset;

        length = volume.getParameter().getBytesPerMftRecord();

        System.out.println("offset " + offset);
        System.out.println("length " + length);

        this.attributes = new HashMap<>();
        ByteBuffer buffer = ByteBuffer.allocate(length);
        volume.read(offset, buffer);

        int magic = buffer.getInt(0);
        System.out.println("magic " + magic);
        if(magic != FILE_SIGNATURE) {
            throw new IllegalArgumentException("no magic signature found!");
        }

        this.attributeOffset = offset + 5;
    }

    public Attribute getAttribute(AttributeType attribute) {
        if(!attributes.containsKey(attribute)) {
            
        }

        return attributes.get(attribute);
    }
}
<commit_msg>parse attributes when navigating the mft entry.<commit_after>/**
 * Copyright © 2014 <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 net.alphadev.ntfslib.structures.entries;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.HashMap;
import java.util.Map;

import net.alphadev.ntfslib.api.BlockDevice;
import net.alphadev.ntfslib.structures.Volume;
import net.alphadev.ntfslib.structures.attributes.Attribute;
import net.alphadev.ntfslib.structures.attributes.AttributeType;
import net.alphadev.ntfslib.util.BitStitching;

public class FileRecord {
    public static final int FILE_SIGNATURE = 0x454c4946;
    public static final int BAAD_SIGNATURE = 0x44414142;

    private Map<AttributeType, ? extends Attribute> attributes;
    private Volume volume;
    private final long offset;
    private int length;

    public FileRecord(Volume volume, long offset) throws IOException {
        this.volume = volume;
        this.offset = offset;

        final int size = volume.getParameter().getBytesPerMftRecord();
        ByteBuffer buffer = ByteBuffer.allocate(size);
        buffer.order(ByteOrder.LITTLE_ENDIAN);
        volume.read(offset, buffer);
        buffer.rewind();

        int magic = buffer.getInt(0);
        if(magic != FILE_SIGNATURE) {
            throw new IllegalArgumentException("no magic signature found!");
        }

        this.attributes = new HashMap<>();

        long attributeOffset = offset + 5;
        while(attributeOffset != 0xff) {
            parseAttribute(attributeOffset);
        }
    }

    public int parseAttribute(long baseAddress) {
        Attribute attribute = new Attribute();
        attribute.setFixupOffset();
        this.attributes.add(attribute);
        return attribute.getLength();
    }

    public Attribute getAttribute(AttributeType attribute) {
        return attributes.get(attribute);
    }
}

{'fraction_non_alphanumeric': 0.08890807078118257, 'fraction_numerical': 0.011868795856711264, 'mean_word_length': 3.3036211699164344, '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': '4045630', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1224, 'n_words': 384}