Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
39
Task/Unix-ls/Delphi/unix-ls.delphi
Normal file
39
Task/Unix-ls/Delphi/unix-ls.delphi
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
program LsCommand;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
|
||||
|
||||
uses
|
||||
System.SysUtils,
|
||||
System.IoUtils;
|
||||
|
||||
procedure Ls(folder: string = '.');
|
||||
var
|
||||
offset: Integer;
|
||||
fileName: string;
|
||||
|
||||
// simulate unix results in windows
|
||||
|
||||
function ToUnix(path: string): string;
|
||||
begin
|
||||
Result := path.Replace('/', PathDelim, [rfReplaceAll])
|
||||
end;
|
||||
|
||||
begin
|
||||
folder := IncludeTrailingPathDelimiter(ToUnix(folder));
|
||||
offset := length(folder);
|
||||
|
||||
for fileName in TDirectory.GetFileSystemEntries(folder, '*') do
|
||||
writeln(^I, ToUnix(fileName).Substring(offset));
|
||||
end;
|
||||
|
||||
begin
|
||||
writeln('cd foo'#10'ls');
|
||||
ls('foo');
|
||||
|
||||
writeln(#10'cd bar'#10'ls');
|
||||
ls('foo/bar');
|
||||
|
||||
{$IFNDEF LINUX} readln; {$ENDIF}
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue