add mountPoint methods
authorpenk
Fri, 27 Sep 2002 13:59:27 +0200
changeset 6779 bd65f054770d
parent 6778 87e2d95ce8a4
child 6780 459a7ffe82d4
add mountPoint methods
UnixOperatingSystem.st
--- a/UnixOperatingSystem.st	Fri Sep 27 12:48:06 2002 +0200
+++ b/UnixOperatingSystem.st	Fri Sep 27 13:59:27 2002 +0200
@@ -41,6 +41,13 @@
 	privateIn:UnixOperatingSystem
 !
 
+Object subclass:#MountInfo
+	instanceVariableNames:'mountPointPath deviceOrRemotePath fsType attributeString'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:UnixOperatingSystem
+!
+
 Object subclass:#OSProcessStatus
 	instanceVariableNames:'pid status code core'
 	classVariableNames:''
@@ -5130,33 +5137,6 @@
     ^ self primitiveFailed
 !
 
-isMountPoint:aPathName
-    "return true, if the given file is a mounted fileSystems mountPoint"
-
-    |procFS|
-
-    procFS := '/proc/mounts' asFilename.
-    procFS exists not ifTrue:[
-        "/ TODO: add fallback code for other OS's
-        ^ false "/ dont know 
-    ].
-
-    procFS readingLinesDo:[:eachLine |
-        |items mountPath|
-
-        items := eachLine asCollectionOfWords.
-        mountPath := items second.
-        mountPath = aPathName ifTrue:[ ^ true ].
-    ].
-    ^ false
-
-    "
-     OperatingSystem isMountPoint:'/phys/qnx'  
-     OperatingSystem isMountPoint:'/proc'      
-     OperatingSystem isMountPoint:'/'      
-    "
-!
-
 isReadable:aPathName
     "return true, if the file/dir 'aPathName' is readable.
      For symbolic links, the pointed-to-file is checked."
@@ -5336,6 +5316,36 @@
    "
 !
 
+mountPoints
+    "return a collection of mountPoints (aka. topDirectories of mounted file systems)"
+
+    |procFS entries|
+
+    procFS := '/proc/mounts' asFilename.
+    procFS exists not ifTrue:[
+        "/ TODO: add fallback code for other OS's
+        ^ #() 
+    ].
+
+    entries := OrderedCollection new.
+    procFS readingLinesDo:[:eachLine |
+        |items mountInfo|
+
+        items := eachLine asCollectionOfWords.
+        mountInfo := (MountInfo new
+            mountPointPath:(items at:2)        
+            deviceOrRemotePath:(items at:1) 
+            fsType:(items at:3) 
+            attributeString:(items at:4)).
+        entries add:mountInfo
+    ].
+    ^ entries
+
+    "
+     OperatingSystem mountPoints
+    "
+!
+
 parentDirectoryName
     "return the name used to refer to parent directories.
      In MSDOS, Unix and other systems this is '..', but maybe different
@@ -10488,7 +10498,7 @@
 !UnixOperatingSystem::FilePointerHandle class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.126 2002-09-25 09:51:14 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.127 2002-09-27 11:59:27 penk Exp $'
 ! !
 
 !UnixOperatingSystem::FilePointerHandle methodsFor:'release'!
@@ -10670,6 +10680,29 @@
     numLinks := nL.
 ! !
 
+!UnixOperatingSystem::MountInfo methodsFor:'accessing'!
+
+mountPointPath
+    "return the value of the instance variable 'mountPointPath' (automatically generated)"
+
+    ^ mountPointPath
+!
+
+mountPointPath:mountPointArg deviceOrRemotePath:deviceOrRemotePathArg fsType:fsTypeArg attributeString:attributeStringArg 
+    "set instance variables (automatically generated)"
+
+    mountPointPath := mountPointArg.
+    deviceOrRemotePath := deviceOrRemotePathArg.
+    fsType := fsTypeArg.
+    attributeString := attributeStringArg.
+! !
+
+!UnixOperatingSystem::MountInfo methodsFor:'queries'!
+
+isRemote
+    ^ fsType = 'nfs'
+! !
+
 !UnixOperatingSystem::OSProcessStatus class methodsFor:'documentation'!
 
 documentation
@@ -12108,7 +12141,7 @@
 !UnixOperatingSystem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.126 2002-09-25 09:51:14 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.127 2002-09-27 11:59:27 penk Exp $'
 ! !
 
 UnixOperatingSystem initialize!