Skip to content

Commit

Permalink
Added support for .vpkignore
Browse files Browse the repository at this point in the history
  • Loading branch information
taskinoz committed Dec 1, 2021
1 parent 0c733c0 commit 078e951
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion RSPNVPK/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ static void Main(string[] args)
$"VPK archive: {vpkarch}\n" +
$"Directory: {directory}");

// .vpkignore logic
var ignoreFileDir = $"{directory}.vpkignore";
string[] ignoreFiles = {};
if (System.IO.File.Exists(ignoreFileDir))
{
ignoreFiles = System.IO.File.ReadAllLines(ignoreFileDir);
// Remove ignore comments
ignoreFiles = ignoreFiles.Where(val => !val.Contains("#")).ToArray();
ignoreFiles = ignoreFiles.Concat(new string[] {".vpkignore"}).ToArray();
}

var filesList = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories).Select(path => path.Replace(directory, "").Replace(Path.DirectorySeparatorChar, '/')).ToList();
var filesEdit = new List<string>();
var filesDelete = new List<string>();
Expand All @@ -112,11 +123,25 @@ static void Main(string[] args)
}
else
{
filesEdit.Add(file);
// Check if file is in .vpkignore list
bool ignore = false;
foreach (var check in ignoreFiles) {
if (file.Contains(check))
{
ignore = true;
}
}
if (!ignore)
filesEdit.Add(file);
}
}
filesList = null; // Dispose ecksde

Console.ForegroundColor = ConsoleColor.Blue;
foreach (var edit in ignoreFiles)
{
Console.WriteLine($"\t[#]{(edit.EndsWith("/") ? edit+".." : edit)}");
}
Console.ForegroundColor = ConsoleColor.Green;
foreach (var edit in filesEdit)
{
Expand Down

0 comments on commit 078e951

Please sign in to comment.