Skip to content

Commit

Permalink
Merge pull request #142 from SnaffCon/fixes
Browse files Browse the repository at this point in the history
Fixes for a couple of long-outstanding issues
  • Loading branch information
l0ss authored Apr 15, 2024
2 parents 97e0513 + 3cd1011 commit ae01ab9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
3 changes: 3 additions & 0 deletions SnaffCore/Classifiers/FileResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ public void SnaffleFile(FileInfo fileInfo, string snafflePath)
string sourcePath = fileInfo.FullName;
// clean it up and normalise it a bit
string cleanedPath = sourcePath.Replace(':', '.').Replace('$', '.').Replace("\\\\", "\\");
cleanedPath = cleanedPath.TrimStart('\\');
//string cleanedPath = Path.GetFullPath(sourcePath.Replace(':', '.').Replace('$', '.'));

// make the dir exist
string snaffleFilePath = Path.Combine(snafflePath, cleanedPath);

string snaffleDirPath = Path.GetDirectoryName(snaffleFilePath);
Directory.CreateDirectory(snaffleDirPath);
File.Copy(sourcePath, (Path.Combine(snafflePath, cleanedPath)), true);
Expand Down
18 changes: 16 additions & 2 deletions Snaffler/SnaffleRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,28 @@ public void Run(string[] args)
}
}
};
nlogConfig.AddRule(LogLevel, LogLevel.Fatal, logconsole);
if (LogLevel == LogLevel.Warn)
{
nlogConfig.AddRule(LogLevel.Warn, LogLevel.Warn, logconsole);
}
else
{
nlogConfig.AddRule(LogLevel, LogLevel.Fatal, logconsole);
}
logconsole.Layout = "${message}";
}

if (Options.LogToFile)
{
logfile = new FileTarget("logfile") { FileName = Options.LogFilePath };
nlogConfig.AddRule(LogLevel, LogLevel.Fatal, logfile);
if (LogLevel == LogLevel.Warn)
{
nlogConfig.AddRule(LogLevel.Warn, LogLevel.Warn, logfile);
}
else
{
nlogConfig.AddRule(LogLevel, LogLevel.Fatal, logfile);
}
if (Options.LogType == LogType.Plain)
{
logfile.Layout = "${message}";
Expand Down
6 changes: 2 additions & 4 deletions Snaffler/Snaffler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@
<Version>4.7.15</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Folder Include="SnaffRules\DefaultRules\PostMatchRules\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>

0 comments on commit ae01ab9

Please sign in to comment.