This repository has been archived by the owner on Aug 29, 2022. It is now read-only.
forked from Jonathan-LeRoux/IguanaTex
-
Notifications
You must be signed in to change notification settings - Fork 22
/
MacUtil.bas
60 lines (40 loc) · 1.63 KB
/
MacUtil.bas
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
Attribute VB_Name = "MacUtil"
Public Const PathSeperator As String = "/"
Public Function ShellEscape(Str As String) As String
ShellEscape = "'" & Replace(Replace(Str, "\", "\\"), "'", "'\''") & "'"
End Function
Public Function ReadAllBytes(filename As String) As Byte()
Dim fnum As Integer
fnum = FreeFile()
Open filename For Binary Access Read As fnum
Dim length As Long
length = FileLen(filename)
Dim data() As Byte
If length <> 0 Then
ReDim data(length - 1)
Get #fnum, , data
End If
Close #fnum
ReadAllBytes = data
End Function
Public Function ReadAll(filename As String) As String
ReadAll = Utf8ToString(ReadAllBytes(filename))
End Function
Public Function ReadAllExternal(pathname As String) As String
ReadAllExternal = AppleScriptTask("IguanaTex.scpt", "ReadAllExternal", pathname)
End Function
Public Function MacTempPath() As String
MacTempPath = MacScript("POSIX path of (path to temporary items)")
End Function
Public Function MacChooseFileOfType(typeStr As String) As String
MacChooseFileOfType = AppleScriptTask("IguanaTex.scpt", "MacChooseFileOfType", typeStr)
End Function
Public Function MacChooseApp(defaultValue As String) As String
MacChooseApp = AppleScriptTask("IguanaTex.scpt", "MacChooseApp", defaultValue)
End Function
Public Function MacChooseFile(defaultValue As String) As String
MacChooseFile = AppleScriptTask("IguanaTex.scpt", "MacChooseFile", defaultValue)
End Function
Public Function MacChooseFolder(defaultValue As String) As String
MacChooseFolder = AppleScriptTask("IguanaTex.scpt", "MacChooseFolder", defaultValue)
End Function