Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,2 @@
---
from: http://rosettacode.org/wiki/Unix/ls

33
Task/Unix-ls/00-TASK.txt Normal file
View file

@ -0,0 +1,33 @@
;Task:
Write a program that will list everything in the current folder,   similar to:
:::* &nbsp; the Unix utility &nbsp; “<tt>ls</tt>” &nbsp; [http://man7.org/linux/man-pages/man1/ls.1.html] &nbsp; &nbsp; &nbsp; or
:::* &nbsp; the Windows terminal command &nbsp; “<tt>DIR</tt>”
<br>
The output must be sorted, but printing extended details and producing multi-column output is not required.
;Example output
For the list of paths:
<pre>
/foo/bar
/foo/bar/1
/foo/bar/2
/foo/bar/a
/foo/bar/b
</pre>
When the program is executed in &nbsp; `/foo`, &nbsp; it should print:
<pre>
bar
</pre>
and when the program is executed in &nbsp; `/foo/bar`, &nbsp; it should print:
<pre>
1
2
a
b
</pre>
<br><br>

View file

@ -0,0 +1 @@
print(sorted(fs:list_dir(.)).join("\n"))

View file

@ -0,0 +1,133 @@
dma: equ 80h
puts: equ 9h ; Write string to console
sfirst: equ 11h ; Find first matching file
snext: equ 12h ; Get next matching file
org 100h
;;; First, retrieve all filenames in current directory
;;; CP/M has function 11h (sfirst) and function 13h (snext)
;;; to return the first, and then following, files that
;;; match a wildcard.
lxi d,0 ; Amount of files
push d ; Push on stack
lxi h,fnames ; Start of area to save names
push h ; Push on stack
lxi d,fcb ; FCB that will match any file
mvi c,sfirst ; Get the first file
getnames: call 5 ; Call CP/M BDOS
inr a
jz namesdone ; FF = we have all files
dcr a ; Dir entry is at DMA+32*A
rrc ; Rotate 3 right, same as
rrc ; rotate 5 left, *32
rrc
adi dma+1 ; Add DMA offset + 1 (filename offset)
mov e,a ; Low byte of address
mvi d,0 ; High byte is 0
mvi b,8 ; Filename is 8 bytes
pop h ; Get pointer to name area
call memcpy ; Copy the name
mvi m,' ' ; Separate name and extension
inx h
mvi b,3 ; Extension is 3 bytes
call memcpy ; Copy the extension
mvi m,13 ; While we're at it, terminate
inx h ; the filename with \r\n
mvi m,10
inx h
pop d ; Get amount of files
inx d ; Increment it (we've added a file)
push d ; Put it back onto the stack
push h ; Put the name pointer on the stack too
mvi c,snext ; Go get the next file
jmp getnames
namesdone: pop h ; Terminate the file list with $
mvi m,'$' ; so it can be printed with function 9
;;; CP/M does not keep its directory in sorted order,
;;; so we need to sort the list of files ourselves.
;;; What follows is a simple insertion sort.
lxi d,1 ; DE (i) = 1
sortouter: pop h ; Get amount of files
push h
call cmpdehl ; i < length(files)?
jnc sortdone ; If not, we're done
push d ; push i; DE (j) = i
sortinner: push d ; push j
mov a,d ; j > 0?
ora e
jz sortinnerdone ; If not, inner loop is done
dcx d ; DE = j-1
call lookup ; HL = files[j-1]
push h ; push files[j-1]
inx d ; DE = j
call lookup ; HL = files[j]
pop d ; pop DE = files[j-1]
push d ; keep them across comparison
push h
call cmpentries ; A[j] >= A[j-1]?
pop h
pop d
jc sortinnerdone ; Then inner loop is done.
mvi b,12 ; Otherwise we should swap them
swaploop: ldax d ; Get byte from files[j-1]
mov c,m ; Get byte from files[j]
mov m,a ; files[j][x]=files[j-1][x]
mov a,c ; files[j-1][x]=files[j]-[x]
stax d
inx h ; Increment pointers
inx d
dcr b ; all 12 bytes done yet?
jnz swaploop ; if not, swap next byte
pop d ; DE = j
dcx d ; j = j-1
jmp sortinner
sortinnerdone: pop d ; pop j
pop d ; pop i
inx d ; i = i + 1
jmp sortouter
sortdone: pop h ; Remove file count from stack
;;; We're done sorting the list, print it.
lxi d,fnames ; Print the now sorted list of files
mvi c,puts
jmp 5
;;; Subroutine: compare entries under DE and HL
cmpentries: mvi b,12 ; Each entry has 12 relevant bytes.
cmploop: ldax d ; Get byte from entry DE
cmp m ; Compare with byte from entry HL
rnz ; If they differ, we know the ordering
inx h ; Increment both pointers
inx d
dcr b ; Decrement byte counter
jnz cmploop ; Compare next byte
ret
;;; Subroutine: look up filename entry (HL=DE*14+fnames)
lookup: push d ; Save entry number
mov h,d
mov l,e
dad h ; HL = HL' * 2
dad d ; HL = HL' * 3
dad h ; HL = HL' * 6
dad d ; HL = HL' * 7
dad h ; HL = HL' * 14
lxi d,fnames ; Offset
dad d ; Add the offset
pop d ; Restore entry number
ret
;;; Subroutine: compare DE and HL
cmpdehl: mov a,d
cmp h
rnz
mov a,e
cmp l
ret
;;; Subroutine: copy B bytes from DE to HL
memcpy: ldax d ; Get byte from source
mov m,a ; Store byte at destination
inx h ; Increment both pointers
inx d
dcr b ; Done yet?
jnz memcpy ; If not, copy next byte
ret
;;; File control block used to specify wildcard
fcb: db 0,'???????????' ; Accept any file
ds fcb+36-$ ; Pad the FCB out to 36 bytes
fnames:

View file

@ -0,0 +1,3 @@
"*" f:glob
' s:cmp a:sort
"\n" a:join .

View file

@ -0,0 +1,8 @@
# syntax: GAWK -f UNIX_LS.AWK * | SORT
BEGINFILE {
printf("%s\n",FILENAME)
nextfile
}
END {
exit(0)
}

View file

@ -0,0 +1,32 @@
with Ada.Text_IO, Ada.Directories, Ada.Containers.Indefinite_Vectors;
procedure Directory_List is
use Ada.Directories, Ada.Text_IO;
Search: Search_Type; Found: Directory_Entry_Type;
package SV is new Ada.Containers.Indefinite_Vectors(Natural, String);
Result: SV.Vector;
package Sorting is new SV.Generic_Sorting; use Sorting;
function SName return String is (Simple_Name(Found));
begin
-- search directory and store it in Result, a vector of strings
Start_Search(Search, Directory => ".", Pattern =>"");
while More_Entries(Search) loop
Get_Next_Entry(Search, Found);
declare
Name: String := Simple_Name(Found);
begin
if Name(Name'First) /= '.' then
Result.Append(Name);
end if; -- ingnore filenames beginning with "."
end;
end loop; -- Result holds the entire directory in arbitrary order
Sort(Result); -- Result holds the directory in proper order
-- print Result
for I in Result.First_Index .. Result.Last_Index loop
Put_Line(Result.Element(I));
end loop;
end Directory_List;

View file

@ -0,0 +1,13 @@
record r;
file f;
text s;
f.opendir(1.argv);
while (~f.case(s)) {
if (s != "." && s != "..") {
r[s] = 0;
}
}
r.vcall(o_, 0, "\n");

View file

@ -0,0 +1 @@
print list "."

View file

@ -0,0 +1,8 @@
directory$ = dir("m:\foo\bar\") #Specified directory
#directory$ = dir(currentdir) #Current directory
while directory$ <> ""
print directory$
directory$ = dir()
end while
end

View file

@ -0,0 +1,18 @@
' Emulate ls
cnt% = 0
files$ = ""
OPEN CURDIR$ FOR DIRECTORY AS mydir
GETFILE myfile$ FROM mydir
WHILE ISTRUE(LEN(myfile$))
IF LEFT$(myfile$, 1) != "." THEN
INCR cnt%
files$ = APPEND$(files$, cnt%, UNFLATTEN$(myfile$))
ENDIF
GETFILE myfile$ FROM mydir
WEND
CLOSE DIRECTORY mydir
IF cnt% > 0 THEN
FOR f$ IN SORT$(files$)
PRINT FLATTEN$(f$)
NEXT
ENDIF

View file

@ -0,0 +1,17 @@
#include <iostream>
#include <set>
#include <boost/filesystem.hpp>
namespace fs = boost::filesystem;
int main(void)
{
fs::path p(fs::current_path());
std::set<std::string> tree;
for (auto it = fs::directory_iterator(p); it != fs::directory_iterator(); ++it)
tree.insert(it->path().filename().native());
for (auto entry : tree)
std::cout << entry << '\n';
}

View file

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Unix_ls
{
public class UnixLS
{
public static void Main(string[] args)
{
UnixLS ls = new UnixLS();
ls.list(args.Length.Equals(0) ? "." : args[0]);
}
private void list(string folder)
{
foreach (FileSystemInfo fileSystemInfo in new DirectoryInfo(folder).EnumerateFileSystemInfos("*", SearchOption.TopDirectoryOnly))
{
Console.WriteLine(fileSystemInfo.Name);
}
}
}
}

63
Task/Unix-ls/C/unix-ls.c Normal file
View file

@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
#include <dirent.h>
#include <unistd.h>
int cmpstr(const void *a, const void *b)
{
return strcmp(*(const char**)a, *(const char**)b);
}
int main(void)
{
DIR *basedir;
char path[PATH_MAX];
struct dirent *entry;
char **dirnames;
int diralloc = 128;
int dirsize = 0;
if (!(dirnames = malloc(diralloc * sizeof(char*)))) {
perror("malloc error:");
return 1;
}
if (!getcwd(path, PATH_MAX)) {
perror("getcwd error:");
return 1;
}
if (!(basedir = opendir(path))) {
perror("opendir error:");
return 1;
}
while ((entry = readdir(basedir))) {
if (dirsize >= diralloc) {
diralloc *= 2;
if (!(dirnames = realloc(dirnames, diralloc * sizeof(char*)))) {
perror("realloc error:");
return 1;
}
}
dirnames[dirsize++] = strdup(entry->d_name);
}
qsort(dirnames, dirsize, sizeof(char*), cmpstr);
int i;
for (i = 0; i < dirsize; ++i) {
if (dirnames[i][0] != '.') {
printf("%s\n", dirnames[i]);
}
}
for (i = 0; i < dirsize; ++i)
free(dirnames[i]);
free(dirnames);
closedir(basedir);
return 0;
}

View file

@ -0,0 +1,3 @@
(def files (sort (filter #(= "." (.getParent %)) (file-seq (clojure.java.io/file ".")))))
(doseq [n files] (println (.getName n)))

View file

@ -0,0 +1,12 @@
(defun files-list (&optional (path "."))
(let* ((dir (concatenate 'string path "/"))
(abs-path (car (directory dir)))
(file-pattern (concatenate 'string dir "*"))
(subdir-pattern (concatenate 'string file-pattern "/")))
(remove-duplicates
(mapcar (lambda (p) (enough-namestring p abs-path))
(mapcan #'directory (list file-pattern subdir-pattern)))
:test #'string-equal)))
(defun ls (&optional (path "."))
(format t "~{~a~%~}" (sort (files-list path) #'string-lessp)))

6
Task/Unix-ls/D/unix-ls.d Normal file
View file

@ -0,0 +1,6 @@
void main() {
import std.stdio, std.file, std.path, std.array, std.algorithm;
foreach (const string path; dirEntries(getcwd, SpanMode.shallow).array.sort)
path.baseName.writeln;
}

View 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.

View file

@ -0,0 +1,16 @@
;; ls of stores (kind of folders)
(for-each writeln (list-sort < (local-stores))) →
AGES
NEMESIS
info
objects.dat
reader
system
user
words
;; ls of "NEMESIS" store
(for-each writeln (local-keys "NEMESIS")) →
Alan
Glory
Jonah

View file

@ -0,0 +1,11 @@
iex(1)> ls = fn dir -> File.ls!(dir) |> Enum.each(&IO.puts &1) end
#Function<6.54118792/1 in :erl_eval.expr/5>
iex(2)> ls.("foo")
bar
:ok
iex(3)> ls.("foo/bar")
1
2
a
b
:ok

View file

@ -0,0 +1,14 @@
1> Ls = fun(Dir) ->
1> {ok, DirContents} = file:list_dir(Dir),
1> [io:format("~s~n", [X]) || X <- lists:sort(DirContents)]
1> end.
#Fun<erl_eval.6.36634728>
2> Ls("foo").
bar
[ok]
3> Ls("foo/bar").
1
2
a
b
[ok,ok,ok,ok]

View file

@ -0,0 +1 @@
let ls = DirectoryInfo(".").EnumerateFileSystemInfos() |> Seq.map (fun i -> i.Name) |> Seq.sort |> Seq.iter (printfn "%s")

View file

@ -0,0 +1,12 @@
256 buffer: filename-buf
: each-filename { xt -- } \ xt-consuming variant
s" ." open-dir throw { d }
begin filename-buf 256 d read-dir throw while
filename-buf swap xt execute
repeat d close-dir throw ;
\ immediate variant
: each-filename[ s" ." postpone sliteral ]] open-dir throw >r begin filename-buf 256 r@ read-dir throw while filename-buf swap [[ ; immediate compile-only
: ]each-filename ]] repeat drop r> close-dir throw [[ ; immediate compile-only
: ls ( -- ) [: cr type ;] each-filename ;

View file

@ -0,0 +1,15 @@
: save-string ( c-addr u -- a )
dup 1+ allocate throw dup >r place r> ;
require ffl/car.fs
: sorted-filenames ( -- car )
0 car-new { a }
[: swap count rot count compare ;] a car-compare!
each-filename[ save-string a car-insert-sorted ]each-filename
a ;
: each-sorted-filename ( xt -- )
sorted-filenames { a } a car-execute [: free throw ;] a car-execute a car-free ;
: ls ( -- )
[: count cr type ;] each-sorted-filename ;

View file

@ -0,0 +1,18 @@
PROGRAM LS !Names the files in the current directory.
USE DFLIB !Mysterious library.
TYPE(FILE$INFO) INFO !With mysterious content.
NAMELIST /HIC/INFO !This enables annotated output.
INTEGER MARK,L !Assistants.
MARK = FILE$FIRST !Starting state.
Call for the next file.
10 L = GETFILEINFOQQ("*",INFO,MARK) !Mystery routine returns the length of the file name.
IF (MARK.EQ.FILE$ERROR) THEN !Or possibly, not.
WRITE (6,*) "Error!",L !Something went wrong.
WRITE (6,HIC) !Reveal INFO, annotated.
STOP "That wasn't nice." !Quite.
ELSE IF (IAND(INFO.PERMIT,FILE$DIR) .EQ. 0) THEN !Not a directory.
IF (L.GT.0) WRITE (6,*) INFO.NAME(1:L) !The object of the exercise!
END IF !So much for that entry.
IF (MARK.NE.FILE$LAST) GO TO 10 !Lastness is discovered after the last file is fingered.
END !If FILE$LAST is not reached, "system resources may be lost."

View file

@ -0,0 +1,16 @@
INTERFACE
INTEGER*4 FUNCTION GETFILEINFOQQ(FILES, BUFFER,dwHANDLE)
!DEC$ ATTRIBUTES DEFAULT :: GETFILEINFOQQ
CHARACTER*(*) FILES
STRUCTURE / FILE$INFO /
INTEGER*4 CREATION ! Creation time (-1 on FAT)
INTEGER*4 LASTWRITE ! Last write to file
INTEGER*4 LASTACCESS ! Last access (-1 on FAT)
INTEGER*4 LENGTH ! Length of file
INTEGER*2 PERMIT ! File access mode
CHARACTER*255 NAME ! File name
END STRUCTURE
RECORD / FILE$INFO / BUFFER
INTEGER*4 dwHANDLE
END FUNCTION
END INTERFACE

View file

@ -0,0 +1,13 @@
#include "dir.bi"
Sub ls(Byref filespec As String, Byval attrib As Integer)
Dim As String filename = Dir(filespec, attrib)
Do While Len(filename) > 0
Print filename
filename = Dir()
Loop
End Sub
Dim As String directory = "" ' Current directory
ls(directory & "*", fbDirectory)
Sleep

View file

@ -0,0 +1,2 @@
for f = sort[files["."], {|a,b| lexicalCompare[a.getName[], b.getName[]]}]
println[f.getName[]]

View file

@ -0,0 +1,4 @@
import io.File
for f <- sort( list(File( "." ).list()).filterNot(s -> s.startsWith(".")) )
println( f )

View file

@ -0,0 +1,80 @@
###sysinclude dir.uh
###sysinclude stringextra.uh
###define COLORS
// delete the COLORS directive above if you do not want colored output!
{ „vonal” __usebigbossnamespace myself "-" 90 makestring() }
{ „points” __usebigbossnamespace myself "." 60 makestring() }
#g argc 3 < { "." }{ 2 argv } sto mypath
@mypath 'd !istrue { ."The give directory doesn't exist! Exited.\n" end }
@mypath getdir { ."Cannot load the dir! Aborted.\n" end } sto mydir
@mydir ~d {
."Directories:\n"
@mydir ~d {| #s
@mydir 'd {} octalrights dup print free SPACE
@mydir 'd {} getfilename dup 37 stub print SPACE drop
@mydir 'd {} groupname ': !+
@mydir 'd {} ownername dup sto temp + dup 10 stub print free @temp free
@mydir 'd {} mtime dup print free
NL |}
@points sprint
@mydir ~d { ."Total: " @mydir ~d #g print ." subdirectories.\n" }
@vonal sprint
}
@mydir ~r {
."Regular files:\n"
@mydir ~r {| #s
@mydir 'r {} octalrights dup print free SPACE
@mydir 'r {} getfilesize sbr §ifcolored
@mydir 'r {} executable { ." >" }{ ." " } SPACE
@mydir 'r {} getfilename dup 37 stub print SPACE drop
@mydir 'r {} groupname ': !+
@mydir 'r {} ownername dup sto temp + dup 10 stub print free @temp free
@mydir 'r {} mtime dup print free
NL |}
@points sprint
@mydir ~r { ."Total: " @mydir ~r #g print ." regular files. "
."TotalSize = " @mydir 'r totalsize sbr §ifcolored NL
}
@vonal sprint
}
@mydir ~L {
."Symlinks:\n"
@mydir ~L {| #s
@mydir 'L {} octalrights dup print free SPACE
@mydir 'L {} executable { .">" }{ SPACE } SPACE
@mydir 'L {} getfilename dup 67 stub print SPACE drop
@mydir 'L {} broken { ."--->" }{ ."===>" } SPACE
@mydir 'L {} destination dup 30 stub print drop
NL |}
@points sprint
@mydir ~L { ."Total: " @mydir ~L #g print ." symlinks.\n"
}
}
@vonal sprint
."Size, alltogether = " @mydir alltotal sbr §ifcolored NL
@vonal sprint
@mydir free
."Free spaces: /* Total size of the filesystem is : " @mypath filesystemsize dup sto filsize sbr §ifcolored ." */\n"
." for non-privilegized use: " @mypath freenonpriv dup sbr §ifcolored
#g 100 * @filsize / ." ( " print ."% ) " NL
." All available free space: " @mypath totalfree dup sbr §ifcolored
#g 100 * @filsize / ." ( " print ."% ) " NL
end
ifcolored:
###ifdef COLORS
coloredsize
###endif
###ifndef COLORS
#g !(#s) 21 >|
###endif
dup sprint free
rts
{ „filsize” }
{ „mydir” }
{ „mypath” }
{ „temp” }
{ „makestring” #s * dup 10 !+ swap free #g = }

View file

@ -0,0 +1,6 @@
Public Sub Main()
Dim sDir As String[] = Dir(User.Home &/ "test").Sort()
Print sDir.Join(gb.NewLine)
End

View file

@ -0,0 +1,24 @@
package main
import (
"fmt"
"log"
"os"
"sort"
)
func main() {
f, err := os.Open(".")
if err != nil {
log.Fatal(err)
}
files, err := f.Readdirnames(0)
f.Close()
if err != nil {
log.Fatal(err)
}
sort.Strings(files)
for _, n := range files {
fmt.Println(n)
}
}

View file

@ -0,0 +1,9 @@
import Control.Monad
import Data.List
import System.Directory
dontStartWith = flip $ (/=) . head
main = do
files <- getDirectoryContents "."
mapM_ putStrLn $ sort $ filter (dontStartWith '.') files

2
Task/Unix-ls/J/unix-ls.j Normal file
View file

@ -0,0 +1,2 @@
dir '' NB. includes properties
>1 1 dir '' NB. plain filename as per task

View file

@ -0,0 +1,86 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Formatter;
import java.util.List;
public class Ls {
public static void main(String[] args) throws Exception {
Ls ls = new Ls("/");
System.out.println(ls);
}
private final File directory;
private final List<File> list;
public Ls(String path) throws Exception {
directory = new File(path);
if (!directory.exists())
throw new Exception("Path not found '%s'".formatted(directory));
if (!directory.isDirectory())
throw new Exception("Not a directory '%s'".formatted(directory));
list = new ArrayList<>(List.of(directory.listFiles()));
/* place the directories first */
list.sort((fileA, fileB) -> {
if (fileA.isDirectory() && fileB.isFile()) {
return -1;
} else if (fileA.isFile() && fileB.isDirectory()) {
return 1;
}
return 0;
});
}
private String size(long bytes) {
if (bytes > 1E9) {
return "%.1fG".formatted(bytes / 1E9d);
} else if (bytes > 1E6) {
return "%.1fM".formatted(bytes / 1E6d);
} else if (bytes > 1E3) {
return "%.1fK".formatted(bytes / 1E3d);
} else {
return "%d".formatted(bytes);
}
}
@Override
public String toString() {
StringBuilder string = new StringBuilder();
Formatter formatter = new Formatter(string);
/* add parent and current directory listings */
list.add(0, directory.getParentFile());
list.add(0, directory);
/* generate total used space value */
long total = 0;
for (File file : list) {
if (file == null) continue;
total += file.length();
}
formatter.format("total %s%n", size(total));
/* generate output for each entry */
int index = 0;
for (File file : list) {
if (file == null) continue;
/* generate permission columns */
formatter.format(file.isDirectory() ? "d" : "-");
formatter.format(file.canRead() ? "r" : "-");
formatter.format(file.canWrite() ? "w" : "-");
formatter.format(file.canExecute() ? "x" : "-");
/* include size */
formatter.format("%7s ", size(file.length()));
/* modification timestamp */
formatter.format("%tb %1$td %1$tR ", file.lastModified());
/* file or directory name */
switch (index) {
case 0 -> formatter.format(".");
case 1 -> formatter.format("..");
default -> formatter.format("%s", file.getName());
}
if (file.isDirectory())
formatter.format(File.separator);
formatter.format("%n");
index++;
}
formatter.flush();
return string.toString();
}
}

View file

@ -0,0 +1,12 @@
package rosetta;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class UnixLS {
public static void main(String[] args) throws IOException {
Files.list(Path.of("")).sorted().forEach(System.out::println);
}
}

View file

@ -0,0 +1 @@
Files.list(Path.of("")).map(Path::toString).sorted(String.CASE_INSENSITIVE_ORDER).forEach(System.out::println);

View file

@ -0,0 +1,2 @@
const fs = require('fs');
fs.readdir('.', (err, names) => names.sort().map( name => console.log(name) ));

View file

@ -0,0 +1 @@
puts(File.glob().sort().join('\n'));

View file

@ -0,0 +1,9 @@
# v0.6.0
for e in readdir() # Current directory
println(e)
end
# Same for...
readdir("~") # Read home directory
readdir("~/documents")

View file

@ -0,0 +1,18 @@
// Version 1.2.41
import java.io.File
fun ls(directory: String) {
val d = File(directory)
if (!d.isDirectory) {
println("$directory is not a directory")
return
}
d.listFiles().map { it.name }
.sortedBy { it.toLowerCase() } // case insensitive
.forEach { println(it) }
}
fun main(args: Array<String>) {
ls(".") // list files in current directory, say
}

View file

@ -0,0 +1,16 @@
#!/bin/ksh
# List everything in the current folder (sorted), similar to `ls`
# # Variables:
#
targetDir=${1:-/tmp/foo}
######
# main #
######
cd ${targetDir}
for obj in *; do
print ${obj}
done

View file

@ -0,0 +1,4 @@
set the defaultFolder to "/foo"
put the folders & the files
set the defaultFolder to "/foo/bar"
put the folders & the files

View file

@ -0,0 +1,2 @@
require("lfs")
for file in lfs.dir(".") do print(file) end

View file

@ -0,0 +1 @@
Column[FileNames[]]

View file

@ -0,0 +1,8 @@
import Nanoquery.IO
import sort
fnames = sort(new(File).listDir("."))
for i in range(0, len(fnames) - 1)
println fnames[i]
end

View file

@ -0,0 +1,6 @@
from algorithm import sorted
from os import walkPattern
from sequtils import toSeq
for path in toSeq(walkPattern("*")).sorted:
echo path

View file

@ -0,0 +1,3 @@
let () =
Array.iter print_endline (
Sys.readdir Sys.argv.(1) )

View file

@ -0,0 +1,12 @@
class Test {
function : Main(args : String[]) ~ Nil {
file_names := System.IO.File.Directory->List(".");
each(i : file_names) {
file_name := file_names[i];
if(System.IO.File.Directory->Exists(file_name)) {
file_name += '/';
};
file_name->PrintLine();
};
}
}

View file

@ -0,0 +1 @@
system("dir/b/on")

View file

@ -0,0 +1 @@
system("ls")

View file

@ -0,0 +1,4 @@
<?php
foreach(scandir('.') as $fileName){
echo $fileName."\n";
}

View file

@ -0,0 +1,11 @@
Program ls; {To list the names of all files/directories in the current directory.}
Uses DOS;
var DirInfo: SearchRec; {Predefined. See page 403 of the Turbo Pascal 4 manual.}
BEGIN
FindFirst('*.*',AnyFile,DirInfo); {AnyFile means any file name OR directory name.}
While DOSerror = 0 do {Result of FindFirst/Next not being a function, damnit.}
begin
WriteLn(DirInfo.Name);
FindNext(DirInfo);
end;
END.

View file

@ -0,0 +1,88 @@
###sysinclude standard.uh
###sysinclude args.uh
###sysinclude io.uh
###sysinclude str.uh
###define COLORS
// delete the COLORS directive above if you do not want colored output!
#g argc 3 < { "." }{ 2 argv } sto mypath
@mypath 'd inv istrue { ."The given directory doesn't exist! Exited.\n" end }
@mypath getdir { ."Cannot load the dir! Aborted.\n" end } sto mydir
'- 90 *... sto vonal
'. 60 *... sto points
@mydir ~d {
."Directories:\n"
@mydir ~d {{ #s
@mydir 'd {{}} octalrights dup print inv mem SPACE
@mydir 'd {{}} getfilename dup 67 mc print SPACE drop
@mydir 'd {{}} groupname ': !+
@mydir 'd {{}} ownername dup sto temp + dup 10 mc print inv mem @temp inv mem
@mydir 'd {{}} mtime dup print inv mem
NL }}
@points sprintnl
@mydir ~d { ."Total: " @mydir ~d #g print ." subdirectories.\n" }
@vonal sprintnl
}
@mydir ~r {
."Regular files:\n"
@mydir ~r {{ #s
@mydir 'r {{}} octalrights dup print inv mem SPACE
@mydir 'r {{}} getfilesize sbr §ifcolored
@mydir 'r {{}} executable { ." >" }{ ." " } SPACE
@mydir 'r {{}} getfilename dup 67 mc print SPACE drop
@mydir 'r {{}} groupname ': !+
@mydir 'r {{}} ownername dup sto temp + dup 10 mc print inv mem @temp inv mem
@mydir 'r {{}} mtime dup print inv mem
NL }}
@points sprintnl
@mydir ~r { ."Total: " @mydir ~r #g print ." regular files. "
."TotalSize = " @mydir 'r totalsize sbr §ifcolored NL
}
@vonal sprintnl
}
@mydir ~L {
."Symlinks:\n"
@mydir ~L {{ #s
@mydir 'L {{}} octalrights dup print inv mem SPACE
@mydir 'L {{}} executable { .">" }{ SPACE } SPACE
@mydir 'L {{}} getfilename dup 67 mc print SPACE drop
@mydir 'L {{}} broken { ."--->" }{ ."===>" } SPACE
@mydir 'L {{}} destination dup 30 mc print drop
NL }}
@points sprintnl
@mydir ~L { ."Total: " @mydir ~L #g print ." symlinks.\n"
}
}
@vonal sprintnl
."Size, alltogether = " @mydir alltotal sbr §ifcolored NL
@vonal sprintnl
@mydir inv mem
."free spaces: /* Total size of the filesystem is : " @mypath filesystemsize dup sto filsize sbr §ifcolored ." */\n"
." for non-privilegized use: " @mypath freenonpriv dup sbr §ifcolored
#g 100 * @filsize / ." ( " print ."% ) " NL
." All available free space: " @mypath totalfree dup sbr §ifcolored
#g 100 * @filsize / ." ( " print ."% ) " NL
@vonal inv mem
end
ifcolored:
###ifdef COLORS
coloredsize
###endif
###ifndef COLORS
#g !(#s) 21 >|
###endif
dup sprint inv mem
rts
{ „filsize” }
{ „mydir” }
{ „mypath” }
{ „temp” }
{ „vonal” }
{ „points” }

View file

@ -0,0 +1,5 @@
opendir my $handle, '.' or die "Couldnt open current directory: $!";
while (readdir $handle) {
print "$_\n";
}
closedir $handle;

View file

@ -0,0 +1 @@
print "$_\n" for glob '*';

View file

@ -0,0 +1 @@
print "$_\n" for glob '* .*'; # If you want to include dot files

View file

@ -0,0 +1,4 @@
-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #7060A8;">pp</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),{</span><span style="color: #004600;">pp_Nest</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #004600;">pp_IntCh</span><span style="color: #0000FF;">,</span><span style="color: #004600;">false</span><span style="color: #0000FF;">})</span>
<!--

View file

@ -0,0 +1,4 @@
-->
<span style="color: #008080;">without</span> <span style="color: #008080;">js</span> <span style="color: #000080;font-style:italic;">-- (file i/o)</span>
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">vslice</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">),</span><span style="color: #004600;">D_NAME</span><span style="color: #0000FF;">)</span>
<!--

View file

@ -0,0 +1,29 @@
(phixonline)-->
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">dirf</span><span style="color: #0000FF;">(</span><span style="color: #004080;">string</span> <span style="color: #000000;">path</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">integer</span> <span style="color: #000000;">date_type</span><span style="color: #0000FF;">=</span><span style="color: #004600;">D_MODIFICATION</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span>
<span style="color: #008080;">return</span> <span style="color: #0000FF;">{{</span><span style="color: #008000;">`.`</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">`d`</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2022</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">11</span><span style="color: #0000FF;">,</span><span style="color: #000000;">01</span><span style="color: #0000FF;">,</span><span style="color: #000000;">09</span><span style="color: #0000FF;">,</span><span style="color: #000000;">13</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">`..`</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">`d`</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2022</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">11</span><span style="color: #0000FF;">,</span><span style="color: #000000;">01</span><span style="color: #0000FF;">,</span><span style="color: #000000;">09</span><span style="color: #0000FF;">,</span><span style="color: #000000;">13</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">`.fake`</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">`a`</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2021</span><span style="color: #0000FF;">,</span><span style="color: #000000;">6</span><span style="color: #0000FF;">,</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #000000;">6</span><span style="color: #0000FF;">,</span><span style="color: #000000;">42</span><span style="color: #0000FF;">,</span><span style="color: #000000;">6</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">`directory`</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">`a`</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">18898</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2020</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">,</span><span style="color: #000000;">4</span><span style="color: #0000FF;">,</span><span style="color: #000000;">13</span><span style="color: #0000FF;">,</span><span style="color: #000000;">57</span><span style="color: #0000FF;">,</span><span style="color: #000000;">37</span><span style="color: #0000FF;">},</span>
<span style="color: #0000FF;">{</span><span style="color: #008000;">`for.p2js`</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">`a`</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">1024</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2019</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,</span><span style="color: #000000;">28</span><span style="color: #0000FF;">,</span><span style="color: #000000;">15</span><span style="color: #0000FF;">,</span><span style="color: #000000;">30</span><span style="color: #0000FF;">,</span><span style="color: #000000;">45</span><span style="color: #0000FF;">}}</span>
<span style="color: #008080;">else</span>
<span style="color: #008080;">return</span> <span style="color: #7060A8;">dir</span><span style="color: #0000FF;">(</span><span style="color: #000000;">path</span><span style="color: #0000FF;">,</span><span style="color: #000000;">date_type</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">builtins</span><span style="color: #0000FF;">\</span><span style="color: #004080;">timedate</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #7060A8;">set_timedate_formats</span><span style="color: #0000FF;">({</span><span style="color: #008000;">"hh:mmpm Ddd Mmm ddth YYYY"</span><span style="color: #0000FF;">})</span>
<span style="color: #004080;">object</span> <span style="color: #000000;">d</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">dirf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"."</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">d</span><span style="color: #0000FF;">!=-</span><span style="color: #000000;">1</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%-20s %s %10s %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"-- name --"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"attr"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"size"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"-- time and date --"</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">sequence</span> <span style="color: #000000;">di</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">d</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span>
<span style="color: #004080;">string</span> <span style="color: #000000;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">di</span><span style="color: #0000FF;">[</span><span style="color: #004600;">D_NAME</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">attr</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">di</span><span style="color: #0000FF;">[</span><span style="color: #004600;">D_ATTRIBUTES</span><span style="color: #0000FF;">],</span>
<span style="color: #000000;">size</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">file_size_k</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #004600;">D_SIZE</span><span style="color: #0000FF;">]),</span>
<span style="color: #000000;">tdte</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">format_timedate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">d</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">][</span><span style="color: #004600;">D_YEAR</span><span style="color: #0000FF;">..$])</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%-20s %=4s %10s %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">name</span><span style="color: #0000FF;">,</span><span style="color: #000000;">attr</span><span style="color: #0000FF;">,</span><span style="color: #000000;">size</span><span style="color: #0000FF;">,</span><span style="color: #000000;">tdte</span><span style="color: #0000FF;">})</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<!--

View file

@ -0,0 +1,7 @@
import os, util.
main =>
println(ls()),
println(ls("foo/bar")).
ls() = ls(".").
ls(Path) = [F : F in listdir(Path), F != ".",F != ".."].sort.join('\n').

View file

@ -0,0 +1,2 @@
(for F (sort (dir))
(prinl F) )

View file

@ -0,0 +1,2 @@
foreach(sort(get_dir()), string file)
write(file +"\n");

View file

@ -0,0 +1,5 @@
# Prints Name, Length, Mode, and LastWriteTime
Get-ChildItem | Sort-Object Name | Write-Output
# Prints only the name of each file in the directory
Get-ChildItem | Sort-Object Name | ForEach-Object Name | Write-Output

View file

@ -0,0 +1,15 @@
NewList lslist.s()
If OpenConsole("ls-sim")
If ExamineDirectory(0,GetCurrentDirectory(),"*.*")
While NextDirectoryEntry(0)
AddElement(lslist()) : lslist()=DirectoryEntryName(0)
Wend
FinishDirectory(0)
SortList(lslist(),#PB_Sort_Ascending)
ForEach lslist()
PrintN(lslist())
Next
EndIf
Input()
EndIf

View file

@ -0,0 +1,16 @@
>>> import os
>>> print('\n'.join(sorted(os.listdir('.'))))
DLLs
Doc
LICENSE.txt
Lib
NEWS.txt
README.txt
Scripts
Tools
include
libs
python.exe
pythonw.exe
tcl
>>>

2
Task/Unix-ls/R/unix-ls.r Normal file
View file

@ -0,0 +1,2 @@
cat(paste(list.files(), collapse = "\n"), "\n")
cat(paste(list.files("bar"), collapse = "\n"), "\n")

View file

@ -0,0 +1,3 @@
/*REXX program lists contents of current folder (ala mode UNIX's LS). */
'DIR /b /oN' /*use Windows DIR: sorts & lists.*/
/*stick a fork in it, we're done.*/

View file

@ -0,0 +1,20 @@
#lang racket/base
;; Racket's `directory-list' produces a sorted list of files
(define (ls) (for-each displayln (directory-list)))
;; Code to run when this file is running directly
(module+ main
(ls))
(module+ test
(require tests/eli-tester racket/port racket/file)
(define (make-directory-tree)
(make-directory* "foo/bar")
(for ([f '("1" "2" "a" "b")])
(with-output-to-file (format "foo/bar/~a"f) #:exists 'replace newline)))
(make-directory-tree)
(define (ls/str dir)
(parameterize ([current-directory dir]) (with-output-to-string ls)))
(test (ls/str "foo") => "bar\n"
(ls/str "foo/bar") => "1\n2\na\nb\n"))

View file

@ -0,0 +1 @@
.say for sort ~«dir

View file

@ -0,0 +1 @@
Dir.foreach("./"){|n| puts n}

View file

@ -0,0 +1,13 @@
files #f, DefaultDir$ + "\*.*" ' RunBasic Default directory.. Can be any directroy
print "rowcount: ";#f ROWCOUNT() ' how many rows in directory
#f DATEFORMAT("mm/dd/yy") 'set format of file date or not
#f TIMEFORMAT("hh:mm:ss") 'set format of file time or not
count = #f rowcount()
for i = 1 to count ' loop thru the row count
print "info: ";#f nextfile$() ' file info
print "name: ";#f NAME$() ' Name of file
print "size: ";#f SIZE() ' size
print "date: ";#f DATE$() ' date
print "time: ";#f TIME$() ' time
print "isdir: ";#f ISDIR() ' 1 = is a directory
next

View file

@ -0,0 +1,24 @@
use std::{env, fmt, fs, process};
use std::io::{self, Write};
use std::path::Path;
fn main() {
let cur = env::current_dir().unwrap_or_else(|e| exit_err(e, 1));
let arg = env::args().nth(1);
print_files(arg.as_ref().map_or(cur.as_path(), |p| Path::new(p)))
.unwrap_or_else(|e| exit_err(e, 2));
}
#[inline]
fn print_files(path: &Path) -> io::Result<()> {
for x in try!(fs::read_dir(path)) {
println!("{}", try!(x).file_name().to_string_lossy());
}
Ok(())
}
#[inline]
fn exit_err<T>(msg: T, code: i32) -> ! where T: fmt::Display {
writeln!(&mut io::stderr(), "{}", msg).expect("Could not write to stderr");
process::exit(code)
}

View file

@ -0,0 +1,3 @@
variable d = listdir(getcwd()), p;
foreach p (array_sort(d))
() = printf("%s\n", d[p] );

View file

@ -0,0 +1,11 @@
$ include "seed7_05.s7i";
include "osfiles.s7i";
const proc: main is func
local
var string: name is "";
begin
for name range readDir(".") do
writeln(name);
end for;
end func;

View file

@ -0,0 +1,9 @@
var content = [];
Dir.cwd.open.each { |file|
file ~~ < . .. > && next;
content.append(file);
}
content.sort.each { |file|
say file;
}

View file

@ -0,0 +1,3 @@
'*'.glob.each { |file|
say file;
}

View file

@ -0,0 +1 @@
Stdout printCR: ( PipeStream outputFromCommand:'ls' )

View file

@ -0,0 +1 @@
Stdout printCR:('.' asFilename directoryContents sort asStringWith:Character cr)

View file

@ -0,0 +1 @@
'.' asFilename directoryContents sort do:#printCR

View file

@ -0,0 +1,34 @@
dir := '.' asFilename.
dir directoryContentsAsFilenames sort do:[:fn |
|line|
"
generate a line of the form of ls -l:
drwxrwxrwx user group size date time name
where year is printed if not current, time of day otherwise
"
line := String streamContents:[:s |
|accessRights|
s nextPut:(fn isDirectory ifTrue:[$d] ifFalse:[$-]).
accessRights := fn symbolicAccessRights.
#( readUser writeUser executeUser
readGroup writeGroup executeGroup
readOthers writeOthers executeOthers
)
with:'rwxrwxrwx'
do:[:eachRight :charToPrint |
s nextPut:((accessRights includes:eachRight) ifTrue:[charToPrint] ifFalse:[$-])
].
(OperatingSystem getUserNameFromID:fn info uid) printOn:s leftPaddedTo:10.
(OperatingSystem getGroupNameFromID:fn info gid) printOn:s leftPaddedTo:10.
fn fileSize printOn:s leftPaddedTo:12.
fn modificationTime year = Date today year ifTrue:[
fn modificationTime printOn:s format:' %(dayPadded) %(ShortMonthName) %h:%m'.
] ifFalse:[
fn modificationTime asDate printOn:s format:' %(dayPadded) %(ShortMonthName) %y'.
].
s space.
s nextPutAll:fn baseName
].
line printCR
].

View file

@ -0,0 +1 @@
OS.Process.system "ls -a"

View file

@ -0,0 +1,15 @@
local (* make a sort function *)
val rec insert = fn s :string =>fn [] => [s]
| ll as h::t => if s<=h then s::ll else h::insert s t;
in
val rec sort = fn [] => [] | h::t => insert h (sort t)
end;
open Posix.FileSys ;
val istream = opendir "." ;
val ll = ref [readdir istream] ;
while ( isSome (hd (!ll)) ) do ( ll:=readdir istream :: !ll );
val result = List.map valOf (tl (!ll));
closedir istream ;
sort result;

View file

@ -0,0 +1,4 @@
. dir *.dta
6.3k 6/12/17 14:26 auto.dta
2.3k 8/10/17 7:34 titanium.dta
6.0k 8/12/17 9:28 trend.dta

View file

@ -0,0 +1 @@
puts [join [lsort [glob -nocomplain *]] "\n"]

View file

@ -0,0 +1 @@
echo *

View file

@ -0,0 +1 @@
for f in *; do echo "$f"; done

View file

@ -0,0 +1 @@
for f in *; do echo "$f"; done |sort

View file

@ -0,0 +1 @@
stat -c %n * |sort

View file

@ -0,0 +1,7 @@
decl file f
decl string<> fnames
set fnames (sort (f.listdir "."))
for (decl int i) (< i (size fnames)) (inc i)
out fnames<i> endl console
end for

View file

@ -0,0 +1,6 @@
import os
fn main() {
contents := os.ls('.')?
println(contents)
}

View file

@ -0,0 +1,6 @@
import "io" for Directory
var path = "./" // or whatever
// Note that output is automatically sorted using this method.
Directory.list(path).each { |f| System.print(f) }

View file

@ -0,0 +1,7 @@
string 0;
char S;
[S:= "ls";
asm { ldr r0, S
bl system
}
]

View file

@ -0,0 +1 @@
File.glob("*").sort()

View file

@ -0,0 +1 @@
File.glob("*",0x8).sort()

View file

@ -0,0 +1 @@
File.globular("Src",*,True,0x10,List).sort().concat("\n")