add dscanner fix command

This commit is contained in:
WebFreak001 2023-07-07 17:42:28 +02:00 committed by Jan Jurzitza
parent 48cec8a6f4
commit 4194e6af0c
8 changed files with 371 additions and 60 deletions

View file

@ -80,6 +80,19 @@ ubyte[] readFile(string fileName)
return sourceCode;
}
void writeFileSafe(string filename, scope const(ubyte)[] content)
{
import std.file : copy, PreserveAttributes, remove, write;
import std.path : baseName, buildPath, dirName;
string tempName = buildPath(filename.dirName, "." ~ filename.baseName ~ "~");
// FIXME: we are removing the optional BOM here
copy(filename, tempName, PreserveAttributes.yes);
write(filename, content);
remove(tempName);
}
string[] expandArgs(string[] args)
{
import std.file : isFile, FileException, dirEntries, SpanMode;