changeset 17637 | e88d00519209 |
parent 17580 | e7f4e453fa96 |
child 17638 | a2feeffaea64 |
17636:b1f2d32a9931 | 17637:e88d00519209 |
---|---|
230 initialize |
230 initialize |
231 "initialize the class" |
231 "initialize the class" |
232 |
232 |
233 "/ protect against double initialization |
233 "/ protect against double initialization |
234 ErrorSignal isNil ifTrue:[ |
234 ErrorSignal isNil ifTrue:[ |
235 self initializeConcreteClass. |
235 self initializeConcreteClass. |
236 |
236 |
237 OSErrorHolder initialize. |
237 OSErrorHolder initialize. |
238 ErrorSignal := OsError. |
238 ErrorSignal := OsError. |
239 InvalidArgumentsSignal := OsInvalidArgumentsError. |
239 InvalidArgumentsSignal := OsInvalidArgumentsError. |
240 AccessDeniedErrorSignal := OSErrorHolder noPermissionsSignal. |
240 AccessDeniedErrorSignal := OSErrorHolder noPermissionsSignal. |
241 FileNotFoundErrorSignal := OSErrorHolder nonexistentSignal. |
241 FileNotFoundErrorSignal := OSErrorHolder nonexistentSignal. |
242 UnsupportedOperationSignal := OSErrorHolder unsupportedOperationSignal. |
242 UnsupportedOperationSignal := OSErrorHolder unsupportedOperationSignal. |
243 Smalltalk addDependent:self. "/ to catch language changes |
243 Smalltalk addDependent:self. "/ to catch language changes |
244 ]. |
244 ]. |
245 ! |
245 ! |
246 |
246 |
247 initializeConcreteClass |
247 initializeConcreteClass |
248 OperatingSystem := ConcreteClass := self getConcreteClass. |
248 OperatingSystem := ConcreteClass := self getConcreteClass. |
1092 and the other elements are the arguments to the command. No shell is invoked in this case. |
1092 and the other elements are the arguments to the command. No shell is invoked in this case. |
1093 Blocks until the command has finished. |
1093 Blocks until the command has finished. |
1094 Return true if successful, false otherwise." |
1094 Return true if successful, false otherwise." |
1095 |
1095 |
1096 ^ self |
1096 ^ self |
1097 executeCommand:aCommandString |
1097 executeCommand:aCommandString |
1098 inputFrom:nil |
1098 inputFrom:nil |
1099 outputTo:nil |
1099 outputTo:nil |
1100 errorTo:nil |
1100 errorTo:nil |
1101 auxFrom:nil |
1101 auxFrom:nil |
1102 environment:nil |
1102 environment:nil |
1103 inDirectory:nil |
1103 inDirectory:nil |
1104 lineWise:false |
1104 lineWise:false |
1105 onError:[:status| false] |
1105 onError:[:status| false] |
1106 |
1106 |
1107 "unix: |
1107 "unix: |
1108 |
1108 |
1109 OperatingSystem executeCommand:'sleep 30'. |
1109 OperatingSystem executeCommand:'sleep 30'. |
1110 OperatingSystem executeCommand:'pwd'. |
1110 OperatingSystem executeCommand:'pwd'. |
1137 If aCommandString is an Array, the first element is the command to be executed, |
1137 If aCommandString is an Array, the first element is the command to be executed, |
1138 and the other elements are the arguments to the command. No shell is invoked in this case. |
1138 and the other elements are the arguments to the command. No shell is invoked in this case. |
1139 Return true if successful, false otherwise." |
1139 Return true if successful, false otherwise." |
1140 |
1140 |
1141 ^ self |
1141 ^ self |
1142 executeCommand:aCommandString |
1142 executeCommand:aCommandString |
1143 inputFrom:nil |
1143 inputFrom:nil |
1144 outputTo:nil |
1144 outputTo:nil |
1145 errorTo:errorStream |
1145 errorTo:errorStream |
1146 auxFrom:nil |
1146 auxFrom:nil |
1147 environment:nil |
1147 environment:nil |
1148 inDirectory:nil |
1148 inDirectory:nil |
1149 lineWise:false |
1149 lineWise:false |
1150 onError:[:status| false] |
1150 onError:[:status| false] |
1151 |
1151 |
1152 "unix: |
1152 "unix: |
1153 |
1153 |
1154 OperatingSystem executeCommand:'ls -l' errorTo:Transcript. |
1154 OperatingSystem executeCommand:'ls -l' errorTo:Transcript. |
1155 OperatingSystem executeCommand:'invalidCommand' errorTo:Transcript. |
1155 OperatingSystem executeCommand:'invalidCommand' errorTo:Transcript. |
1164 If aCommandString is an Array, the first element is the command to be executed, |
1164 If aCommandString is an Array, the first element is the command to be executed, |
1165 and the other elements are the arguments to the command. No shell is invoked in this case. |
1165 and the other elements are the arguments to the command. No shell is invoked in this case. |
1166 Return true if successful, false otherwise." |
1166 Return true if successful, false otherwise." |
1167 |
1167 |
1168 ^ self |
1168 ^ self |
1169 executeCommand:aCommandString |
1169 executeCommand:aCommandString |
1170 inputFrom:nil |
1170 inputFrom:nil |
1171 outputTo:nil |
1171 outputTo:nil |
1172 errorTo:errorStream |
1172 errorTo:errorStream |
1173 auxFrom:nil |
1173 auxFrom:nil |
1174 environment:nil |
1174 environment:nil |
1175 inDirectory:aDirectory |
1175 inDirectory:aDirectory |
1176 lineWise:false |
1176 lineWise:false |
1177 onError:[:status| false] |
1177 onError:[:status| false] |
1178 |
1178 |
1179 "unix: |
1179 "unix: |
1180 |
1180 |
1181 OperatingSystem executeCommand:'ls -l' errorTo:Transcript. |
1181 OperatingSystem executeCommand:'ls -l' errorTo:Transcript. |
1182 OperatingSystem executeCommand:'invalidCommand' errorTo:Transcript. |
1182 OperatingSystem executeCommand:'invalidCommand' errorTo:Transcript. |
1193 If aCommandString is an Array, the first element is the command to be executed, |
1193 If aCommandString is an Array, the first element is the command to be executed, |
1194 and the other elements are the arguments to the command. No shell is invoked in this case. |
1194 and the other elements are the arguments to the command. No shell is invoked in this case. |
1195 Return true if successful, false otherwise." |
1195 Return true if successful, false otherwise." |
1196 |
1196 |
1197 ^ self |
1197 ^ self |
1198 executeCommand:aCommandString |
1198 executeCommand:aCommandString |
1199 inputFrom:nil |
1199 inputFrom:nil |
1200 outputTo:nil |
1200 outputTo:nil |
1201 errorTo:nil |
1201 errorTo:nil |
1202 auxFrom:nil |
1202 auxFrom:nil |
1203 environment:nil |
1203 environment:nil |
1204 inDirectory:aDirectory |
1204 inDirectory:aDirectory |
1205 lineWise:false |
1205 lineWise:false |
1206 onError:[:exitStatus| false] |
1206 onError:[:exitStatus| false] |
1207 |
1207 |
1208 "Modified: / 10.11.1998 / 20:54:37 / cg" |
1208 "Modified: / 10.11.1998 / 20:54:37 / cg" |
1209 ! |
1209 ! |
1210 |
1210 |
1211 executeCommand:aCommandString inDirectory:aDirectory onError:aBlock |
1211 executeCommand:aCommandString inDirectory:aDirectory onError:aBlock |
1217 Return true if successful, the value from aBlock if not. |
1217 Return true if successful, the value from aBlock if not. |
1218 If not successfull, aBlock is called with an OsProcessStatus |
1218 If not successfull, aBlock is called with an OsProcessStatus |
1219 (containing the exit status) as argument." |
1219 (containing the exit status) as argument." |
1220 |
1220 |
1221 ^ self |
1221 ^ self |
1222 executeCommand:aCommandString |
1222 executeCommand:aCommandString |
1223 inputFrom:nil |
1223 inputFrom:nil |
1224 outputTo:nil |
1224 outputTo:nil |
1225 errorTo:nil |
1225 errorTo:nil |
1226 auxFrom:nil |
1226 auxFrom:nil |
1227 environment:nil |
1227 environment:nil |
1228 inDirectory:aDirectory |
1228 inDirectory:aDirectory |
1229 lineWise:false |
1229 lineWise:false |
1230 onError:aBlock |
1230 onError:aBlock |
1231 |
1231 |
1232 "Modified: / 10.11.1998 / 20:54:37 / cg" |
1232 "Modified: / 10.11.1998 / 20:54:37 / cg" |
1233 ! |
1233 ! |
1234 |
1234 |
1235 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream |
1235 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream |
1239 If aCommandString is an Array, the first element is the command to be executed, |
1239 If aCommandString is an Array, the first element is the command to be executed, |
1240 and the other elements are the arguments to the command. No shell is invoked in this case. |
1240 and the other elements are the arguments to the command. No shell is invoked in this case. |
1241 Return true if successful, false if not." |
1241 Return true if successful, false if not." |
1242 |
1242 |
1243 ^ self |
1243 ^ self |
1244 executeCommand:aCommandString |
1244 executeCommand:aCommandString |
1245 inputFrom:anInStream |
1245 inputFrom:anInStream |
1246 outputTo:anOutStream |
1246 outputTo:anOutStream |
1247 errorTo:anErrStream |
1247 errorTo:anErrStream |
1248 auxFrom:nil |
1248 auxFrom:nil |
1249 environment:nil |
1249 environment:nil |
1250 inDirectory:nil |
1250 inDirectory:nil |
1251 lineWise:false |
1251 lineWise:false |
1252 onError:[:status | false] |
1252 onError:[:status | false] |
1253 |
1253 |
1254 " |
1254 " |
1255 OperatingSystem |
1255 OperatingSystem |
1256 executeCommand:'ls' |
1256 executeCommand:'ls' |
1257 inputFrom:nil |
1257 inputFrom:nil |
1258 outputTo:Transcript |
1258 outputTo:Transcript |
1259 errorTo:Transcript |
1259 errorTo:Transcript |
1260 |
1260 |
1261 |s| |
1261 |s| |
1262 s := WriteStream on:''. |
1262 s := WriteStream on:''. |
1263 (OperatingSystem |
1263 (OperatingSystem |
1264 executeCommand:'ls' |
1264 executeCommand:'ls' |
1265 inputFrom:nil |
1265 inputFrom:nil |
1266 outputTo:s |
1266 outputTo:s |
1267 errorTo:Transcript) ifTrue:[Transcript showCR:s contents] |
1267 errorTo:Transcript) ifTrue:[Transcript showCR:s contents] |
1268 |
1268 |
1269 OperatingSystem |
1269 OperatingSystem |
1270 executeCommand:'dir' |
1270 executeCommand:'dir' |
1271 inputFrom:nil |
1271 inputFrom:nil |
1272 outputTo:Transcript |
1272 outputTo:Transcript |
1273 errorTo:Transcript |
1273 errorTo:Transcript |
1274 |
1274 |
1275 OperatingSystem |
1275 OperatingSystem |
1276 executeCommand:'foo' |
1276 executeCommand:'foo' |
1277 inputFrom:Transcript |
1277 inputFrom:Transcript |
1278 outputTo:Transcript |
1278 outputTo:Transcript |
1279 errorTo:nil |
1279 errorTo:nil |
1280 " |
1280 " |
1281 " |
1281 " |
1282 |outStr errStr| |
1282 |outStr errStr| |
1283 |
1283 |
1284 outStr := '' writeStream. |
1284 outStr := '' writeStream. |
1285 errStr := '' writeStream. |
1285 errStr := '' writeStream. |
1286 OperatingSystem |
1286 OperatingSystem |
1287 executeCommand:'ls' |
1287 executeCommand:'ls' |
1288 inputFrom:nil |
1288 inputFrom:nil |
1289 outputTo:outStr |
1289 outputTo:outStr |
1290 errorTo:errStr |
1290 errorTo:errStr |
1291 onError:[:status | Transcript flash]. |
1291 onError:[:status | Transcript flash]. |
1292 Transcript show:'out:'; showCR:outStr contents. |
1292 Transcript show:'out:'; showCR:outStr contents. |
1293 Transcript show:'err:'; showCR:errStr contents. |
1293 Transcript show:'err:'; showCR:errStr contents. |
1294 " |
1294 " |
1295 " |
1295 " |
1296 |outStr errStr| |
1296 |outStr errStr| |
1297 |
1297 |
1298 outStr := '' writeStream. |
1298 outStr := '' writeStream. |
1299 errStr := '' writeStream. |
1299 errStr := '' writeStream. |
1300 OperatingSystem |
1300 OperatingSystem |
1301 executeCommand:'ls /fooBar' |
1301 executeCommand:'ls /fooBar' |
1302 inputFrom:nil |
1302 inputFrom:nil |
1303 outputTo:outStr |
1303 outputTo:outStr |
1304 errorTo:errStr |
1304 errorTo:errStr |
1305 onError:[:status | Transcript flash]. |
1305 onError:[:status | Transcript flash]. |
1306 Transcript show:'out:'; showCR:outStr contents. |
1306 Transcript show:'out:'; showCR:outStr contents. |
1307 Transcript show:'err:'; showCR:errStr contents. |
1307 Transcript show:'err:'; showCR:errStr contents. |
1308 " |
1308 " |
1309 |
1309 |
1310 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1310 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1311 ! |
1311 ! |
1312 |
1312 |
1340 closeStreams| |
1340 closeStreams| |
1341 |
1341 |
1342 terminateLock := Semaphore forMutualExclusion. |
1342 terminateLock := Semaphore forMutualExclusion. |
1343 ((externalInStream := anInStream) notNil |
1343 ((externalInStream := anInStream) notNil |
1344 and:[externalInStream isExternalStream not]) ifTrue:[ |
1344 and:[externalInStream isExternalStream not]) ifTrue:[ |
1345 pIn := NonPositionableExternalStream makePipe. |
1345 pIn := NonPositionableExternalStream makePipe. |
1346 inStreamToClose := externalInStream := pIn at:1. |
1346 inStreamToClose := externalInStream := pIn at:1. |
1347 shuffledInStream := pIn at:2. |
1347 shuffledInStream := pIn at:2. |
1348 anInStream isBinary ifTrue:[ |
1348 anInStream isBinary ifTrue:[ |
1349 shuffledInStream binary |
1349 shuffledInStream binary |
1350 ]. |
1350 ]. |
1351 lineWise ifFalse:[ |
1351 lineWise ifFalse:[ |
1352 shuffledInStream blocking:false. |
1352 shuffledInStream blocking:false. |
1353 ]. |
1353 ]. |
1354 |
1354 |
1355 "/ start a reader process, shuffling data from the given |
1355 "/ start a reader process, shuffling data from the given |
1356 "/ inStream to the pipe (which is connected to the commands input) |
1356 "/ inStream to the pipe (which is connected to the commands input) |
1357 inputShufflerProcess := |
1357 inputShufflerProcess := |
1358 [ |
1358 [ |
1359 [ |
1359 [ |
1360 [anInStream atEnd] whileFalse:[ |
1360 [anInStream atEnd] whileFalse:[ |
1361 self shuffleFrom:anInStream to:shuffledInStream lineWise:lineWise. |
1361 self shuffleFrom:anInStream to:shuffledInStream lineWise:lineWise. |
1362 shuffledInStream flush |
1362 shuffledInStream flush |
1363 ] |
1363 ] |
1364 ] ensure:[ |
1364 ] ensure:[ |
1365 shuffledInStream close |
1365 shuffledInStream close |
1366 ] |
1366 ] |
1367 ] newProcess |
1367 ] newProcess |
1368 name:'cmd input shuffler'; |
1368 name:'cmd input shuffler'; |
1369 "/ beSystemProcess; |
1369 "/ beSystemProcess; |
1370 resume. |
1370 resume. |
1371 ]. |
1371 ]. |
1372 ((externalOutStream := anOutStream) notNil |
1372 ((externalOutStream := anOutStream) notNil |
1373 and:[externalOutStream isExternalStream not]) ifTrue:[ |
1373 and:[externalOutStream isExternalStream not]) ifTrue:[ |
1374 pOut := NonPositionableExternalStream makePipe. |
1374 pOut := NonPositionableExternalStream makePipe. |
1375 shuffledOutStream := (pOut at:1). |
1375 shuffledOutStream := (pOut at:1). |
1376 anOutStream isBinary ifTrue:[ |
1376 anOutStream isBinary ifTrue:[ |
1377 shuffledOutStream binary |
1377 shuffledOutStream binary |
1378 ]. |
1378 ]. |
1379 outStreamToClose := externalOutStream := pOut at:2. |
1379 outStreamToClose := externalOutStream := pOut at:2. |
1380 outputShufflerProcess := |
1380 outputShufflerProcess := |
1381 [ |
1381 [ |
1382 WriteError handle:[:ex | |
1382 WriteError handle:[:ex | |
1383 "/ ignored |
1383 "/ ignored |
1384 ] do:[ |
1384 ] do:[ |
1385 self shuffleAllFrom:shuffledOutStream to:anOutStream lineWise:lineWise lockWith:terminateLock. |
1385 self shuffleAllFrom:shuffledOutStream to:anOutStream lineWise:lineWise lockWith:terminateLock. |
1386 ]. |
1386 ]. |
1387 ] newProcess |
1387 ] newProcess |
1388 priority:(Processor userSchedulingPriority + 1); |
1388 priority:(Processor userSchedulingPriority + 1); |
1389 name:'cmd output shuffler'; |
1389 name:'cmd output shuffler'; |
1390 "/ beSystemProcess; |
1390 "/ beSystemProcess; |
1391 resume. |
1391 resume. |
1392 ]. |
1392 ]. |
1393 (externalErrStream := anErrStream) notNil ifTrue:[ |
1393 (externalErrStream := anErrStream) notNil ifTrue:[ |
1394 anErrStream == anOutStream ifTrue:[ |
1394 anErrStream == anOutStream ifTrue:[ |
1395 externalErrStream := externalOutStream |
1395 externalErrStream := externalOutStream |
1396 ] ifFalse:[ |
1396 ] ifFalse:[ |
1397 anErrStream isExternalStream ifFalse:[ |
1397 anErrStream isExternalStream ifFalse:[ |
1398 pErr := NonPositionableExternalStream makePipe. |
1398 pErr := NonPositionableExternalStream makePipe. |
1399 shuffledErrStream := (pErr at:1). |
1399 shuffledErrStream := (pErr at:1). |
1400 anErrStream isBinary ifTrue:[ |
1400 anErrStream isBinary ifTrue:[ |
1401 shuffledErrStream binary |
1401 shuffledErrStream binary |
1402 ]. |
1402 ]. |
1403 errStreamToClose := externalErrStream := pErr at:2. |
1403 errStreamToClose := externalErrStream := pErr at:2. |
1404 errorShufflerProcess := |
1404 errorShufflerProcess := |
1405 [ |
1405 [ |
1406 self shuffleAllFrom:shuffledErrStream to:anErrStream lineWise:lineWise lockWith:terminateLock. |
1406 self shuffleAllFrom:shuffledErrStream to:anErrStream lineWise:lineWise lockWith:terminateLock. |
1407 ] newProcess |
1407 ] newProcess |
1408 priority:(Processor userSchedulingPriority + 2); |
1408 priority:(Processor userSchedulingPriority + 2); |
1409 name:'cmd err-output shuffler'; |
1409 name:'cmd err-output shuffler'; |
1410 "/ beSystemProcess; |
1410 "/ beSystemProcess; |
1411 resume. |
1411 resume. |
1412 ] |
1412 ] |
1413 ] |
1413 ] |
1414 ]. |
1414 ]. |
1415 ((externalAuxStream := anAuxStream) notNil |
1415 ((externalAuxStream := anAuxStream) notNil |
1416 and:[externalAuxStream isExternalStream not]) ifTrue:[ |
1416 and:[externalAuxStream isExternalStream not]) ifTrue:[ |
1417 pAux := NonPositionableExternalStream makePipe. |
1417 pAux := NonPositionableExternalStream makePipe. |
1418 auxStreamToClose := externalAuxStream := pAux at:1. |
1418 auxStreamToClose := externalAuxStream := pAux at:1. |
1419 shuffledAuxStream := pAux at:2. |
1419 shuffledAuxStream := pAux at:2. |
1420 shuffledAuxStream blocking:false. |
1420 shuffledAuxStream blocking:false. |
1421 anAuxStream isBinary ifTrue:[ |
1421 anAuxStream isBinary ifTrue:[ |
1422 shuffledAuxStream binary |
1422 shuffledAuxStream binary |
1423 ]. |
1423 ]. |
1424 |
1424 |
1425 "/ start a reader process, shuffling data from the given |
1425 "/ start a reader process, shuffling data from the given |
1426 "/ auxStream to the pipe (which is connected to the commands aux) |
1426 "/ auxStream to the pipe (which is connected to the commands aux) |
1427 auxShufflerProcess := |
1427 auxShufflerProcess := |
1428 [ |
1428 [ |
1429 [ |
1429 [ |
1430 [anAuxStream atEnd] whileFalse:[ |
1430 [anAuxStream atEnd] whileFalse:[ |
1431 self shuffleFrom:anAuxStream to:shuffledAuxStream lineWise:false. |
1431 self shuffleFrom:anAuxStream to:shuffledAuxStream lineWise:false. |
1432 shuffledAuxStream flush |
1432 shuffledAuxStream flush |
1433 ] |
1433 ] |
1434 ] ensure:[ |
1434 ] ensure:[ |
1435 shuffledAuxStream close |
1435 shuffledAuxStream close |
1436 ] |
1436 ] |
1437 ] newProcess |
1437 ] newProcess |
1438 name:'cmd aux shuffler'; |
1438 name:'cmd aux shuffler'; |
1439 "/ beSystemProcess; |
1439 "/ beSystemProcess; |
1440 resume. |
1440 resume. |
1441 ]. |
1441 ]. |
1442 |
1442 |
1443 stopShufflers := [:shuffleRest | |
1443 stopShufflers := [:shuffleRest | |
1444 inputShufflerProcess notNil ifTrue:[ |
1444 inputShufflerProcess notNil ifTrue:[ |
1445 terminateLock critical:[inputShufflerProcess terminate]. |
1445 terminateLock critical:[inputShufflerProcess terminate]. |
1446 inputShufflerProcess waitUntilTerminated |
1446 inputShufflerProcess waitUntilTerminated |
1447 ]. |
1447 ]. |
1448 auxShufflerProcess notNil ifTrue:[ |
1448 auxShufflerProcess notNil ifTrue:[ |
1449 terminateLock critical:[auxShufflerProcess terminate]. |
1449 terminateLock critical:[auxShufflerProcess terminate]. |
1450 auxShufflerProcess waitUntilTerminated |
1450 auxShufflerProcess waitUntilTerminated |
1451 ]. |
1451 ]. |
1452 outputShufflerProcess notNil ifTrue:[ |
1452 outputShufflerProcess notNil ifTrue:[ |
1453 terminateLock critical:[outputShufflerProcess terminate]. |
1453 terminateLock critical:[outputShufflerProcess terminate]. |
1454 outputShufflerProcess waitUntilTerminated. |
1454 outputShufflerProcess waitUntilTerminated. |
1455 shuffleRest ifTrue:[ self shuffleRestFrom:shuffledOutStream to:anOutStream lineWise:lineWise ]. |
1455 shuffleRest ifTrue:[ self shuffleRestFrom:shuffledOutStream to:anOutStream lineWise:lineWise ]. |
1456 shuffledOutStream close. |
1456 shuffledOutStream close. |
1457 ]. |
1457 ]. |
1458 errorShufflerProcess notNil ifTrue:[ |
1458 errorShufflerProcess notNil ifTrue:[ |
1459 terminateLock critical:[errorShufflerProcess terminate]. |
1459 terminateLock critical:[errorShufflerProcess terminate]. |
1460 errorShufflerProcess waitUntilTerminated. |
1460 errorShufflerProcess waitUntilTerminated. |
1461 shuffleRest ifTrue:[ self shuffleRestFrom:shuffledErrStream to:anErrStream lineWise:lineWise ]. |
1461 shuffleRest ifTrue:[ self shuffleRestFrom:shuffledErrStream to:anErrStream lineWise:lineWise ]. |
1462 shuffledErrStream close. |
1462 shuffledErrStream close. |
1463 ]. |
1463 ]. |
1464 ]. |
1464 ]. |
1465 |
1465 |
1466 closeStreams := [ |
1466 closeStreams := [ |
1467 inStreamToClose notNil ifTrue:[ |
1467 inStreamToClose notNil ifTrue:[ |
1468 inStreamToClose close |
1468 inStreamToClose close |
1469 ]. |
1469 ]. |
1470 errStreamToClose notNil ifTrue:[ |
1470 errStreamToClose notNil ifTrue:[ |
1471 errStreamToClose close |
1471 errStreamToClose close |
1472 ]. |
1472 ]. |
1473 outStreamToClose notNil ifTrue:[ |
1473 outStreamToClose notNil ifTrue:[ |
1474 outStreamToClose close |
1474 outStreamToClose close |
1475 ]. |
1475 ]. |
1476 auxStreamToClose notNil ifTrue:[ |
1476 auxStreamToClose notNil ifTrue:[ |
1477 auxStreamToClose close |
1477 auxStreamToClose close |
1478 ]. |
1478 ]. |
1479 nullStream notNil ifTrue:[ |
1479 nullStream notNil ifTrue:[ |
1480 nullStream close |
1480 nullStream close |
1481 ]. |
1481 ]. |
1482 ]. |
1482 ]. |
1483 |
1483 |
1484 |
1484 |
1485 sema := Semaphore new name:'OS command wait'. |
1485 sema := Semaphore new name:'OS command wait'. |
1486 [ |
1486 [ |
1487 externalInStream isNil ifTrue:[ |
1487 externalInStream isNil ifTrue:[ |
1488 externalInStream := nullStream := Filename nullDevice readWriteStream. |
1488 externalInStream := nullStream := Filename nullDevice readWriteStream. |
1489 ]. |
1489 ]. |
1490 externalOutStream isNil ifTrue:[ |
1490 externalOutStream isNil ifTrue:[ |
1491 nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream]. |
1491 nullStream isNil ifTrue:[nullStream := Filename nullDevice writeStream]. |
1492 externalOutStream := nullStream. |
1492 externalOutStream := nullStream. |
1493 ]. |
1493 ]. |
1494 externalErrStream isNil ifTrue:[ |
1494 externalErrStream isNil ifTrue:[ |
1495 externalErrStream := externalOutStream |
1495 externalErrStream := externalOutStream |
1496 ]. |
1496 ]. |
1497 |
1497 |
1498 pid := Processor |
1498 pid := Processor |
1499 monitor:[ |
1499 monitor:[ |
1500 self |
1500 self |
1501 startProcess:aCommandStringOrArray |
1501 startProcess:aCommandStringOrArray |
1502 inputFrom:externalInStream |
1502 inputFrom:externalInStream |
1503 outputTo:externalOutStream |
1503 outputTo:externalOutStream |
1504 errorTo:externalErrStream |
1504 errorTo:externalErrStream |
1505 auxFrom:externalAuxStream |
1505 auxFrom:externalAuxStream |
1506 environment:environmentDictionary |
1506 environment:environmentDictionary |
1507 inDirectory:dirOrNil |
1507 inDirectory:dirOrNil |
1508 ] |
1508 ] |
1509 action:[:status | |
1509 action:[:status | |
1510 status stillAlive ifFalse:[ |
1510 status stillAlive ifFalse:[ |
1511 exitStatus := status. |
1511 exitStatus := status. |
1512 sema signal. |
1512 sema signal. |
1513 self closePid:pid |
1513 self closePid:pid |
1514 ] |
1514 ] |
1515 ]. |
1515 ]. |
1516 |
1516 |
1517 pid isNil ifTrue:[ |
1517 pid isNil ifTrue:[ |
1518 exitStatus := self osProcessStatusClass processCreationFailure |
1518 exitStatus := self osProcessStatusClass processCreationFailure |
1519 ] ifFalse:[ |
1519 ] ifFalse:[ |
1520 sema wait. |
1520 sema wait. |
1521 ]. |
1521 ]. |
1522 ] ifCurtailed:[ |
1522 ] ifCurtailed:[ |
1523 closeStreams value. |
1523 closeStreams value. |
1524 pid notNil ifTrue:[ |
1524 pid notNil ifTrue:[ |
1525 "/ terminate the os-command (and all of its forked commands) |
1525 "/ terminate the os-command (and all of its forked commands) |
1526 self terminateProcessGroup:pid. |
1526 self terminateProcessGroup:pid. |
1527 self terminateProcess:pid. |
1527 self terminateProcess:pid. |
1528 self closePid:pid. |
1528 self closePid:pid. |
1529 ]. |
1529 ]. |
1530 stopShufflers value:false. |
1530 stopShufflers value:false. |
1531 ]. |
1531 ]. |
1532 |
1532 |
1533 closeStreams value. |
1533 closeStreams value. |
1534 stopShufflers value:true. |
1534 stopShufflers value:true. |
1535 (exitStatus isNil or:[exitStatus success]) ifFalse:[ |
1535 (exitStatus isNil or:[exitStatus success]) ifFalse:[ |
1536 ^ aBlock value:exitStatus |
1536 ^ aBlock value:exitStatus |
1537 ]. |
1537 ]. |
1538 ^ true |
1538 ^ true |
1539 |
1539 |
1540 " |
1540 " |
1541 |outStream errStream| |
1541 |outStream errStream| |
1542 |
1542 |
1543 outStream := '' writeStream. |
1543 outStream := '' writeStream. |
1544 |
1544 |
1545 OperatingSystem executeCommand:'ls -l' |
1545 OperatingSystem executeCommand:'ls -l' |
1546 inputFrom:'abc' readStream |
1546 inputFrom:'abc' readStream |
1547 outputTo:outStream |
1547 outputTo:outStream |
1548 errorTo:nil |
1548 errorTo:nil |
1549 inDirectory:nil |
1549 inDirectory:nil |
1550 lineWise:true |
1550 lineWise:true |
1551 onError:[:exitStatus | ^ false]. |
1551 onError:[:exitStatus | ^ false]. |
1552 outStream contents |
1552 outStream contents |
1553 " |
1553 " |
1554 |
1554 |
1555 " |
1555 " |
1556 |outStream errStream| |
1556 |outStream errStream| |
1557 |
1557 |
1558 outStream := #[] writeStream. |
1558 outStream := #[] writeStream. |
1559 |
1559 |
1560 OperatingSystem executeCommand:'cat' |
1560 OperatingSystem executeCommand:'cat' |
1561 inputFrom:(ByteArray new:5000000) readStream |
1561 inputFrom:(ByteArray new:5000000) readStream |
1562 outputTo:outStream |
1562 outputTo:outStream |
1563 errorTo:nil |
1563 errorTo:nil |
1564 inDirectory:nil |
1564 inDirectory:nil |
1565 lineWise:false |
1565 lineWise:false |
1566 onError:[:exitStatus | ^ false]. |
1566 onError:[:exitStatus | ^ false]. |
1567 outStream size |
1567 outStream size |
1568 " |
1568 " |
1569 |
1569 |
1570 " |
1570 " |
1571 |outStream errStream| |
1571 |outStream errStream| |
1572 |
1572 |
1573 outStream := '' writeStream. |
1573 outStream := '' writeStream. |
1574 |
1574 |
1575 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1575 OperatingSystem executeCommand:'gpg -s --batch --no-tty --passphrase-fd 0 /tmp/passwd' |
1576 inputFrom:'bla' readStream |
1576 inputFrom:'bla' readStream |
1577 outputTo:outStream |
1577 outputTo:outStream |
1578 errorTo:nil |
1578 errorTo:nil |
1579 inDirectory:nil |
1579 inDirectory:nil |
1580 lineWise:true |
1580 lineWise:true |
1581 onError:[:exitStatus | false]. |
1581 onError:[:exitStatus | false]. |
1582 outStream contents |
1582 outStream contents |
1583 " |
1583 " |
1584 |
1584 |
1585 "Modified: / 11-02-2007 / 20:54:39 / cg" |
1585 "Modified: / 11-02-2007 / 20:54:39 / cg" |
1586 ! |
1586 ! |
1587 |
1587 |
1607 Return true if successful, the value from aBlock if not. |
1607 Return true if successful, the value from aBlock if not. |
1608 If not successfull, aBlock is called with an OsProcessStatus |
1608 If not successfull, aBlock is called with an OsProcessStatus |
1609 (containing the exit status) as argument." |
1609 (containing the exit status) as argument." |
1610 |
1610 |
1611 ^ self |
1611 ^ self |
1612 executeCommand:aCommandString |
1612 executeCommand:aCommandString |
1613 inputFrom:anInStream |
1613 inputFrom:anInStream |
1614 outputTo:anOutStream |
1614 outputTo:anOutStream |
1615 errorTo:anErrStream |
1615 errorTo:anErrStream |
1616 auxFrom:nil |
1616 auxFrom:nil |
1617 environment:env |
1617 environment:env |
1618 inDirectory:nil |
1618 inDirectory:nil |
1619 lineWise:false |
1619 lineWise:false |
1620 onError:aBlock |
1620 onError:aBlock |
1621 |
1621 |
1622 " |
1622 " |
1623 OperatingSystem |
1623 OperatingSystem |
1624 executeCommand:'dir' |
1624 executeCommand:'dir' |
1625 inputFrom:nil |
1625 inputFrom:nil |
1626 outputTo:nil |
1626 outputTo:nil |
1627 errorTo:nil |
1627 errorTo:nil |
1628 onError:[:status | Transcript flash] |
1628 onError:[:status | Transcript flash] |
1629 |
1629 |
1630 OperatingSystem |
1630 OperatingSystem |
1631 executeCommand:'foo' |
1631 executeCommand:'foo' |
1632 inputFrom:nil |
1632 inputFrom:nil |
1633 outputTo:nil |
1633 outputTo:nil |
1634 errorTo:nil |
1634 errorTo:nil |
1635 onError:[:status | Transcript flash] |
1635 onError:[:status | Transcript flash] |
1636 " |
1636 " |
1637 " |
1637 " |
1638 |outStr errStr| |
1638 |outStr errStr| |
1639 |
1639 |
1640 outStr := '' writeStream. |
1640 outStr := '' writeStream. |
1641 errStr := '' writeStream. |
1641 errStr := '' writeStream. |
1642 OperatingSystem |
1642 OperatingSystem |
1643 executeCommand:'ls' |
1643 executeCommand:'ls' |
1644 inputFrom:nil |
1644 inputFrom:nil |
1645 outputTo:outStr |
1645 outputTo:outStr |
1646 errorTo:errStr |
1646 errorTo:errStr |
1647 onError:[:status | Transcript flash]. |
1647 onError:[:status | Transcript flash]. |
1648 Transcript show:'out:'; showCR:outStr contents. |
1648 Transcript show:'out:'; showCR:outStr contents. |
1649 Transcript show:'err:'; showCR:errStr contents. |
1649 Transcript show:'err:'; showCR:errStr contents. |
1650 " |
1650 " |
1651 " |
1651 " |
1652 |outStr errStr| |
1652 |outStr errStr| |
1653 |
1653 |
1654 outStr := '' writeStream. |
1654 outStr := '' writeStream. |
1655 errStr := '' writeStream. |
1655 errStr := '' writeStream. |
1656 OperatingSystem |
1656 OperatingSystem |
1657 executeCommand:'ls /fooBar' |
1657 executeCommand:'ls /fooBar' |
1658 inputFrom:nil |
1658 inputFrom:nil |
1659 outputTo:outStr |
1659 outputTo:outStr |
1660 errorTo:errStr |
1660 errorTo:errStr |
1661 onError:[:status | Transcript flash]. |
1661 onError:[:status | Transcript flash]. |
1662 Transcript show:'out:'; showCR:outStr contents. |
1662 Transcript show:'out:'; showCR:outStr contents. |
1663 Transcript show:'err:'; showCR:errStr contents. |
1663 Transcript show:'err:'; showCR:errStr contents. |
1664 " |
1664 " |
1665 |
1665 |
1666 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1666 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1667 ! |
1667 ! |
1668 |
1668 |
1709 those internal stream(s). |
1709 those internal stream(s). |
1710 Nil stream args will execute the command connected to ST/X's standard input, output or |
1710 Nil stream args will execute the command connected to ST/X's standard input, output or |
1711 error resp. - i.e. usually, i/o will be from/to the terminal" |
1711 error resp. - i.e. usually, i/o will be from/to the terminal" |
1712 |
1712 |
1713 ^ self |
1713 ^ self |
1714 executeCommand:aCommandString |
1714 executeCommand:aCommandString |
1715 inputFrom:anInStream |
1715 inputFrom:anInStream |
1716 outputTo:anOutStream |
1716 outputTo:anOutStream |
1717 errorTo:anErrStream |
1717 errorTo:anErrStream |
1718 auxFrom:nil |
1718 auxFrom:nil |
1719 environment:nil |
1719 environment:nil |
1720 inDirectory:dirOrNil |
1720 inDirectory:dirOrNil |
1721 lineWise:lineWise |
1721 lineWise:lineWise |
1722 onError:aBlock |
1722 onError:aBlock |
1723 ! |
1723 ! |
1724 |
1724 |
1725 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock |
1725 executeCommand:aCommandString inputFrom:anInStream outputTo:anOutStream errorTo:anErrStream inDirectory:dirOrNil onError:aBlock |
1726 "execute the unix command specified by the argument, aCommandString. |
1726 "execute the unix command specified by the argument, aCommandString. |
1727 If aCommandString is a String, the commandString is passed to a shell for execution |
1727 If aCommandString is a String, the commandString is passed to a shell for execution |
1737 those internal stream(s). |
1737 those internal stream(s). |
1738 Nil stream args will execute the command connected to ST/X's input, output or |
1738 Nil stream args will execute the command connected to ST/X's input, output or |
1739 error resp. - i.e. i/o will be from/to the xterminal" |
1739 error resp. - i.e. i/o will be from/to the xterminal" |
1740 |
1740 |
1741 ^ self |
1741 ^ self |
1742 executeCommand:aCommandString |
1742 executeCommand:aCommandString |
1743 inputFrom:anInStream |
1743 inputFrom:anInStream |
1744 outputTo:anOutStream |
1744 outputTo:anOutStream |
1745 errorTo:anErrStream |
1745 errorTo:anErrStream |
1746 auxFrom:nil |
1746 auxFrom:nil |
1747 environment:nil |
1747 environment:nil |
1748 inDirectory:dirOrNil |
1748 inDirectory:dirOrNil |
1749 lineWise:false |
1749 lineWise:false |
1750 onError:aBlock |
1750 onError:aBlock |
1751 |
1751 |
1752 " |
1752 " |
1753 OperatingSystem |
1753 OperatingSystem |
1754 executeCommand:'dir' |
1754 executeCommand:'dir' |
1755 inputFrom:nil |
1755 inputFrom:nil |
1756 outputTo:nil |
1756 outputTo:nil |
1757 errorTo:nil |
1757 errorTo:nil |
1758 inDirectory:'c:' |
1758 inDirectory:'c:' |
1759 onError:[:status | Transcript flash] |
1759 onError:[:status | Transcript flash] |
1760 |
1760 |
1761 OperatingSystem |
1761 OperatingSystem |
1762 executeCommand:'foo' |
1762 executeCommand:'foo' |
1763 inputFrom:nil |
1763 inputFrom:nil |
1764 outputTo:nil |
1764 outputTo:nil |
1765 errorTo:nil |
1765 errorTo:nil |
1766 inDirectory:'/etc' |
1766 inDirectory:'/etc' |
1767 onError:[:status | Transcript flash] |
1767 onError:[:status | Transcript flash] |
1768 |
1768 |
1769 |s| |
1769 |s| |
1770 s := '' writeStream. |
1770 s := '' writeStream. |
1771 OperatingSystem |
1771 OperatingSystem |
1772 executeCommand:'ls -l' |
1772 executeCommand:'ls -l' |
1773 inputFrom:nil |
1773 inputFrom:nil |
1774 outputTo:s |
1774 outputTo:s |
1775 errorTo:nil |
1775 errorTo:nil |
1776 onError:[:status | Transcript flash]. |
1776 onError:[:status | Transcript flash]. |
1777 Transcript showCR:s contents. |
1777 Transcript showCR:s contents. |
1778 |
1778 |
1779 |s| |
1779 |s| |
1780 s := '' writeStream. |
1780 s := '' writeStream. |
1781 OperatingSystem |
1781 OperatingSystem |
1782 executeCommand:'sh foo' |
1782 executeCommand:'sh foo' |
1783 inputFrom:nil |
1783 inputFrom:nil |
1784 outputTo:s |
1784 outputTo:s |
1785 errorTo:s |
1785 errorTo:s |
1786 onError:[:status | Transcript flash]. |
1786 onError:[:status | Transcript flash]. |
1787 Transcript showCR:s contents. |
1787 Transcript showCR:s contents. |
1788 " |
1788 " |
1789 |
1789 |
1790 "Modified: / 25.3.1997 / 11:02:02 / stefan" |
1790 "Modified: / 25.3.1997 / 11:02:02 / stefan" |
1791 "Modified: / 28.1.1998 / 14:46:36 / md" |
1791 "Modified: / 28.1.1998 / 14:46:36 / md" |
1802 Return true if successful, the value from aBlock if not. |
1802 Return true if successful, the value from aBlock if not. |
1803 If not successfull, aBlock is called with an OsProcessStatus |
1803 If not successfull, aBlock is called with an OsProcessStatus |
1804 (containing the exit status) as argument." |
1804 (containing the exit status) as argument." |
1805 |
1805 |
1806 ^ self |
1806 ^ self |
1807 executeCommand:aCommandString |
1807 executeCommand:aCommandString |
1808 inputFrom:anInStream |
1808 inputFrom:anInStream |
1809 outputTo:anOutStream |
1809 outputTo:anOutStream |
1810 errorTo:anErrStream |
1810 errorTo:anErrStream |
1811 auxFrom:nil |
1811 auxFrom:nil |
1812 environment:nil |
1812 environment:nil |
1813 inDirectory:nil |
1813 inDirectory:nil |
1814 lineWise:false |
1814 lineWise:false |
1815 onError:aBlock |
1815 onError:aBlock |
1816 |
1816 |
1817 " |
1817 " |
1818 OperatingSystem |
1818 OperatingSystem |
1819 executeCommand:'dir' |
1819 executeCommand:'dir' |
1820 inputFrom:nil |
1820 inputFrom:nil |
1821 outputTo:nil |
1821 outputTo:nil |
1822 errorTo:nil |
1822 errorTo:nil |
1823 onError:[:status | Transcript flash] |
1823 onError:[:status | Transcript flash] |
1824 |
1824 |
1825 OperatingSystem |
1825 OperatingSystem |
1826 executeCommand:'foo' |
1826 executeCommand:'foo' |
1827 inputFrom:nil |
1827 inputFrom:nil |
1828 outputTo:nil |
1828 outputTo:nil |
1829 errorTo:nil |
1829 errorTo:nil |
1830 onError:[:status | Transcript flash] |
1830 onError:[:status | Transcript flash] |
1831 " |
1831 " |
1832 " |
1832 " |
1833 |outStr errStr| |
1833 |outStr errStr| |
1834 |
1834 |
1835 outStr := '' writeStream. |
1835 outStr := '' writeStream. |
1836 errStr := '' writeStream. |
1836 errStr := '' writeStream. |
1837 OperatingSystem |
1837 OperatingSystem |
1838 executeCommand:'ls' |
1838 executeCommand:'ls' |
1839 inputFrom:nil |
1839 inputFrom:nil |
1840 outputTo:outStr |
1840 outputTo:outStr |
1841 errorTo:errStr |
1841 errorTo:errStr |
1842 onError:[:status | Transcript flash]. |
1842 onError:[:status | Transcript flash]. |
1843 Transcript show:'out:'; showCR:outStr contents. |
1843 Transcript show:'out:'; showCR:outStr contents. |
1844 Transcript show:'err:'; showCR:errStr contents. |
1844 Transcript show:'err:'; showCR:errStr contents. |
1845 " |
1845 " |
1846 " |
1846 " |
1847 |outStr errStr| |
1847 |outStr errStr| |
1848 |
1848 |
1849 outStr := '' writeStream. |
1849 outStr := '' writeStream. |
1850 errStr := '' writeStream. |
1850 errStr := '' writeStream. |
1851 OperatingSystem |
1851 OperatingSystem |
1852 executeCommand:'ls /fooBar' |
1852 executeCommand:'ls /fooBar' |
1853 inputFrom:nil |
1853 inputFrom:nil |
1854 outputTo:outStr |
1854 outputTo:outStr |
1855 errorTo:errStr |
1855 errorTo:errStr |
1856 onError:[:status | Transcript flash]. |
1856 onError:[:status | Transcript flash]. |
1857 Transcript show:'out:'; showCR:outStr contents. |
1857 Transcript show:'out:'; showCR:outStr contents. |
1858 Transcript show:'err:'; showCR:errStr contents. |
1858 Transcript show:'err:'; showCR:errStr contents. |
1859 " |
1859 " |
1860 |
1860 |
1861 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1861 "Modified: / 10.11.1998 / 20:51:39 / cg" |
1862 ! |
1862 ! |
1863 |
1863 |
1870 Return true if successful, the value from aBlock if not. |
1870 Return true if successful, the value from aBlock if not. |
1871 If not successfull, aBlock is called with an OsProcessStatus |
1871 If not successfull, aBlock is called with an OsProcessStatus |
1872 (containing the exit status) as argument." |
1872 (containing the exit status) as argument." |
1873 |
1873 |
1874 ^ self |
1874 ^ self |
1875 executeCommand:aCommandString |
1875 executeCommand:aCommandString |
1876 inputFrom:nil |
1876 inputFrom:nil |
1877 outputTo:nil |
1877 outputTo:nil |
1878 errorTo:nil |
1878 errorTo:nil |
1879 auxFrom:nil |
1879 auxFrom:nil |
1880 environment:nil |
1880 environment:nil |
1881 inDirectory:nil |
1881 inDirectory:nil |
1882 lineWise:false |
1882 lineWise:false |
1883 onError:aBlock |
1883 onError:aBlock |
1884 |
1884 |
1885 "unix: |
1885 "unix: |
1886 |
1886 |
1887 OperatingSystem executeCommand:'sleep 30' onError:[]. |
1887 OperatingSystem executeCommand:'sleep 30' onError:[]. |
1888 OperatingSystem executeCommand:'pwd' onError:[:status|status inspect]. |
1888 OperatingSystem executeCommand:'pwd' onError:[:status|status inspect]. |
1908 If aCommandString is an Array, the first element is the command to be executed, |
1908 If aCommandString is an Array, the first element is the command to be executed, |
1909 and the other elements are the arguments to the command. No shell is invoked in this case. |
1909 and the other elements are the arguments to the command. No shell is invoked in this case. |
1910 Return true if successful, false otherwise." |
1910 Return true if successful, false otherwise." |
1911 |
1911 |
1912 ^ self |
1912 ^ self |
1913 executeCommand:aCommandString |
1913 executeCommand:aCommandString |
1914 inputFrom:nil |
1914 inputFrom:nil |
1915 outputTo:anOutStreamOrNil |
1915 outputTo:anOutStreamOrNil |
1916 errorTo:nil |
1916 errorTo:nil |
1917 auxFrom:nil |
1917 auxFrom:nil |
1918 environment:nil |
1918 environment:nil |
1919 inDirectory:nil |
1919 inDirectory:nil |
1920 lineWise:false |
1920 lineWise:false |
1921 onError:[:status| false] |
1921 onError:[:status| false] |
1922 |
1922 |
1923 " |
1923 " |
1924 String streamContents:[:s|OperatingSystem |
1924 String streamContents:[:s|OperatingSystem |
1925 executeCommand:'ls' |
1925 executeCommand:'ls' |
1926 outputTo:s |
1926 outputTo:s |
1927 ] |
1927 ] |
1928 " |
1928 " |
1929 |
1929 |
1930 " |
1930 " |
1931 String streamContents:[:s|OperatingSystem |
1931 String streamContents:[:s|OperatingSystem |
1932 executeCommand:'pwd' |
1932 executeCommand:'pwd' |
1933 outputTo:s |
1933 outputTo:s |
1934 ] |
1934 ] |
1935 " |
1935 " |
1936 ! |
1936 ! |
1937 |
1937 |
1938 executeCommand:aCommandString outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:aDirectory |
1938 executeCommand:aCommandString outputTo:outStreamOrNil errorTo:errStreamOrNil inDirectory:aDirectory |
4014 # define PLATFORM_DEFINE "-DMACOS" |
4014 # define PLATFORM_DEFINE "-DMACOS" |
4015 # endif |
4015 # endif |
4016 # ifdef VMS |
4016 # ifdef VMS |
4017 # define PLATFORM_DEFINE "-DVMS" |
4017 # define PLATFORM_DEFINE "-DVMS" |
4018 # endif |
4018 # endif |
4019 # ifdef __osx__ |
|
4020 # define PLATFORM_DEFINE "-D__osx__" |
|
4021 # endif |
|
4019 # ifdef OSX |
4022 # ifdef OSX |
4020 # define PLATFORM_DEFINE "-DOSX" |
4023 # define PLATFORM_DEFINE "-DOSX" |
4021 # endif |
4024 # endif |
4022 # ifndef PLATFORM_DEFINE |
4025 # ifndef PLATFORM_DEFINE |
4023 # define PLATFORM_DEFINE "-DUNIX" |
4026 # define PLATFORM_DEFINE "-DUNIX" |
4152 ^ false |
4155 ^ false |
4153 ! |
4156 ! |
4154 |
4157 |
4155 isLinuxLike |
4158 isLinuxLike |
4156 "return true, if the OS we're running on is a linux." |
4159 "return true, if the OS we're running on is a linux." |
4157 |
4160 |
4158 ^ false |
4161 ^ false |
4159 ! |
4162 ! |
4160 |
4163 |
4161 isMAClike |
4164 isMAClike |
4162 "return true, if running on a macOS (but not on A/UX or OS/X)" |
4165 "return true, if running on a macOS (but not on A/UX or OS/X)" |
5891 ! |
5894 ! |
5892 |
5895 |
5893 computeUTCTimeAndDateFrom:osTime |
5896 computeUTCTimeAndDateFrom:osTime |
5894 "given an OS-dependent time in osTime, return an Array |
5897 "given an OS-dependent time in osTime, return an Array |
5895 containing: |
5898 containing: |
5896 (full-) year, |
5899 (full-) year, |
5897 month, (1..) |
5900 month, (1..) |
5898 day, (1..) |
5901 day, (1..) |
5899 hour, (0..23) |
5902 hour, (0..23) |
5900 minute (0..59) |
5903 minute (0..59) |
5901 seconds, (0..59) |
5904 seconds, (0..59) |
5902 offset to UTC, (seconds) |
5905 offset to UTC, (seconds) |
5903 daylight savings time flag, |
5906 daylight savings time flag, |
5904 milliseconds, (0..999) |
5907 milliseconds, (0..999) |
5905 dayInYear (1..) |
5908 dayInYear (1..) |
5906 dayInWeek (1..). |
5909 dayInWeek (1..). |
5907 Conversion is to utc." |
5910 Conversion is to utc." |
5908 |
5911 |
5909 ^ self timeInfoFromSeconds:(osTime // 1000) milliseconds:(osTime \\ 1000) localTime:false. |
5912 ^ self timeInfoFromSeconds:(osTime // 1000) milliseconds:(osTime \\ 1000) localTime:false. |
5910 |
5913 |
5911 " |
5914 " |
6219 |
6222 |
6220 utcOffset |
6223 utcOffset |
6221 ^ (self computeTimeAndDateFrom:0) utcOffset |
6224 ^ (self computeTimeAndDateFrom:0) utcOffset |
6222 |
6225 |
6223 " |
6226 " |
6224 OperatingSystem utcOffset |
6227 OperatingSystem utcOffset |
6225 " |
6228 " |
6226 ! ! |
6229 ! ! |
6227 |
6230 |
6228 !AbstractOperatingSystem class methodsFor:'users & groups'! |
6231 !AbstractOperatingSystem class methodsFor:'users & groups'! |
6229 |
6232 |
7696 ! ! |
7699 ! ! |
7697 |
7700 |
7698 !AbstractOperatingSystem class methodsFor:'documentation'! |
7701 !AbstractOperatingSystem class methodsFor:'documentation'! |
7699 |
7702 |
7700 version |
7703 version |
7701 ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.292 2015-03-02 23:12:59 stefan Exp $' |
7704 ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.293 2015-03-23 15:44:01 cg Exp $' |
7702 ! |
7705 ! |
7703 |
7706 |
7704 version_CVS |
7707 version_CVS |
7705 ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.292 2015-03-02 23:12:59 stefan Exp $' |
7708 ^ '$Header: /cvs/stx/stx/libbasic/AbstractOperatingSystem.st,v 1.293 2015-03-23 15:44:01 cg Exp $' |
7706 ! ! |
7709 ! ! |
7707 |
7710 |
7708 |
7711 |
7709 AbstractOperatingSystem initialize! |
7712 AbstractOperatingSystem initialize! |