author | Claus Gittinger <cg@exept.de> |
Fri, 14 Oct 2016 03:21:23 +0200 | |
changeset 20639 | 3bf77812174f |
parent 20637 | a9b41f05ca91 |
child 20642 | 56c52db3521a |
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" |
16644 | 77 |
|
20637 | 78 |
|path executablePath executableDir packagesDir |
79 |
libDir appDir versionsDir vsnDirName vsnDir| |
|
16644 | 80 |
|
81 |
path := super defaultPackagePath. |
|
82 |
||
83 |
executablePath := OperatingSystem pathOfSTXExecutable. |
|
84 |
executablePath notNil ifTrue:[ |
|
20637 | 85 |
executableDir := executablePath asFilename directory. |
86 |
packagesDir := executableDir directory directory / 'Packages'. |
|
87 |
packagesDir exists ifTrue:[ |
|
20639 | 88 |
packagesDir := packagesDir pathName. |
89 |
(path includes:packagesDir) ifFalse:[ |
|
90 |
path add:packagesDir. |
|
91 |
]. |
|
20637 | 92 |
]. |
93 |
libDir := '/Library/Frameworks/SmalltalkX.framework' asFilename. |
|
94 |
libDir exists ifTrue:[ |
|
95 |
versionsDir := libDir / 'Versions'. |
|
96 |
versionsDir exists ifTrue:[ |
|
97 |
vsnDirName := '%1.%2.%3' |
|
98 |
bindWith:Smalltalk majorVersionNr |
|
99 |
with:Smalltalk minorVersionNr |
|
100 |
with:Smalltalk revisionNr. |
|
101 |
vsnDir := versionsDir / vsnDirName. |
|
102 |
vsnDir exists ifTrue:[ |
|
20639 | 103 |
vsnDir := vsnDir pathName. |
104 |
(path includes:vsnDir) ifFalse:[ |
|
105 |
path add:vsnDir. |
|
106 |
]. |
|
20637 | 107 |
]. |
108 |
]. |
|
109 |
]. |
|
110 |
appDir := '/Applications/SmalltalkX/' asFilename. |
|
111 |
appDir exists ifTrue:[ |
|
112 |
versionsDir := appDir / 'Versions'. |
|
113 |
versionsDir exists ifTrue:[ |
|
114 |
vsnDirName := '%1.%2.%3' |
|
115 |
bindWith:Smalltalk majorVersionNr |
|
116 |
with:Smalltalk minorVersionNr |
|
117 |
with:Smalltalk revisionNr. |
|
118 |
vsnDir := versionsDir / vsnDirName. |
|
119 |
vsnDir exists ifTrue:[ |
|
20639 | 120 |
vsnDir := vsnDir pathName. |
121 |
(path includes:vsnDir) ifFalse:[ |
|
122 |
path add:vsnDir. |
|
123 |
]. |
|
20637 | 124 |
]. |
125 |
]. |
|
126 |
]. |
|
16644 | 127 |
]. |
16647 | 128 |
^ path |
16644 | 129 |
! |
130 |
||
16677 | 131 |
getDriveList |
132 |
"return a list of volumes in the system." |
|
133 |
||
134 |
^ ('/Volumes' asFilename directoryContents) |
|
135 |
, super getDriveList |
|
136 |
! |
|
137 |
||
16381 | 138 |
getTrashDirectory |
139 |
"get the name of a trash folder (if the OS supports it), |
|
140 |
or nil, if not. |
|
141 |
Must be redefined to return non nil in concrete operating systems" |
|
142 |
||
143 |
^ '~/.Trash' |
|
16677 | 144 |
! |
145 |
||
146 |
pathNameForDrive:driveName |
|
147 |
"given a drive name, return the pathname to open it as a directory. |
|
148 |
For Windows, this is the driveName itself. |
|
149 |
For OSX, '/Volumes' is prepended. |
|
150 |
Other OSs might prepent the pount point (i.e. /mnt/)" |
|
151 |
||
16905 | 152 |
driveName isNil ifTrue:[^ nil]. |
16677 | 153 |
driveName asFilename isAbsolute ifTrue:[^ driveName]. |
154 |
^ '/Volumes/',driveName |
|
17177 | 155 |
! |
156 |
||
157 |
supportsVolumes |
|
18279 | 158 |
"return true if the os support a list of drives/volumes |
17179 | 159 |
(here we can return a list of mounted drives in /Volumes)" |
17177 | 160 |
|
161 |
^ true |
|
14819 | 162 |
! ! |
163 |
||
164 |
!OSXOperatingSystem class methodsFor:'documentation'! |
|
165 |
||
166 |
version |
|
19817 | 167 |
^ '$Header$' |
14819 | 168 |
! |
169 |
||
170 |
version_CVS |
|
19817 | 171 |
^ '$Header$' |
14819 | 172 |
! ! |
19817 | 173 |