author | Claus Gittinger <cg@exept.de> |
Sat, 06 Jun 2015 14:42:18 +0200 | |
changeset 18452 | 5724547da8de |
parent 18279 | 6d7174763909 |
child 19817 | b2aaa648f81d |
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; |
|
64 |
on a real OS, we return true." |
|
65 |
||
18279 | 66 |
"/ actually, this is wrong and depends on the mounted volume; |
67 |
"/ so we need a query for a particular directory (and/or volume). |
|
14819 | 68 |
^ false |
69 |
||
70 |
"Modified: / 5.6.1998 / 18:35:18 / cg" |
|
16381 | 71 |
! |
72 |
||
16644 | 73 |
defaultPackagePath |
74 |
"redefined to add stx.app packages and /Library stuff" |
|
75 |
||
76 |
|path executablePath executableDir packagesDir libDir vsnDirName vsnDir| |
|
77 |
||
78 |
path := super defaultPackagePath. |
|
79 |
||
80 |
executablePath := OperatingSystem pathOfSTXExecutable. |
|
81 |
executablePath notNil ifTrue:[ |
|
18279 | 82 |
executableDir := executablePath asFilename directory. |
83 |
packagesDir := executableDir directory directory / 'Packages'. |
|
84 |
packagesDir exists ifTrue:[ |
|
85 |
path add:packagesDir. |
|
86 |
]. |
|
87 |
libDir := '/Library/Smalltalk-x' asFilename. |
|
88 |
libDir exists ifTrue:[ |
|
89 |
vsnDirName := '%1.%2' bindWith:Smalltalk majorVersionNr |
|
90 |
with:Smalltalk minorVersionNr. |
|
91 |
vsnDir := libDir / vsnDirName. |
|
92 |
vsnDir exists ifTrue:[ |
|
93 |
path add:vsnDir. |
|
94 |
]. |
|
95 |
]. |
|
16644 | 96 |
]. |
16647 | 97 |
^ path |
16644 | 98 |
! |
99 |
||
16677 | 100 |
getDriveList |
101 |
"return a list of volumes in the system." |
|
102 |
||
103 |
^ ('/Volumes' asFilename directoryContents) |
|
104 |
, super getDriveList |
|
105 |
! |
|
106 |
||
16381 | 107 |
getTrashDirectory |
108 |
"get the name of a trash folder (if the OS supports it), |
|
109 |
or nil, if not. |
|
110 |
Must be redefined to return non nil in concrete operating systems" |
|
111 |
||
112 |
^ '~/.Trash' |
|
16677 | 113 |
! |
114 |
||
115 |
pathNameForDrive:driveName |
|
116 |
"given a drive name, return the pathname to open it as a directory. |
|
117 |
For Windows, this is the driveName itself. |
|
118 |
For OSX, '/Volumes' is prepended. |
|
119 |
Other OSs might prepent the pount point (i.e. /mnt/)" |
|
120 |
||
16905 | 121 |
driveName isNil ifTrue:[^ nil]. |
16677 | 122 |
driveName asFilename isAbsolute ifTrue:[^ driveName]. |
123 |
^ '/Volumes/',driveName |
|
17177 | 124 |
! |
125 |
||
126 |
supportsVolumes |
|
18279 | 127 |
"return true if the os support a list of drives/volumes |
17179 | 128 |
(here we can return a list of mounted drives in /Volumes)" |
17177 | 129 |
|
130 |
^ true |
|
14819 | 131 |
! ! |
132 |
||
133 |
!OSXOperatingSystem class methodsFor:'documentation'! |
|
134 |
||
135 |
version |
|
18279 | 136 |
^ '$Header: /cvs/stx/stx/libbasic/OSXOperatingSystem.st,v 1.17 2015-04-24 08:18:41 cg Exp $' |
14819 | 137 |
! |
138 |
||
139 |
version_CVS |
|
18279 | 140 |
^ '$Header: /cvs/stx/stx/libbasic/OSXOperatingSystem.st,v 1.17 2015-04-24 08:18:41 cg Exp $' |
14819 | 141 |
! ! |