June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -7,7 +7,7 @@ extension op
|
|||
= self isAvailable; iif("exists","not found").
|
||||
}
|
||||
|
||||
program =
|
||||
public program =
|
||||
[
|
||||
console printLine("input.txt file ",File new("input.txt"); validatePath).
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
U0 FileExists(U8 *f) {
|
||||
if (FileFind(f) && !IsDir(f)) {
|
||||
Print("'%s' file exists.\n", f);
|
||||
} else {
|
||||
Print("'%s' file does not exist.\n", f);
|
||||
}
|
||||
}
|
||||
|
||||
U0 DirExists(U8 *d) {
|
||||
if (IsDir(d)) {
|
||||
Print("'%s' directory exists.\n", d);
|
||||
} else {
|
||||
Print("'%s' directory does not exist.\n", d);
|
||||
}
|
||||
}
|
||||
|
||||
FileExists("input.txt");
|
||||
FileExists("::/input.txt");
|
||||
DirExists("docs");
|
||||
DirExists("::/docs");
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
isfile("input.txt")
|
||||
isfile("/input.txt")
|
||||
isdir("docs")
|
||||
isdir("/docs")
|
||||
@show isfile("input.txt")
|
||||
@show isfile("/input.txt")
|
||||
@show isdir("docs")
|
||||
@show isdir("/docs")
|
||||
@show isfile("")
|
||||
@show isfile("`Abdu'l-Bahá.txt")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
(if (info "file.txt")
|
||||
(prinl "Size: " (car @) " bytes, last modified " (stamp (cadr @) (cddr @)))
|
||||
(prinl "File doesn't exist") )
|
||||
|
||||
# for directory existing
|
||||
# Nehal-Singhal 2018-05-25
|
||||
|
||||
(if (info "./docs")
|
||||
(print 'exists)
|
||||
(print 'doesNotExist)))
|
||||
|
||||
# To verify if it's really a directory, (CAR of return value will be 'T').
|
||||
# abu 2018-05-25
|
||||
|
||||
(let I (info "./docs")
|
||||
(prinl
|
||||
(nond
|
||||
(I "Does not exist")
|
||||
((=T (car I)) "Is not a directory")
|
||||
(NIL "Directory exists") ) ) )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
exists? %input.txt
|
||||
exists? %docs/
|
||||
exists? %/c/input.txt
|
||||
exists? %/c/docs/
|
||||
exists? %//input.txt
|
||||
exists? %//docs/
|
||||
|
||||
>> exists? %`Abdu'l-Bahá.txt
|
||||
== true
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
confirmdir docs
|
||||
if !r(confirmdir) {
|
||||
if !`r(confirmdir)' {
|
||||
* do something if the directory exists
|
||||
}
|
||||
|
|
|
|||
18
Task/Check-that-file-exists/VBA/check-that-file-exists.vba
Normal file
18
Task/Check-that-file-exists/VBA/check-that-file-exists.vba
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
Option Explicit
|
||||
|
||||
Sub Main_File_Exists()
|
||||
Dim myFile As String, myDirectory As String
|
||||
|
||||
myFile = "Abdu'l-Bahá.txt"
|
||||
myDirectory = "C:\"
|
||||
Debug.Print File_Exists(myFile, myDirectory)
|
||||
End Sub
|
||||
|
||||
Function File_Exists(F As String, D As String) As Boolean
|
||||
If F = "" Then
|
||||
File_Exists = False
|
||||
Else
|
||||
D = IIf(Right(D, 1) = "\", D, D & "\")
|
||||
File_Exists = (Dir(D & F) <> "")
|
||||
End If
|
||||
End Function
|
||||
|
|
@ -1,24 +1,33 @@
|
|||
Set FSO=CreateObject("Scripting.FileSystemObject")
|
||||
Set FSO = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Function FileExists(strFile)
|
||||
if FSO.fileExists(strFile) then
|
||||
FileExists=true
|
||||
else
|
||||
FileExists=false
|
||||
end if
|
||||
end function
|
||||
If FSO.FileExists(strFile) Then
|
||||
FileExists = True
|
||||
Else
|
||||
FileExists = False
|
||||
End If
|
||||
End Function
|
||||
|
||||
Function folderExists(strFolder)
|
||||
if FSO.folderExists(strFolder) then
|
||||
folderExists=true
|
||||
else
|
||||
folderexists=false
|
||||
end if
|
||||
end function
|
||||
Function FolderExists(strFolder)
|
||||
If FSO.FolderExists(strFolder) Then
|
||||
FolderExists = True
|
||||
Else
|
||||
Folderexists = False
|
||||
End If
|
||||
End Function
|
||||
|
||||
'''''usage (apostrophes indicate comments-this section will not be run)'''''
|
||||
'if fileExists("C:\test.txt") then
|
||||
'msgbox"It Exists!"
|
||||
'else
|
||||
'msgbox"awww"
|
||||
'end if
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
'''''Usage (apostrophes indicate comments-this section will not be run)'''''
|
||||
'If FileExists("C:\test.txt") Then
|
||||
' MsgBox "It Exists!"
|
||||
'Else
|
||||
' Msgbox "awww"
|
||||
'End If
|
||||
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
|
||||
|
||||
'Shorter version
|
||||
|
||||
If CreateObject("Scripting.FileSystemObject").FileExists("d:\test.txt") Then
|
||||
Wscript.Echo "File Exists"
|
||||
Else
|
||||
Wscript.Echo "File Does Not Exist")
|
||||
End If
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
'declarations:
|
||||
Public Declare Function GetFileAttributes Lib "kernel32" _
|
||||
Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
|
||||
Public Const INVALID_FILE_ATTRIBUTES As Long = -1
|
||||
Public Const ERROR_SHARING_VIOLATION As Long = 32&
|
||||
|
||||
'implementation:
|
||||
Public Function FileExists(ByVal Filename As String) As Boolean
|
||||
Dim l As Long
|
||||
l = GetFileAttributes(Filename)
|
||||
If l <> INVALID_FILE_ATTRIBUTES Then
|
||||
FileExists = ((l And vbDirectory) = 0)
|
||||
ElseIf Err.LastDllError = ERROR_SHARING_VIOLATION Then
|
||||
FileExists = True
|
||||
End If
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue