Files
firmware-flasher/FirmwareFlasher/Services/FirmwareCatalog.cs
insulee 196b00b91e refactor: 프로젝트명 DB720Flasher → FirmwareFlasher
폴더·csproj·어셈블리명·RootNamespace·코드 namespace·x:Class·app.manifest 전부 변경.
빌드 결과가 네이티브로 FirmwareFlasher.exe 로 나온다(dist 수동 리네임 불필요).
README 빌드/구조 경로도 갱신. 모델명 "DB720"은 그대로 유지.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 16:37:48 +09:00

70 lines
2.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.IO;
namespace FirmwareFlasher;
public static class FirmwareCatalog
{
// 모델 무관하게 보조 파일명은 공통 — 앱 후보 = 이 4개를 뺀 .bin
static readonly HashSet<string> Support = new(StringComparer.OrdinalIgnoreCase)
{ "bootloader.bin", "partition-table.bin", "ota_data_initial.bin", "www_fs.bin" };
static string? KnownNote(string fileName) => fileName switch
{
"DIBD720Te_08C_04R020C.bin" => "320×64 (4단20열, 8색) · 부팅 검증됨",
"DIBD720Ue_08B_08R040C.bin" => "640×128 (8단40열, 256색) · 미검증",
_ => null,
};
/// <summary>폴더의 앱 후보(.bin 중 보조 4종 제외)를 나열.</summary>
public static List<FirmwareItem> LoadApps(string folder)
{
var apps = new List<FirmwareItem>();
if (!Directory.Exists(folder)) return apps;
foreach (var path in Directory.EnumerateFiles(folder, "*.bin"))
{
var name = Path.GetFileName(path);
if (Support.Contains(name)) continue;
apps.Add(new FirmwareItem
{
FileName = name,
FullPath = path,
Size = SafeLen(path),
Note = KnownNote(name),
});
}
apps.Sort((a, b) => string.Compare(a.FileName, b.FileName, StringComparison.OrdinalIgnoreCase));
return apps;
}
/// <summary>선택한 모드+프로파일에 필요한 보조 파일이 폴더에 다 있는지. 없으면 빠진 목록.</summary>
public static string? MissingFor(string folder, FlashProfile p, FlashMode mode)
{
if (mode == FlashMode.AppOnly) return null;
bool includeBoot = mode == FlashMode.Full;
var miss = new List<string>();
foreach (var rg in p.SupportRegions)
{
if (rg.Kind == "bootloader" && !includeBoot) continue;
if (!File.Exists(Path.Combine(folder, rg.File!))) miss.Add(rg.File!);
}
return miss.Count == 0 ? null : string.Join(", ", miss);
}
/// <summary>exe 위치에서 위로 올라가며 firmware\ (bin 포함) 폴더를 찾는다.</summary>
public static string? AutoLocate(string startDir)
{
var dir = new DirectoryInfo(startDir);
for (int i = 0; i < 6 && dir is not null; i++)
{
var candidate = Path.Combine(dir.FullName, "firmware");
if (Directory.Exists(candidate) && Directory.EnumerateFiles(candidate, "*.bin").Any())
return candidate;
dir = dir.Parent;
}
return null;
}
static long SafeLen(string p) { try { return new FileInfo(p).Length; } catch { return 0; } }
}