Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1 @@
|
|||
"*.c" f:rglob \ top of stack now has list of all "*.c" files, recursively
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
// care only about visible files and filter out any directories
|
||||
define dir -> eachVisibleFilePath() => {
|
||||
return with name in self -> eachEntry where #name -> second != io_dir_dt_dir where not(#name -> first -> beginswith('.')) select .makeFullPath(#name -> first)
|
||||
}
|
||||
|
||||
// care only about visible directories and filter out any files
|
||||
define dir -> eachVisibleDir() => {
|
||||
return with name in self -> eachEntry where #name -> second == io_dir_dt_dir where not(#name -> first -> beginswith('.')) select dir(.makeFullPath(#name -> first + '/'))
|
||||
}
|
||||
|
||||
// Recursively walk the directory tree and find all files and directories
|
||||
// return only paths to files
|
||||
define dir -> eachVisibleFilePathRecursive(-dirFilter = void) => {
|
||||
local(files = .eachVisibleFilePath)
|
||||
with dir in .eachVisibleDir
|
||||
where !#dirFilter || #dirFilter(#dir -> realPath)
|
||||
do {
|
||||
#files = tie(#files, #dir -> eachVisibleFilePathRecursive(-dirFilter = #dirFilter))
|
||||
}
|
||||
return #files
|
||||
}
|
||||
|
||||
local(matchingfilenames = array)
|
||||
|
||||
with filepath in dir('/') -> eachVisibleFilePathRecursive
|
||||
where #filepath -> endswith('.lasso')
|
||||
let filename = #filepath -> split('/') -> last
|
||||
do #matchingfilenames -> insert(#filename)
|
||||
|
||||
#matchingfilenames
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
function recurDir dir, ext
|
||||
set the defaultFolder to dir
|
||||
repeat for each line fi in the files
|
||||
if fileExt(fi) = ext then
|
||||
put the longfilepath of fi & cr after fileList
|
||||
end if
|
||||
end repeat
|
||||
repeat for each line di in the folders
|
||||
if di is not "." and di is not ".." then
|
||||
put recurDir((dir & slash & di), ext) & cr after fileList
|
||||
end if
|
||||
end repeat
|
||||
filter fileList without empty
|
||||
return fileList
|
||||
end recurDir
|
||||
|
||||
function fileExt f
|
||||
set the itemdel to "."
|
||||
return the last item of f
|
||||
end fileExt
|
||||
|
|
@ -0,0 +1 @@
|
|||
put recurDir(the home folder & slash & "music", "mp3")
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
import os, re
|
||||
|
||||
for file in walkDirRec "/":
|
||||
if file.match re".*\.mp3":
|
||||
echo file
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
function find_pfile(string pathname, sequence dirent)
|
||||
if match("pfile.e",dirent[D_NAME]) then
|
||||
-- return pathname&dirent[D_NAME] -- to terminate scan
|
||||
?pathname&"\\"&dirent[D_NAME]
|
||||
end if
|
||||
return 0
|
||||
end function
|
||||
|
||||
?walk_dir("C:\\Program Files (x86)\\Phix",routine_id("find_pfile"),1)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
see "Testing DIR() " + nl
|
||||
mylist = dir("C:\Ring")
|
||||
for x in mylist
|
||||
if x[2]
|
||||
see "Directory : " + x[1] + nl
|
||||
else
|
||||
see "File : " + x[1] + nl
|
||||
ok
|
||||
next
|
||||
see "Files count : " + len(mylist)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
func traverse(Block callback, Dir dir) {
|
||||
dir.open(\var dir_h) || return;
|
||||
|
||||
dir_h.entries.each { |entry|
|
||||
if (entry.is_a(Dir)) {
|
||||
traverse(callback, entry);
|
||||
} else {
|
||||
callback(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var dir = Dir.cwd;
|
||||
var pattern = /foo/; # display files that contain 'foo'
|
||||
|
||||
traverse(
|
||||
{ |file|
|
||||
if (file.basename ~~ pattern) {
|
||||
say file;
|
||||
}
|
||||
} => dir
|
||||
);
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import Foundation
|
||||
|
||||
let fileSystem = FileManager.default
|
||||
let rootPath = "/"
|
||||
|
||||
// Enumerate the directory tree (which likely recurses internally)...
|
||||
|
||||
if let fsTree = fileSystem.enumerator(atPath: rootPath) {
|
||||
|
||||
while let fsNodeName = fsTree.nextObject() as? NSString {
|
||||
|
||||
let fullPath = "\(rootPath)/\(fsNodeName)"
|
||||
|
||||
var isDir: ObjCBool = false
|
||||
fileSystem.fileExists(atPath: fullPath, isDirectory: &isDir)
|
||||
|
||||
if !isDir.boolValue && fsNodeName.pathExtension == "txt" {
|
||||
print(fsNodeName)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue