forked from Jonathan-LeRoux/IguanaTex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MacFileSystemObject.cls
60 lines (53 loc) · 1.44 KB
/
MacFileSystemObject.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "MacFileSystemObject"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' Partial replacement (in Mac) for Scripting.FileSystemObject
Option Explicit
#If Mac Then
Public Function FileExists(pathname As String) As Boolean
FileExists = (Dir(pathname) <> "")
End Function
Public Function FolderExists(pathname As String) As Boolean
FolderExists = (Dir(pathname) <> "")
End Function
Public Sub CreateFolder(pathname As String)
MkDir pathname
End Sub
'Public Sub CopyFile(pathfrom As String, pathto As String)
'#If Mac Then
' cp pathfrom pathto
'#Else
' fs.CopyFile pathfrom, pathto
'#End If
'End Sub
' calls `find <dirname> -name <pattern> -delete`
Public Sub FindDelete(dirname As String, pattern As String)
AppleScriptTask "IguanaTex.scpt", "MacExecute", "find " & ShellEscape(dirname) & " -name " & ShellEscape(pattern) & " -delete"
End Sub
' does not support path globbing. use `FindDelete` instead.
Public Sub DeleteFile(pathname As String)
If FileExists(pathname) Then
' remove readonly attribute if set
SetAttr pathname, vbNormal
Kill pathname
End If
End Sub
#End If
'
'Private Sub Class_Initialize()
'#If Mac Then
' '
'#Else
' Dim fs As New Scripting.FileSystemObject
'#End If
'End Sub
'
'Private Sub Class_Terminate()
' Set fs = Nothing
'End Sub