initial basic qdls implementation

This commit is contained in:
Valerie Wolfe 2024-06-05 10:19:21 -04:00
parent d5e81e285f
commit cb59ed771a
3 changed files with 56 additions and 0 deletions

4
qdls/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
obj/
bin/
.idea/

42
qdls/Program.cs Normal file
View file

@ -0,0 +1,42 @@
using System.IO;
string[] arguments;
if(args.Length == 0)
arguments = ["."];
else
arguments = args;
foreach(var arg in arguments) {
if(!Path.Exists(arg))
Console.WriteLine($"'{arg}: does not exist");
if(File.Exists(arg))
Console.WriteLine($"'{arg}: is file");
var children = Directory.GetFileSystemEntries(arg);
var line = "";
var longest = children.OrderByDescending(s => Path.GetFileName(s).Length).First().Length;
var columns = Console.WindowWidth / (longest + 2);
var position = -1;
if(args.Length > 1)
Console.WriteLine($"{arg}:");
foreach(var child in children) {
var name = Path.GetFileName(child);
if(
name.StartsWith('.') ||
( File.GetAttributes(child) & FileAttributes.Hidden ) == FileAttributes.Hidden
)
continue;
if(++position >= columns) {
position = -1;
Console.WriteLine(line);
line = "";
}
line += name + " ";
}
Console.WriteLine(line);
}

10
qdls/qdls.csproj Normal file
View file

@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>