58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Windows.Threading;
|
|
using Blake3;
|
|
using MediaDevices;
|
|
|
|
namespace ReSync
|
|
{
|
|
public static class FileManager
|
|
{
|
|
static bool cancel = false;
|
|
public static void ScanMTPDevice(MediaDevice device)
|
|
{
|
|
Debug.WriteLine("Starting MTP device scan...");
|
|
Debug.WriteLine(cancel);
|
|
device.Connect();
|
|
ListAllFiles(device, "//");
|
|
|
|
device.Disconnect();
|
|
}
|
|
|
|
static void ListAllFiles(MediaDevice device, string directory)
|
|
{
|
|
if (cancel) return;
|
|
// Get all subdirectories
|
|
var dirs = device.GetDirectories(directory);
|
|
var files = device.GetFiles(directory);
|
|
|
|
foreach (var file in files)
|
|
{
|
|
if (cancel) return;
|
|
Console.WriteLine(file);
|
|
}
|
|
|
|
// Recursively explore directories
|
|
foreach (var dir in dirs)
|
|
{
|
|
if (cancel) return;
|
|
ListAllFiles(device, dir);
|
|
}
|
|
}
|
|
|
|
public static string GetFileHash(string filePath)
|
|
{
|
|
return "a";
|
|
}
|
|
|
|
public static void CancelOperation()
|
|
{
|
|
cancel = true;
|
|
Dispatcher.CurrentDispatcher.InvokeAsync(async() =>
|
|
{
|
|
await Task.Delay(1000);
|
|
cancel = false;
|
|
});
|
|
}
|
|
}
|
|
} |