diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index f208534..b3139fa 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -447,6 +447,13 @@ namespace GameLauncher
this.lblStatusEngine.Text = status;
});
},
+ onLogMessage: log =>
+ {
+ this.Dispatcher.Invoke(() =>
+ {
+ this.AppendLog(log);
+ });
+ },
ct: ct);
// キャッシュの最終同期(削除されたゲームのブックマークもここで除去する)
diff --git a/Services/GameScannerService.cs b/Services/GameScannerService.cs
index 0201f59..3ef1add 100644
--- a/Services/GameScannerService.cs
+++ b/Services/GameScannerService.cs
@@ -944,12 +944,15 @@ namespace GameLauncher.Services
///
/// 指定されたフォルダ一覧からツクール・ティラノ・Unityゲームを非同期で走査・検出します。
+ /// Everything IPC または NTFS MFT (USN Journal) 直接読み取りを利用して爆速インデックスを生成し、
+ /// インメモリプレフィルタによりディスクI/Oを極限まで抑えて高速検出します。
///
public async Task ScanDirectoriesAsync(
IEnumerable targetPaths,
IProgress progress,
HashSet existingPaths,
Action? onStatusUpdated = null,
+ Action? onLogMessage = null,
CancellationToken ct = default)
{
await Task.Run(() =>
@@ -960,6 +963,63 @@ namespace GameLauncher.Services
MaxDegreeOfParallelism = Math.Clamp(Environment.ProcessorCount * 2, 4, 16)
};
+ // 1. Everything / NTFS MFT による超高速スナップショット取得
+ FastDirectorySnapshot? snapshot = null;
+ string engineName = string.Empty;
+
+ if (EverythingSearchService.IsEverythingRunning())
+ {
+ onStatusUpdated?.Invoke("Everything IPCによる高速スキャンを実行中...");
+ try
+ {
+ snapshot = EverythingSearchService.TryScanTargetsFast(targetPaths);
+ if (snapshot != null && (snapshot.TotalDirectoryCount > 0 || snapshot.TotalFileCount > 0))
+ {
+ engineName = "Everything (IPC高速走査)";
+ }
+ else
+ {
+ snapshot = null;
+ }
+ }
+ catch
+ {
+ snapshot = null;
+ }
+ }
+
+ if (snapshot == null)
+ {
+ onStatusUpdated?.Invoke("NTFS MFT (USN Journal) による高速スキャンを実行中...");
+ try
+ {
+ snapshot = NtfsMftScanService.TryScanTargetsFast(targetPaths);
+ if (snapshot != null && (snapshot.TotalDirectoryCount > 0 || snapshot.TotalFileCount > 0))
+ {
+ engineName = "NTFS MFT直接読み取り (USN Journal高速走査)";
+ }
+ else
+ {
+ snapshot = null;
+ }
+ }
+ catch
+ {
+ snapshot = null;
+ }
+ }
+
+ if (snapshot != null)
+ {
+ onStatusUpdated?.Invoke($"高速インデックス取得完了 ({engineName}): {snapshot.TotalDirectoryCount} フォルダ / {snapshot.TotalFileCount} ファイル");
+ onLogMessage?.Invoke($"高速ファイルシステムインデックス [{engineName}] を取得しました({snapshot.TotalDirectoryCount} ディレクトリ, {snapshot.TotalFileCount} ファイル)。");
+ }
+ else
+ {
+ onStatusUpdated?.Invoke("通常ディレクトリ走査を実行中...");
+ onLogMessage?.Invoke("標準の並列ディレクトリ走査を実行します。");
+ }
+
foreach (var targetPath in targetPaths)
{
if (ct.IsCancellationRequested) break;
@@ -969,7 +1029,14 @@ namespace GameLauncher.Services
List subDirs;
try
{
- subDirs = [.. Directory.EnumerateDirectories(targetPath)];
+ if (snapshot != null && snapshot.DirectoryExists(targetPath))
+ {
+ subDirs = [.. snapshot.GetDirectories(targetPath)];
+ }
+ else
+ {
+ subDirs = [.. Directory.EnumerateDirectories(targetPath)];
+ }
}
catch
{
@@ -993,22 +1060,34 @@ namespace GameLauncher.Services
}
if (isExisting) return;
- // ディレクトリ直下のゲームを検出
- var game = this.DetectGameInDirectory(dir);
- if (game != null)
+ // スナップショットが存在する場合はインメモリプレフィルタでゲーム候補か判定
+ if (snapshot == null || HasPotentialGameContent(dir, snapshot))
{
- lock (existingPaths)
+ var game = this.DetectGameInDirectory(dir);
+ if (game != null)
{
- existingPaths.Add(dir);
+ lock (existingPaths)
+ {
+ existingPaths.Add(dir);
+ }
+ progress.Report(game);
+ return;
}
- progress.Report(game);
- return;
}
// 1階層下も探索(アーカイブ解凍等でサブフォルダが入っているケース)
try
{
- var childDirs = Directory.EnumerateDirectories(dir);
+ IEnumerable childDirs;
+ if (snapshot != null && snapshot.DirectoryExists(dir))
+ {
+ childDirs = snapshot.GetDirectories(dir);
+ }
+ else
+ {
+ childDirs = Directory.EnumerateDirectories(dir);
+ }
+
foreach (var childDir in childDirs)
{
if (ct.IsCancellationRequested) break;
@@ -1020,14 +1099,17 @@ namespace GameLauncher.Services
}
if (isChildExisting) continue;
- var childGame = this.DetectGameInDirectory(childDir);
- if (childGame != null)
+ if (snapshot == null || HasPotentialGameContent(childDir, snapshot))
{
- lock (existingPaths)
+ var childGame = this.DetectGameInDirectory(childDir);
+ if (childGame != null)
{
- existingPaths.Add(childDir);
+ lock (existingPaths)
+ {
+ existingPaths.Add(childDir);
+ }
+ progress.Report(childGame);
}
- progress.Report(childGame);
}
}
}
@@ -1042,6 +1124,55 @@ namespace GameLauncher.Services
}, ct);
}
+ ///
+ /// スナップショットのメモリ情報を用いて、対象フォルダがゲームファイルを含む可能性があるか高速判定します。
+ ///
+ private static bool HasPotentialGameContent(string dirPath, FastDirectorySnapshot snapshot)
+ {
+ var normalized = dirPath.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+
+ // 1. 直下のファイル群をメモリ上でチェック
+ if (snapshot.FilesByDir.TryGetValue(normalized, out var files))
+ {
+ foreach (var f in files)
+ {
+ if (f.EndsWith(".exe", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".wolf", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".rgss3a", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".rgss2a", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".rgssad", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".html", StringComparison.OrdinalIgnoreCase) ||
+ f.EndsWith(".htm", StringComparison.OrdinalIgnoreCase) ||
+ f.Equals("package.json", StringComparison.OrdinalIgnoreCase) ||
+ f.Equals("Game.ini", StringComparison.OrdinalIgnoreCase) ||
+ f.Equals("UnityPlayer.dll", StringComparison.OrdinalIgnoreCase) ||
+ f.Equals("data.xp3", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+ }
+
+ // 2. 直下のサブディレクトリ名をメモリ上でチェック
+ if (snapshot.SubDirsByDir.TryGetValue(normalized, out var subDirs))
+ {
+ foreach (var sub in subDirs)
+ {
+ var name = Path.GetFileName(sub);
+ if (name.Equals("data", StringComparison.OrdinalIgnoreCase) ||
+ name.Equals("tyrano", StringComparison.OrdinalIgnoreCase) ||
+ name.Equals("www", StringComparison.OrdinalIgnoreCase) ||
+ name.EndsWith("_Data", StringComparison.OrdinalIgnoreCase) ||
+ name.Equals("BasicData", StringComparison.OrdinalIgnoreCase) ||
+ name.Equals("System", StringComparison.OrdinalIgnoreCase))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
///
/// 1つのディレクトリ内にツクール・ティラノまたはUnityゲームが存在するか判定し、対応するアイテムを生成します。
///