< Summary

Information
Class: Anichron.Worker.Ingestion.Extraction.AppleCreationDates
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Extraction/AppleCreationDates.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 48
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Read(...)100%11100%
Into(...)100%22100%
DataValue(...)100%11100%
Utf8(...)100%11100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Extraction/AppleCreationDates.cs

#LineLine coverage
 1using MetadataExtractor.Formats.QuickTime;
 2using System.Text;
 3
 4namespace Anichron.Worker.Ingestion.Extraction;
 5
 6/// <summary>Reads the raw value of <c>com.apple.quicktime.creationdate</c> from <c>moov</c> → <c>meta</c>, with its off
 7internal static class AppleCreationDates
 8{
 9    private const string creationDateKey = "com.apple.quicktime.creationdate";
 10
 11    /// <summary>The raw creation date, or null when the file records none or its atoms end early.</summary>
 12    /// <param name="stream">The file, positioned at its start.</param>
 13    public static string? Read(Stream stream)
 1514    {
 1515        var keys = new List<string>();
 1516        string? value = null;
 1517        QuickTimeReader.ProcessAtoms(stream, top => Into(top, "moov", moov => Into(moov, "meta", meta =>
 1518        {
 1519            if (meta.TypeString == "keys")
 1520            {
 1521                meta.Reader.Skip(8);
 1522                QuickTimeReader.ProcessAtoms(stream, key => keys.Add(Utf8(key)), meta.BytesLeft);
 1523            }
 1524
 1525            var index = keys.IndexOf(creationDateKey) + 1;
 1526            Into(meta, "ilst", item =>
 1527            {
 1528                if (item.Type == index)
 1529                    QuickTimeReader.ProcessAtoms(stream, data => value = data.TypeString == "data" ? DataValue(data) : v
 1530            });
 1531        })));
 1432        return value;
 1433    }
 34
 35    private static void Into(AtomCallbackArgs atom, string type, Action<AtomCallbackArgs> children)
 91136    {
 91137        if (atom.TypeString == type)
 2938            QuickTimeReader.ProcessAtoms(atom.Stream, children, atom.BytesLeft);
 90839    }
 40
 41    private static string DataValue(AtomCallbackArgs data)
 642    {
 643        data.Reader.Skip(8);
 644        return Utf8(data);
 445    }
 46
 1847    private static string Utf8(AtomCallbackArgs atom) => Encoding.UTF8.GetString(atom.Reader.GetBytes((int)atom.BytesLef
 48}