-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
option and cli parameter to preserve custom images
summary includes firmware version uppdaed project version
- Loading branch information
1 parent
e326542
commit 8d96766
Showing
5 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace pannella.analoguepocket; | ||
|
||
public class Util | ||
{ | ||
private static string _imagesDirectory = Path.Combine("Platforms", "_images"); | ||
private static string _temp = "imagesbackup"; | ||
public static bool BackupImagesDirectory(string rootPath) | ||
{ | ||
string fullPath = Path.Combine(rootPath, _imagesDirectory); | ||
if(!Directory.Exists(fullPath)) { | ||
return false; | ||
} | ||
|
||
string tempPath = Path.Combine(rootPath, _temp); | ||
try { | ||
Directory.CreateDirectory(tempPath); | ||
CopyDirectory(fullPath, tempPath, false, true); | ||
} catch (Exception) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public static bool RestoreImagesDirectory(string rootPath) | ||
{ | ||
string fullPath = Path.Combine(rootPath, _imagesDirectory); | ||
if(!Directory.Exists(fullPath)) { | ||
return false; | ||
} | ||
string tempPath = Path.Combine(rootPath, _temp); | ||
if(!Directory.Exists(tempPath)) { | ||
return false; | ||
} | ||
CopyDirectory(tempPath, fullPath, false, true); | ||
Directory.Delete(tempPath, true); | ||
|
||
return true; | ||
} | ||
|
||
static void CopyDirectory(string sourceDir, string destinationDir, bool recursive, bool overwrite) | ||
{ | ||
// Get information about the source directory | ||
var dir = new DirectoryInfo(sourceDir); | ||
|
||
// Check if the source directory exists | ||
if (!dir.Exists) | ||
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); | ||
|
||
// Cache directories before we start copying | ||
DirectoryInfo[] dirs = dir.GetDirectories(); | ||
|
||
// Create the destination directory | ||
Directory.CreateDirectory(destinationDir); | ||
|
||
// Get the files in the source directory and copy to the destination directory | ||
foreach (FileInfo file in dir.GetFiles()) | ||
{ | ||
string targetFilePath = Path.Combine(destinationDir, file.Name); | ||
file.CopyTo(targetFilePath, overwrite); | ||
} | ||
|
||
// If recursive and copying subdirectories, recursively call this method | ||
if (recursive) | ||
{ | ||
foreach (DirectoryInfo subDir in dirs) | ||
{ | ||
string newDestinationDir = Path.Combine(destinationDir, subDir.Name); | ||
CopyDirectory(subDir.FullName, newDestinationDir, true, overwrite); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters