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
|
||||
Loading…
Add table
Add a link
Reference in a new issue