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
43
Task/Empty-directory/FreeBASIC/empty-directory.freebasic
Normal file
43
Task/Empty-directory/FreeBASIC/empty-directory.freebasic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
#Include "dir.bi"
|
||||
|
||||
Function IsDirEmpty(dirPath As String) As Boolean
|
||||
Err = 0
|
||||
' check dirPath is a valid directory
|
||||
Dim As String fileName = Dir(dirPath, fbDirectory)
|
||||
If Len(fileName) = 0 Then
|
||||
Err = 1000 ' dirPath is not a valid path
|
||||
Return False
|
||||
End If
|
||||
' now check if there are any files/subdirectories in it other than . and ..
|
||||
Dim fileSpec As String = dirPath + "\*.*"
|
||||
Const attribMask = fbNormal Or fbHidden Or fbSystem Or fbDirectory
|
||||
Dim outAttrib As UInteger
|
||||
fileName = Dir(fileSpec, attribMask, outAttrib) ' get first file
|
||||
Do
|
||||
If fileName <> ".." AndAlso fileName <> "." Then
|
||||
If Len(fileName) = 0 Then Return True
|
||||
Exit Do
|
||||
End If
|
||||
fileName = Dir ' get next file
|
||||
Loop
|
||||
Return False
|
||||
End Function
|
||||
|
||||
Dim outAttrib As UInteger
|
||||
Dim dirPath As String = "c:\freebasic\docs" ' known to be empty
|
||||
Dim empty As Boolean = IsDirEmpty(dirPath)
|
||||
Dim e As Long = Err
|
||||
If e = 1000 Then
|
||||
Print "'"; dirPath; "' is not a valid directory"
|
||||
End
|
||||
End If
|
||||
If empty Then
|
||||
Print "'"; dirPath; "' is empty"
|
||||
Else
|
||||
Print "'"; dirPath; "' is not empty"
|
||||
End If
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
3
Task/Empty-directory/Lasso/empty-directory.lasso
Normal file
3
Task/Empty-directory/Lasso/empty-directory.lasso
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
dir('has_content') -> isEmpty
|
||||
'<br />'
|
||||
dir('no_content') -> isEmpty
|
||||
3
Task/Empty-directory/Lingo/empty-directory.lingo
Normal file
3
Task/Empty-directory/Lingo/empty-directory.lingo
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
on isDirEmpty (dir)
|
||||
return getNthFileNameInFolder(dir, 1) = EMPTY
|
||||
end
|
||||
7
Task/Empty-directory/Nim/empty-directory.nim
Normal file
7
Task/Empty-directory/Nim/empty-directory.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import os, rdstdin
|
||||
|
||||
var empty = true
|
||||
for f in walkDir(readLineFromStdin "directory: "):
|
||||
empty = false
|
||||
break
|
||||
echo empty
|
||||
3
Task/Empty-directory/Ring/empty-directory.ring
Normal file
3
Task/Empty-directory/Ring/empty-directory.ring
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
myList = dir("C:\Ring\bin")
|
||||
if len(myList) > 0 see "C:\Ring\bin is not empty" + nl
|
||||
else see "C:\Ring\bin is empty" + nl ok
|
||||
1
Task/Empty-directory/Sidef/empty-directory-1.sidef
Normal file
1
Task/Empty-directory/Sidef/empty-directory-1.sidef
Normal file
|
|
@ -0,0 +1 @@
|
|||
Dir.new('/my/dir').is_empty; # true, false or nil
|
||||
8
Task/Empty-directory/Sidef/empty-directory-2.sidef
Normal file
8
Task/Empty-directory/Sidef/empty-directory-2.sidef
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
func is_empty(dir) {
|
||||
dir.open(\var dir_h) || return nil;
|
||||
dir_h.each { |file|
|
||||
file ~~ ['.', '..'] && next;
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue