forked from kodlamaio-projects/nArchitecture.Gen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6f434d
commit 514b865
Showing
12 changed files
with
336 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,68 @@ | ||
using Core.CrossCuttingConcerns.Helpers; | ||
using System.Reflection; | ||
|
||
namespace Core.CodeGen.File; | ||
|
||
public static class DirectoryHelper | ||
{ | ||
public static string AssemblyDirectory | ||
{ | ||
get | ||
{ | ||
string codeBase = PlatformHelper.GetDirectoryHeader() + Assembly.GetExecutingAssembly().Location; | ||
UriBuilder uri = new(codeBase); | ||
string path = Uri.UnescapeDataString(uri.Path); | ||
return Path.GetDirectoryName(path)!; | ||
} | ||
} | ||
|
||
public static ICollection<string> GetFilesInDirectoryTree(string root, string searchPattern) | ||
{ | ||
List<string> files = new(); | ||
|
||
Stack<string> stack = new(); | ||
stack.Push(root); | ||
while (stack.Count > 0) | ||
{ | ||
string dir = stack.Pop(); | ||
files.AddRange(collection: Directory.GetFiles(dir, searchPattern)); | ||
|
||
foreach (string subDir in Directory.GetDirectories(dir)) | ||
stack.Push(subDir); | ||
} | ||
|
||
return files; | ||
} | ||
|
||
public static ICollection<string> GetDirsInDirectoryTree(string root, string searchPattern) | ||
{ | ||
List<string> dirs = new(); | ||
|
||
Stack<string> stack = new(); | ||
stack.Push(root); | ||
while (stack.Count > 0) | ||
{ | ||
string dir = stack.Pop(); | ||
dirs.AddRange(collection: Directory.GetDirectories(dir, searchPattern)); | ||
|
||
foreach (string subDir in Directory.GetDirectories(dir)) | ||
stack.Push(subDir); | ||
} | ||
|
||
return dirs; | ||
} | ||
|
||
public static void DeleteDirectory(string path) | ||
{ | ||
foreach (string subPath in Directory.EnumerateDirectories(path)) | ||
DeleteDirectory(subPath); | ||
|
||
foreach (string filePath in Directory.EnumerateFiles(path)) | ||
{ | ||
FileInfo file = new(filePath) { Attributes = FileAttributes.Normal }; | ||
file.Delete(); | ||
} | ||
Directory.Delete(path); | ||
} | ||
} | ||
using System.Reflection; | ||
|
||
namespace Core.CodeGen.File; | ||
|
||
public static class DirectoryHelper | ||
{ | ||
public static string AssemblyDirectory | ||
{ | ||
get | ||
{ | ||
string codeBase = | ||
PlatformHelper.GetDirectoryHeader() + Assembly.GetExecutingAssembly().Location; | ||
UriBuilder uri = new(codeBase); | ||
string path = Uri.UnescapeDataString(uri.Path); | ||
return Path.GetDirectoryName(path)!; | ||
} | ||
} | ||
|
||
public static ICollection<string> GetFilesInDirectoryTree(string root, string searchPattern) | ||
{ | ||
List<string> files = new(); | ||
|
||
Stack<string> stack = new(); | ||
stack.Push(root); | ||
while (stack.Count > 0) | ||
{ | ||
string dir = stack.Pop(); | ||
files.AddRange(collection: Directory.GetFiles(dir, searchPattern)); | ||
|
||
foreach (string subDir in Directory.GetDirectories(dir)) | ||
stack.Push(subDir); | ||
} | ||
|
||
return files; | ||
} | ||
|
||
public static ICollection<string> GetDirsInDirectoryTree(string root, string searchPattern) | ||
{ | ||
List<string> dirs = new(); | ||
|
||
Stack<string> stack = new(); | ||
stack.Push(root); | ||
while (stack.Count > 0) | ||
{ | ||
string dir = stack.Pop(); | ||
dirs.AddRange(collection: Directory.GetDirectories(dir, searchPattern)); | ||
|
||
foreach (string subDir in Directory.GetDirectories(dir)) | ||
stack.Push(subDir); | ||
} | ||
|
||
return dirs; | ||
} | ||
|
||
public static void DeleteDirectory(string path) | ||
{ | ||
foreach (string subPath in Directory.EnumerateDirectories(path)) | ||
DeleteDirectory(subPath); | ||
|
||
foreach (string filePath in Directory.EnumerateFiles(path)) | ||
{ | ||
FileInfo file = new(filePath) { Attributes = FileAttributes.Normal }; | ||
file.Delete(); | ||
} | ||
Directory.Delete(path); | ||
} | ||
} |
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
Oops, something went wrong.