help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Some changes to 2.2b


From: J Pfersich
Subject: [Help-smalltalk] Some changes to 2.2b
Date: Sun, 22 Oct 2006 23:36:34 -0600

Here are a few changes for gst. Some are bug fixes, some are additions that I've been using. The fixes are in CharArray.st and VFS.st. The VFS bug is the createDir creation of the directory with permissions of 777. I think that world writable directories are a bad idea.

VFS.st and File.st have changes made to the isFile method and other additions I've been using for a while now. I didn't include an isPipe in File, although it might be useful

In the Character Array class, the isNumeric method probably should be in a "testing" category instead of the "conversion" category. Also, it should probably be set up to handle fractions and floats with exponents, too.

--- CharArray.st.orig   2006-09-22 03:49:34.000000000 -0600
+++ CharArray.st        2006-10-22 22:17:41.000000000 -0600
@@ -471,11 +471,11 @@
       (ch := stream next) isDigit ] whileTrue: [
     ].
     ch = $. ifFalse: [^false].

     [   ch := stream next.
-       ch isDigit ifFalse: [ ^false ]
+       ch isDigit ifFalse: [ ^false ].
        stream atEnd] whileFalse.
     ^true
 !

 asSymbol


--- VFS.st.orig 2006-09-08 00:43:56.000000000 -0600
+++ VFS.st      2006-10-20 22:41:46.000000000 -0600
@@ -44,11 +44,11 @@
 implementations of File and Directory.  These classes only
 delegate to the appropriate handler, which is in charge of
 actually accessing or ``molding'''' the filesystem.'!

 VFSHandler subclass: #RealFileHandler
-       instanceVariableNames: 'stat isSymbolicLink'
+       instanceVariableNames: 'stat isRegularFile isSocket isSymbolicLink'
        classVariableNames: 'Epoch'
        poolDictionaries: ''
        category: 'Streams-Files'
 !

@@ -325,10 +325,20 @@
 exists
"Answer whether a file with the name contained in the receiver does exist."

     ^true
 !

+isRegularFile
+    "Answer whether the file is a regular file."
+    ^false
+!
+
+isSocket
+    "Answer whether the file is a socket."
+    ^false
+!
+
 isSymbolicLink
     "Answer whether the file is a symbolic link."
     ^false
 !

@@ -431,10 +441,22 @@
 size
     "Answer the size of the file identified by the receiver"
     ^self stat stSize value
 !

+isRegularFile
+    "Answer whether the file is a regular file."
+    isRegularFile isNil ifTrue: [ self refresh ].
+    ^isRegularFile
+!
+
+isSocket
+    "Answer whether the file is a socket."
+    isSocket isNil ifTrue: [ self refresh ].
+    ^isSocket
+!
+
 isSymbolicLink
     "Answer whether the file is a symbolic link."
     isSymbolicLink isNil ifTrue: [ self refresh ].
     ^isSymbolicLink
 !
@@ -472,12 +494,14 @@
         stat := CStatStruct new.
         stat addToBeFinalized
     ].
     self lstatOn: self realFileName into: stat.
     File checkError.
+    isSocket := (stat stMode value bitAnd: 8r170000) = 8r140000. "S_IFSOCK"
isSymbolicLink := (stat stMode value bitAnd: 8r170000) = 8r120000. "S_IFLNK
"
-    isSymbolicLink ifTrue: [
+ isRegularFile := (stat stMode value bitAnd: 8r170000) = 8r100000. "S_IFREG"

+    (isRegularFile | isSocket) | isSymbolicLink ifTrue: [
        self statOn: self realFileName into: stat.
        File checkError ]
 ! !


@@ -584,11 +608,11 @@

 createDir: dirName
     "Create a subdirectory of the receiver, naming it dirName."
     self
         primCreateDir: (Directory append: dirName to: self realFileName)
-        mode: 8r777.
+        mode: 8r755.

     File checkError
 !

 do: aBlock


--- File.st.orig        2006-10-02 02:40:56.000000000 -0600
+++ File.st     2006-10-20 22:42:02.000000000 -0600
@@ -310,27 +310,33 @@
     ^vfsHandler exists
 !

 isSymbolicLink
     "Answer whether a file with the name contained in the receiver does exist
-    and does not identify a directory."
+    and does identify a symbolic link."
     ^vfsHandler exists and: [ vfsHandler isSymbolicLink ]
 !

 isFile
     "Answer whether a file with the name contained in the receiver does exist
-    and does not identify a directory."
-    ^vfsHandler exists and: [ vfsHandler isDirectory not ]
+    and does identify a regular file."
+    ^vfsHandler exists and: [ vfsHandler isRegularFile ]
 !

 isDirectory
     "Answer whether a file with the name contained in the receiver does exist
     and identifies a directory."
     | dir errno |
     ^vfsHandler exists and: [ vfsHandler isDirectory ]
 !

+isSocket
+    "Answer whether a file with the name contained in the receiver does exist
+    and does identify a socket."
+    ^vfsHandler exists and: [ vfsHandler isSocket ]
+!
+
 isReadable
     "Answer whether a file with the name contained in the receiver does exist
      and is readable"
     ^vfsHandler exists and: [ vfsHandler isReadable ]!





reply via email to

[Prev in Thread] Current Thread [Next in Thread]