author | Stefan Vogel <sv@exept.de> |
Thu, 16 Apr 2015 18:28:45 +0200 | |
branch | expecco_2_7_5 |
changeset 18220 | 361e98951d47 |
parent 17471 | 98c49f19bae1 |
child 17493 | 25361a7bc7e7 |
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. |
|
17 |
Codeset := #utf8. |
|
18 |
! ! |
|
14819 | 19 |
|
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
20 |
!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
|
21 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
22 |
openApplicationHelperCommand |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
23 |
"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
|
24 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
25 |
(self canExecuteCommand: 'open') ifTrue:[ |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
26 |
^ 'open' |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
27 |
]. |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
28 |
^ nil |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
29 |
|
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
30 |
"Created: / 13-01-2015 / 09:23:18 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17427 | 31 |
! |
32 |
||
17428 | 33 |
openTerminalWithCommand:shellCommand inBackground:inBackground |
17427 | 34 |
"open a new terminal, which executes a command" |
35 |
||
17428 | 36 |
|cmd| |
37 |
||
38 |
cmd := 'osascript -e ''tell application "Terminal" to do script "%1"''' bindWith:shellCommand. |
|
39 |
||
40 |
inBackground ifTrue:[ |
|
41 |
^ self |
|
42 |
startProcess:cmd |
|
43 |
inputFrom:nil |
|
44 |
outputTo:nil |
|
45 |
errorTo:nil |
|
46 |
auxFrom:nil |
|
47 |
environment:nil |
|
48 |
inDirectory:nil |
|
49 |
] ifFalse:[ |
|
50 |
^ self executeCommand:cmd |
|
51 |
]. |
|
17427 | 52 |
|
53 |
" |
|
17428 | 54 |
OSXOperatingSystem openTerminalWithCommand:'ls -l' inBackground:true |
17427 | 55 |
" |
17297
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
56 |
! ! |
a56ba300949c
Overriden openApplicationForDocument... to use desktop-specific "open" command.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17179
diff
changeset
|
57 |
|
14819 | 58 |
!OSXOperatingSystem class methodsFor:'file queries'! |
59 |
||
60 |
caseSensitiveFilenames |
|
61 |
"return true, if the OS has caseSensitive file naming. |
|
62 |
On MSDOS, this will return false; |
|
63 |
on a real OS, we return true." |
|
64 |
||
65 |
^ false |
|
66 |
||
67 |
"Modified: / 5.6.1998 / 18:35:18 / cg" |
|
16381 | 68 |
! |
69 |
||
16644 | 70 |
defaultPackagePath |
71 |
"redefined to add stx.app packages and /Library stuff" |
|
72 |
||
73 |
|path executablePath executableDir packagesDir libDir vsnDirName vsnDir| |
|
74 |
||
75 |
path := super defaultPackagePath. |
|
76 |
||
77 |
executablePath := OperatingSystem pathOfSTXExecutable. |
|
78 |
executablePath notNil ifTrue:[ |
|
79 |
executableDir := executablePath asFilename directory. |
|
80 |
packagesDir := executableDir directory directory / 'Packages'. |
|
81 |
packagesDir exists ifTrue:[ |
|
82 |
path add:packagesDir. |
|
83 |
]. |
|
84 |
libDir := '/Library/Smalltalk-x' asFilename. |
|
85 |
libDir exists ifTrue:[ |
|
86 |
vsnDirName := '%1.%2' bindWith:Smalltalk majorVersionNr |
|
87 |
with:Smalltalk minorVersionNr. |
|
88 |
vsnDir := libDir / vsnDirName. |
|
89 |
vsnDir exists ifTrue:[ |
|
90 |
path add:vsnDir. |
|
91 |
]. |
|
92 |
]. |
|
93 |
]. |
|
16647 | 94 |
^ path |
16644 | 95 |
! |
96 |
||
16677 | 97 |
getDriveList |
98 |
"return a list of volumes in the system." |
|
99 |
||
100 |
^ ('/Volumes' asFilename directoryContents) |
|
101 |
, super getDriveList |
|
102 |
! |
|
103 |
||
16381 | 104 |
getTrashDirectory |
105 |
"get the name of a trash folder (if the OS supports it), |
|
106 |
or nil, if not. |
|
107 |
Must be redefined to return non nil in concrete operating systems" |
|
108 |
||
109 |
^ '~/.Trash' |
|
16677 | 110 |
! |
111 |
||
112 |
pathNameForDrive:driveName |
|
113 |
"given a drive name, return the pathname to open it as a directory. |
|
114 |
For Windows, this is the driveName itself. |
|
115 |
For OSX, '/Volumes' is prepended. |
|
116 |
Other OSs might prepent the pount point (i.e. /mnt/)" |
|
117 |
||
16905 | 118 |
driveName isNil ifTrue:[^ nil]. |
16677 | 119 |
driveName asFilename isAbsolute ifTrue:[^ driveName]. |
120 |
^ '/Volumes/',driveName |
|
17177 | 121 |
! |
122 |
||
123 |
supportsVolumes |
|
17179 | 124 |
"return true if the os support a list of drives/volumes |
125 |
(here we can return a list of mounted drives in /Volumes)" |
|
17177 | 126 |
|
127 |
^ true |
|
14819 | 128 |
! ! |
129 |
||
130 |
!OSXOperatingSystem class methodsFor:'documentation'! |
|
131 |
||
132 |
version |
|
17471 | 133 |
^ '$Header: /cvs/stx/stx/libbasic/OSXOperatingSystem.st,v 1.14 2015-02-16 09:06:55 cg Exp $' |
14819 | 134 |
! |
135 |
||
136 |
version_CVS |
|
17471 | 137 |
^ '$Header: /cvs/stx/stx/libbasic/OSXOperatingSystem.st,v 1.14 2015-02-16 09:06:55 cg Exp $' |
14819 | 138 |
! ! |
139 |