UnixOperatingSystem.st
changeset 4853 3f5ed291c362
parent 4753 214fc4e89e7a
child 4882 fb4dafb482fb
--- a/UnixOperatingSystem.st	Wed Oct 06 14:59:16 1999 +0200
+++ b/UnixOperatingSystem.st	Wed Oct 06 14:59:44 1999 +0200
@@ -3969,6 +3969,57 @@
     "Modified: / 5.6.1998 / 18:35:35 / cg"
 !
 
+getMountedVolumes
+    "return info about mounted volumes. 
+     The amount of information returned depends upon the OS, and is
+     not guaranteed to be consistent across architectures.
+     On unix, the information returned is (at least):
+        mountPoint - mount point
+        fileSystem - device or NFS-remotePath
+    "
+
+    |p outputText keys values info infoEntry|
+
+    p := PipeStream readingFrom:('df').
+    p isNil ifTrue:[^ nil].
+
+    [
+        outputText := p contentsOfEntireFile.
+    ] valueNowOrOnUnwindDo:[
+        p close.
+    ].
+"/ Transcript showCR:outputText asString.
+    outputText isNil ifTrue:[^ nil].
+
+    outputText := outputText asCollectionOfLines.
+    outputText size < 2 ifTrue:[^ nil].
+
+    keys := (outputText at:1) asLowercase asCollectionOfWords.
+    "/ we may have to validate the following column indices
+    "/ on some rude Unix versions ...
+
+    info := OrderedCollection new.
+
+    outputText from:2 do:[:line |
+        values := line asCollectionOfWords.
+
+        values size >= 2 ifTrue:[
+
+            infoEntry := IdentityDictionary new.
+            infoEntry at:#mountPoint put:(values last).
+            infoEntry at:#fileSystem put:(values first).
+            info add:infoEntry.
+        ]
+    ].
+    ^ info
+
+    "
+     OperatingSystem getMountedVolumes
+    "
+
+    "Modified: / 22.5.1999 / 00:32:13 / cg"
+!
+
 getNullDevice
     "return the name of the OS's null device"
 
@@ -8653,6 +8704,6 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.69 1999-09-17 14:07:58 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.70 1999-10-06 12:59:44 ca Exp $'
 ! !
 UnixOperatingSystem initialize!