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 ]! _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
J Pfersich wrote:
> 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. Wrong, the OS should take into account the umask shouldn't it? 0x777 means "all bits not set in the umask", not world writable. > 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 Okay. > 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. You're probably right. Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by J Pfersich
> 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 For now, I'm applying this patch which is actually quite orthogonal to yours. It implements isDirectory in terms of the st_mode field of struct stat. From here, you can implement things such as isRegularFile, isSocket, etc. Note that this is different from symbolic links, where you use lstat first to get isSymbolicLink, and if it is a symbolic link you use stat to get the real data. The latter step, however, destroys the isSymbolicLink data, so you have to save it. You don't need anything similar for other special files. Paolo 2006-10-27 Paolo Bonzini <[hidden email]> * kernel/VFS.st: Implement isDirectory by accessing struct stat. --- orig/kernel/VFS.st +++ mod/kernel/VFS.st @@ -335,7 +335,8 @@ isSymbolicLink isDirectory "Answer whether a file with the name contained in the receiver does exist and identifies a directory." - self subclassResponsibility! + ^false +! isReadable "Answer whether a file with the name contained in the receiver does exist @@ -433,6 +434,11 @@ size ^self stat stSize value ! +isDirectory + "Answer whether the file is a directory." + ^(self stat stMode value bitAnd: 8r170000) = 8r040000 +! + isSymbolicLink "Answer whether the file is a symbolic link." isSymbolicLink isNil ifTrue: [ self refresh ]. @@ -494,21 +500,6 @@ exists ^File errno == 0 ! -isDirectory - "Answer whether a file with the name contained in the receiver does exist - and identifies a directory." - | dir errno | - dir := self openDir: self realFileName. - errno := File errno. - (errno = 0) ifTrue: [ - self closeDir: dir. - ^true - ]. - errno = 20 ifTrue: [ ^false ]. - errno = 13 ifTrue: [ ^true ]. - File checkError: errno -! - isReadable "Answer whether a file with the name contained in the receiver does exist and is readable" _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini
At 08:13 AM 10/27/2006 +0900, Paolo Bonzini wrote:
>J Pfersich wrote: >>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. >Wrong, the OS should take into account the umask shouldn't it? 0x777 means >"all bits not set in the umask", not world writable. >>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 >Okay. >>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. >You're probably right. Do you want me to take a shot at it? >Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
>>> 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. >> You're probably right. > > Do you want me to take a shot at it? Why not. Take inspiration from RBScanner in compiler/RBParser.st, maybe. Thanks, Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini
At 08:13 AM 10/27/2006 +0900, Paolo Bonzini wrote:
>J Pfersich wrote: >>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. >Wrong, the OS should take into account the umask shouldn't it? 0x777 means >"all bits not set in the umask", not world writable. Actually, I'm sure that it's the shell that sets the umask. On my machines (SUSE Linux and MacOSX 10.3.9) Linux sets the umask in /etc/csh.login and profile; for Apple, I think the OS has 022 built-in (who knows where). At least I have a process that isn't the child of a shell and it's creating directories 777 to put its log files into (it's a server). And there's no method that allows you to modify the umask so that you can make it 022 or 002. I can do that but as a stopgap I changed the permissions to 775 so that the directories aren't world writable (the write bit is not set for others) but are writable by others in the group. >>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 >Okay. >>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. >You're probably right. > >Paolo _______________________________________________ help-smalltalk mailing list [hidden email] http://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |