class: UUID
authorStefan Vogel <sv@exept.de>
Thu, 25 Apr 2013 09:12:17 +0200
changeset 2978 4497be5fc993
parent 2977 afc4d10019c7
child 2979 8bfdd76f67e1
class: UUID comment/format in: #genRandomUUID changed: #fromBytes:msb: #getValidMACAddress
UUID.st
--- a/UUID.st	Mon Apr 22 17:48:57 2013 +0200
+++ b/UUID.st	Thu Apr 25 09:12:17 2013 +0200
@@ -168,6 +168,7 @@
 !
 
 fromBytes:aByteArray msb:msb
+    <resource: #obsolete>
     "Set the UUID from aByteArray. UUIDS are stored internally as MSB-first. 
      So, alway set
         msb = true      if reading from network or persistent storage"
@@ -391,13 +392,14 @@
 !
 
 getValidMACAddress
-    "return the first valid MAC address (i.e. having at least one byte ~~ 0)"
+    "return the first valid MAC address (i.e. having at least 6 bytes with the first six bytes ~~ 0)"
 
     CachedMACAddress isNil ifTrue:[
-        CachedMACAddress := false.      "cache the fact, that there is no MAC address" 
+        CachedMACAddress := false.      "negative caching: remember the fact, that there is no MAC address" 
         [
             CachedMACAddress := OperatingSystem getNetworkMACAddresses 
-                                    detect:[:macAddress | macAddress ~= #[0 0 0 0 0 0]]
+                                    detect:[:macAddress | macAddress size >= 6 
+                                                            and:[(macAddress startsWith:#[0 0 0 0 0 0]) not]]
                                     ifNone:false.
         ] on:PrimitiveFailure do:[:ex| "ignore"].
     ].
@@ -587,8 +589,7 @@
     self at:9 put:(((self at:9) bitAnd:16r3F) bitOr:16r80).
 
     "
-      self new genRandomUUID
-
+      self genRandomUUID
       self genRandomUUID genRandomUUID
     "
 
@@ -879,11 +880,11 @@
 !UUID class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.44 2013-04-22 15:48:57 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.45 2013-04-25 07:12:17 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.44 2013-04-22 15:48:57 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/UUID.st,v 1.45 2013-04-25 07:12:17 stefan Exp $'
 ! !