author | Jan Vrany <jan.vrany@labware.com> |
Sat, 29 Oct 2022 01:05:05 +0100 | |
branch | jv |
changeset 25446 | 98fb817db6de |
parent 20642 | 56c52db3521a |
child 21452 | 3435141db80f |
permissions | -rw-r--r-- |
17471 | 1 |
"{ Package: 'stx:libbasic' }" |
2 |
||
3 |
"{ NameSpace: Smalltalk }" |
|
14819 | 4 |
|
17471 | 5 |
UnixOperatingSystem subclass:#OSXOperatingSystem |
6 |
instanceVariableNames:'' |
|
7 |
classVariableNames:'' |
|
8 |
poolDictionaries:'' |
|
9 |
category:'OS-Unix' |
|
10 |
! |
|
11 |
||
12 |
||
13 |
!OSXOperatingSystem class methodsFor:'initialization'! |
|
14 |
||
15 |
initializeCodeset |
|
16 |
super initializeCodeset. |
|
17493 | 17 |
Codeset := #'utf8-mac'. |
17494 | 18 |
CodesetEncoder := nil. |
17471 | 19 |
! ! |
14819 | 20 |
|
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
21 |
!OSXOperatingSystem class methodsFor:'dummy shell operations'! |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
22 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
23 |
openApplicationHelperCommand |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
24 |
"Return a command line helper to open a default application for file or URL" |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
25 |
|
18279 | 26 |
(self canExecuteCommand: 'open') ifTrue:[ |
27 |
^ 'open' |
|
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
28 |
]. |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
29 |
^ nil |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
30 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
31 |
"Created: / 13-01-2015 / 09:23:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17427 | 32 |
! |
33 |
||
17428 | 34 |
openTerminalWithCommand:shellCommand inBackground:inBackground |
17427 | 35 |
"open a new terminal, which executes a command" |
36 |
||
17428 | 37 |
|cmd| |
38 |
||
39 |
cmd := 'osascript -e ''tell application "Terminal" to do script "%1"''' bindWith:shellCommand. |
|
40 |
||
41 |
inBackground ifTrue:[ |
|
18279 | 42 |
^ self |
43 |
startProcess:cmd |
|
44 |
inputFrom:nil |
|
45 |
outputTo:nil |
|
46 |
errorTo:nil |
|
47 |
auxFrom:nil |
|
48 |
environment:nil |
|
49 |
inDirectory:nil |
|
17428 | 50 |
] ifFalse:[ |
18279 | 51 |
^ self executeCommand:cmd |
17428 | 52 |
]. |
17427 | 53 |
|
54 |
" |
|
17428 | 55 |
OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true |
17427 | 56 |
" |
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
57 |
! ! |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
58 |
|
14819 | 59 |
!OSXOperatingSystem class methodsFor:'file queries'! |
60 |
||
61 |
caseSensitiveFilenames |
|
62 |
"return true, if the OS has caseSensitive file naming. |
|
63 |
On MSDOS, this will return false; |
|
19817 | 64 |
on a real OS, we return true. |
65 |
Be aware, that OSX can be configured to be either. |
|
66 |
Also, that it actually depends on the mounted volume" |
|
14819 | 67 |
|
18279 | 68 |
"/ actually, this is wrong and depends on the mounted volume; |
69 |
"/ so we need a query for a particular directory (and/or volume). |
|
14819 | 70 |
^ false |
71 |
||
72 |
"Modified: / 5.6.1998 / 18:35:18 / cg" |
|
16381 | 73 |
! |
74 |
||
16644 | 75 |
defaultPackagePath |
20639 | 76 |
"redefined to add /Application and /Library stuff" |
20642 | 77 |
"called by Smalltalk initSystemPath" |
78 |
"self defaultPackagePath" |
|
16644 | 79 |
|
20637 | 80 |
|path executablePath executableDir packagesDir |
81 |
libDir appDir versionsDir vsnDirName vsnDir| |
|
16644 | 82 |
|
83 |
path := super defaultPackagePath. |
|
84 |
||
85 |
executablePath := OperatingSystem pathOfSTXExecutable. |
|
86 |
executablePath notNil ifTrue:[ |
|
20637 | 87 |
executableDir := executablePath asFilename directory. |
88 |
packagesDir := executableDir directory directory / 'Packages'. |
|
89 |
packagesDir exists ifTrue:[ |
|
20639 | 90 |
packagesDir := packagesDir pathName. |
91 |
(path includes:packagesDir) ifFalse:[ |
|
92 |
path add:packagesDir. |
|
93 |
]. |
|
20637 | 94 |
]. |
95 |
libDir := '/Library/Frameworks/SmalltalkX.framework' asFilename. |
|
96 |
libDir exists ifTrue:[ |
|
97 |
versionsDir := libDir / 'Versions'. |
|
98 |
versionsDir exists ifTrue:[ |
|
99 |
vsnDirName := '%1.%2.%3' |
|
100 |
bindWith:Smalltalk majorVersionNr |
|
101 |
with:Smalltalk minorVersionNr |
|
102 |
with:Smalltalk revisionNr. |
|
103 |
vsnDir := versionsDir / vsnDirName. |
|
104 |
vsnDir exists ifTrue:[ |
|
20639 | 105 |
vsnDir := vsnDir pathName. |
106 |
(path includes:vsnDir) ifFalse:[ |
|
107 |
path add:vsnDir. |
|
108 |
]. |
|
20637 | 109 |
]. |
110 |
]. |
|
111 |
]. |
|
112 |
appDir := '/Applications/SmalltalkX/' asFilename. |
|
113 |
appDir exists ifTrue:[ |
|
114 |
versionsDir := appDir / 'Versions'. |
|
115 |
versionsDir exists ifTrue:[ |
|
116 |
vsnDirName := '%1.%2.%3' |
|
117 |
bindWith:Smalltalk majorVersionNr |
|
118 |
with:Smalltalk minorVersionNr |
|
119 |
with:Smalltalk revisionNr. |
|
120 |
vsnDir := versionsDir / vsnDirName. |
|
121 |
vsnDir exists ifTrue:[ |
|
20639 | 122 |
vsnDir := vsnDir pathName. |
123 |
(path includes:vsnDir) ifFalse:[ |
|
124 |
path add:vsnDir. |
|
125 |
]. |
|
20637 | 126 |
]. |
127 |
]. |
|
128 |
]. |
|
16644 | 129 |
]. |
16647 | 130 |
^ path |
16644 | 131 |
! |
132 |
||
16677 | 133 |
getDriveList |
134 |
"return a list of volumes in the system." |
|
135 |
||
136 |
^ ('/Volumes' asFilename directoryContents) |
|
137 |
, super getDriveList |
|
138 |
! |
|
139 |
||
16381 | 140 |
getTrashDirectory |
141 |
"get the name of a trash folder (if the OS supports it), |
|
142 |
or nil, if not. |
|
143 |
Must be redefined to return non nil in concrete operating systems" |
|
144 |
||
145 |
^ '~/.Trash' |
|
16677 | 146 |
! |
147 |
||
148 |
pathNameForDrive:driveName |
|
149 |
"given a drive name, return the pathname to open it as a directory. |
|
150 |
For Windows, this is the driveName itself. |
|
151 |
For OSX, '/Volumes' is prepended. |
|
152 |
Other OSs might prepent the pount point (i.e. /mnt/)" |
|
153 |
||
16905 | 154 |
driveName isNil ifTrue:[^ nil]. |
16677 | 155 |
driveName asFilename isAbsolute ifTrue:[^ driveName]. |
156 |
^ '/Volumes/',driveName |
|
17177 | 157 |
! |
158 |
||
159 |
supportsVolumes |
|
18279 | 160 |
"return true if the os support a list of drives/volumes |
17179 | 161 |
(here we can return a list of mounted drives in /Volumes)" |
17177 | 162 |
|
163 |
^ true |
|
14819 | 164 |
! ! |
165 |
||
166 |
!OSXOperatingSystem class methodsFor:'documentation'! |
|
167 |
||
168 |
version |
|
19817 | 169 |
^ '$Header$' |
14819 | 170 |
! |
171 |
||
172 |
version_CVS |
|
19817 | 173 |
^ '$Header$' |
14819 | 174 |
! ! |
19817 | 175 |