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,5 @@
|
|||
If GetCalc("appvINPUT")
|
||||
Disp "EXISTS",i
|
||||
Else
|
||||
Disp "DOES NOT EXIST",i
|
||||
End
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
' Enable FileExists() function to be used
|
||||
#include "file.bi"
|
||||
|
||||
' Use Win32 function to check if directory exists on Windows 10
|
||||
Declare Function GetFileAttributes Lib "kernel32.dll" Alias "GetFileAttributesA" _
|
||||
(ByVal lpFileName As ZString Ptr) As ULong
|
||||
|
||||
Const InvalidFileAttributes As ULong = -1UL
|
||||
Const FileAttributeDirectory As ULong = &H10UL
|
||||
|
||||
Sub CheckFileExists(ByRef filePath As String)
|
||||
If FileExists(filePath) Then
|
||||
Print "'"; filePath; "' exists"
|
||||
Else
|
||||
Print "'"; filePath; "' does not exist"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub CheckDirectoryExists(ByVal dirPath As ZString Ptr)
|
||||
Dim attrib As ULong = GetFileAttributes(dirPath)
|
||||
Dim dirExists As ULong = attrib <> InvalidFileAttributes AndAlso (attrib And FileAttributeDirectory) <> 0
|
||||
If dirExists Then
|
||||
Print "'"; *dirPath; "' exists"
|
||||
Else
|
||||
Print "'"; *dirPath; "' does not exist"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
CheckFileExists(CurDir + "\input.txt")
|
||||
Dim dirPath As String = CurDir + "\docs"
|
||||
CheckDirectoryExists(StrPtr(dirPath))
|
||||
CheckFileExists("c:\input.txt")
|
||||
CheckDirectoryExists(StrPtr("c:\docs"))
|
||||
Print
|
||||
Print "Press any key to quit the program"
|
||||
Sleep
|
||||
16
Task/Check-that-file-exists/I/check-that-file-exists.i
Normal file
16
Task/Check-that-file-exists/I/check-that-file-exists.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
function exists(""filename) {
|
||||
var file = open(filename)
|
||||
issues {
|
||||
print(filename+" does not exist")
|
||||
return
|
||||
}
|
||||
print(filename+" exists")
|
||||
close(file)
|
||||
}
|
||||
|
||||
software {
|
||||
exists("input.txt")
|
||||
exists("/input.txt")
|
||||
exists("docs")
|
||||
exists("/docs")
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
> (: filelib is_regular '"input.txt")
|
||||
false
|
||||
> (: filelib is_dir '"docs")
|
||||
false
|
||||
> (: filelib is_regular '"/input.txt")
|
||||
false
|
||||
> (: filelib is_dir '"/docs"))
|
||||
false
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
// local file
|
||||
file_exists('input.txt')
|
||||
|
||||
// local directory
|
||||
file_exists('docs')
|
||||
|
||||
// file in root file system (requires permissions at user OS level)
|
||||
file_exists('//input.txt')
|
||||
|
||||
// directory in root file system (requires permissions at user OS level)
|
||||
file_exists('//docs')
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
there is a file "/input.txt"
|
||||
there is a file "input.txt"
|
||||
there is a folder "docs"
|
||||
there is a file "/docs/input.txt"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
set the defaultFolder to "docs"
|
||||
there is a file "input.txt"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
import os
|
||||
|
||||
echo existsFile "input.txt"
|
||||
echo existsFile "/input.txt"
|
||||
echo existsDir "docs"
|
||||
echo existsDir "/docs"
|
||||
18
Task/Check-that-file-exists/Phix/check-that-file-exists.phix
Normal file
18
Task/Check-that-file-exists/Phix/check-that-file-exists.phix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
constant fd = {"file","directory"}
|
||||
|
||||
procedure check(string name)
|
||||
object d = dir(name)
|
||||
if sequence(d) then
|
||||
d = (find('d',d[1][D_ATTRIBUTES])!=0)
|
||||
printf(1,"%s %s exists.\n",{fd[1+d],name})
|
||||
else
|
||||
printf(1,"%s does not exist.\n",{name})
|
||||
end if
|
||||
end procedure
|
||||
|
||||
check("input.txt")
|
||||
check("docs")
|
||||
check("/input.txt")
|
||||
check("/docs")
|
||||
check("/pagefile.sys")
|
||||
check("/Program Files (x86)")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
aFile = "C:\Ring\ReadMe.txt"
|
||||
see aFile
|
||||
if Fexists(aFile) see " exists" + nl
|
||||
else see " doesn't exist" + nl ok
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# Here
|
||||
say (Dir.cwd + %f'input.txt' -> is_file);
|
||||
say (Dir.cwd + %d'docs' -> is_dir);
|
||||
|
||||
# Root
|
||||
say (Dir.root + %f'input.txt' -> is_file);
|
||||
say (Dir.root + %d'docs' -> is_dir);
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
def exists (string filename)
|
||||
decl file f
|
||||
try
|
||||
f.open filename
|
||||
return true
|
||||
catch ioerror
|
||||
return false
|
||||
end try
|
||||
end exists
|
||||
Loading…
Add table
Add a link
Reference in a new issue