package dev.photosync.core.capture;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Instant;

/**
 * A screenshot that has just landed in the screenshots folder.
 *
 * <p>Produced by the platform layer -- which is the only part that knows how
 * Minecraft writes the file -- and consumed by the upload queue.
 */
public record CapturedScreenshot(Path file, String fileName, Instant capturedAt, CaptureOrigin origin, long sizeBytes) {

    public static CapturedScreenshot of(Path file, CaptureOrigin origin) throws IOException {
        return new CapturedScreenshot(
                file.toAbsolutePath(),
                file.getFileName().toString(),
                Files.getLastModifiedTime(file).toInstant(),
                origin,
                Files.size(file));
    }
}
