2013-04-28 Holger Hans Peter Freyther <[hidden email]>
* kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and File>>#primSync to use the new primitives. 2013-04-28 Holger Hans Peter Freyther <[hidden email]> * libgst/cint.c: Bind link, fsync, sync for additional C level access. --- ChangeLog | 5 +++++ kernel/File.st | 15 +++++++++++++++ libgst/ChangeLog | 4 ++++ libgst/cint.c | 3 +++ 4 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6b6d9d2..c45d2a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-04-28 Holger Hans Peter Freyther <[hidden email]> + + * kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and + File>>#primSync to use the new primitives. + 2013-03-04 Holger Hans Peter Freyther <[hidden email]> * kernel/PkgLoader.st: Remove unused variable. diff --git a/kernel/File.st b/kernel/File.st index 426a415..b40e9bd 100644 --- a/kernel/File.st +++ b/kernel/File.st @@ -259,6 +259,11 @@ FilePath subclass: File [ ] + primLink: srcName as: destName [ + <category: 'private-C call-outs'> + <cCall: 'link' returning: #int args: #(#string #string)> + ] + primSymlink: srcName as: destName [ <category: 'private-C call-outs'> <cCall: 'symlink' returning: #int args: #(#string #string)> @@ -289,6 +294,16 @@ FilePath subclass: File [ ] + primFsync: aFd [ + <category: 'private-C call-outs'> + <cCall: 'fsync' returning: #int args: #(#int)> + ] + + primSync [ + <category: 'private-C call-outs'> + <cCall: 'sync' returning: #int args: #()> + ] + extractDirentName: dirent [ <category: 'private-C call-outs'> <cCall: 'extractDirentName' returning: #string args: #(#cObject)> diff --git a/libgst/ChangeLog b/libgst/ChangeLog index e95a837..9cf1626 100644 --- a/libgst/ChangeLog +++ b/libgst/ChangeLog @@ -1,3 +1,7 @@ +2013-04-28 Holger Hans Peter Freyther <[hidden email]> + + * libgst/cint.c: Bind link, fsync, sync for additional C level access. + 2013-02-24 Holger Hans Peter Freyther <[hidden email]> * libgst/dict.c: Remove ATTRIBUTE_HIDDEN from static methods. diff --git a/libgst/cint.c b/libgst/cint.c index 77c8f8c..57a6efd 100644 --- a/libgst/cint.c +++ b/libgst/cint.c @@ -641,6 +641,7 @@ _gst_init_cfuncs (void) _gst_define_cfunc ("rewinddir", rewinddir); _gst_define_cfunc ("extractDirentName", extract_dirent_name); + _gst_define_cfunc ("link", link); _gst_define_cfunc ("symlink", my_symlink); _gst_define_cfunc ("unlink", unlink); _gst_define_cfunc ("rename", rename); @@ -649,6 +650,8 @@ _gst_init_cfuncs (void) _gst_define_cfunc ("mkdir", my_mkdir); _gst_define_cfunc ("mkdtemp", my_mkdtemp); _gst_define_cfunc ("getCurDirName", _gst_get_cur_dir_name); + _gst_define_cfunc ("fsync", fsync); + _gst_define_cfunc ("sync", sync); _gst_define_cfunc ("fileIsReadable", _gst_file_is_readable); _gst_define_cfunc ("fileIsWriteable", _gst_file_is_writeable); -- 1.7.10.4 _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
From: Holger Hans Peter Freyther <[hidden email]>
Add a way to load a Package from the package.xml and not go through the creation of a star file. This can make developing with packages more effective. 2013-03-24 Holger Hans Peter Freyther <[hidden email]> * libgst/files.c: Add DirPackage.st to the bootstrap. * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer. * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass. --- ChangeLog | 7 ++++ NEWS | 7 ++++ kernel/DirPackage.st | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/Makefile.frag | 2 +- kernel/PkgLoader.st | 28 ++++++++++----- libgst/files.c | 1 + packages.xml | 1 + 7 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 kernel/DirPackage.st diff --git a/ChangeLog b/ChangeLog index c45d2a0..6c2abb5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,15 @@ +2013-03-24 Holger Hans Peter Freyther <[hidden email]> + + * libgst/files.c: Add DirPackage.st to the bootstrap. + * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer. + * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass. + 2013-04-28 Holger Hans Peter Freyther <[hidden email]> * kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and File>>#primSync to use the new primitives. + 2013-03-04 Holger Hans Peter Freyther <[hidden email]> * kernel/PkgLoader.st: Remove unused variable. diff --git a/NEWS b/NEWS index b5e9127..d768a8f 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ List of user-visible changes in GNU Smalltalk +NEWS FROM 3.2.5 to 3.2.90 + +o Add PackageLoader>>#loadPackageFromFile: to load a package by using + a package.xml. This can make the development more effective. + +----------------------------------------------------------------------------- + NEWS FROM 3.2.4 to 3.2.5 o Add Delay>>#value:onTimeoutDo: as an easy way to timeout an operation. diff --git a/kernel/DirPackage.st b/kernel/DirPackage.st new file mode 100644 index 0000000..784d5cd --- /dev/null +++ b/kernel/DirPackage.st @@ -0,0 +1,92 @@ +"====================================================================== +| +| Load packages from a directory without loading a Star file. +| +| + ======================================================================" + +"====================================================================== +| +| Copyright 2013 +| Free Software Foundation, Inc. +| Written by Holger Hans Peter Freyther. +| +| This file is part of the GNU Smalltalk class library. +| +| The GNU Smalltalk class library is free software; you can redistribute it +| and/or modify it under the terms of the GNU Lesser General Public License +| as published by the Free Software Foundation; either version 2.1, or (at +| your option) any later version. +| +| The GNU Smalltalk class library is distributed in the hope that it will be +| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser +| General Public License for more details. +| +| You should have received a copy of the GNU Lesser General Public License +| along with the GNU Smalltalk class library; see the file COPYING.LIB. +| If not, write to the Free Software Foundation, 59 Temple Place - Suite +| 330, Boston, MA 02110-1301, USA. +| + ======================================================================" + +Namespace current: Kernel [ + +ExternalPackage subclass: DirPackage [ + <category: 'Language-Packaging'> + <comment: 'I can parse a package.xml from a directort and treat it + like a package. This allows loading packages from a directory without + the need of zipping them first.'> + + DirPackage class >> file: aFile [ + ^ self new + file: aFile; + yourself + ] + + directory [ + ^ self file asFile directory. + ] + + name [ + "Pick the name of the loaded package" + ^ self loadedPackage name. + ] + + loadedPackage [ + <category: 'accessing'> + | file package | + loadedPackage isNil ifFalse: [^loadedPackage]. + file := self file asFile. + package := Package parse: file readStream. + package isNil + ifTrue: [^self error: 'invalid disabled-package tag inside a star file']. + package relativeDirectory: file directory. + package baseDirectories: {file directory}. + package name isNil + ifTrue: [^self error: 'package name must not be nil']. + loadedPackage := package. + ^loadedPackage + ] +] + +] + +PackageLoader class extend [ + + loadPackageFromFile: aFileName [ + | package | + <category: '*Language-Kernel'> + + "Make sure that root is initialized." + self refresh. + + "Add the 'directory' to the packages" + package := Kernel.DirPackage file: aFileName. + + "And now file it in. Do not use >>fileIn as it will + attempt to load the package by name." + self fileInPackages: package prerequisites. + package primFileIn. + ] +] diff --git a/kernel/Makefile.frag b/kernel/Makefile.frag index e61f2be..fb4b3d2 100644 --- a/kernel/Makefile.frag +++ b/kernel/Makefile.frag @@ -1,3 +1,3 @@ $(srcdir)/kernel/stamp-classes: \ -kernel/Array.st kernel/CompildMeth.st kernel/LookupTable.st kernel/RunArray.st kernel/Iterable.st kernel/ArrayColl.st kernel/CompiledBlk.st kernel/Magnitude.st kernel/Semaphore.st kernel/DeferBinding.st kernel/Association.st kernel/HomedAssoc.st kernel/ContextPart.st kernel/MappedColl.st kernel/SeqCollect.st kernel/Autoload.st kernel/DLD.st kernel/Memory.st kernel/Set.st kernel/Bag.st kernel/Date.st kernel/Message.st kernel/MessageLookup.st kernel/SharedQueue.st kernel/Behavior.st kernel/Delay.st kernel/Metaclass.st kernel/SmallInt.st kernel/BlkClosure.st kernel/Continuation.st kernel/Generator.st kernel/Dictionary.st kernel/MethodDict.st kernel/SortCollect.st kernel/BlkContext.st kernel/DirMessage.st kernel/MethodInfo.st kernel/Stream.st kernel/Boolean.st kernel/Directory.st kernel/MthContext.st kernel/String.st kernel/UniString.st kernel/ExcHandling.st kernel/Namespace.st kernel/SymLink.st kernel/VFS.st kernel/VFSZip.st kernel/Builtins.st kernel/False.st kernel/Number.st kernel/Sy mbol.st kernel/ByteArray.st kernel/FilePath.st kernel/File.st kernel/SysDict.st kernel/ScaledDec.st kernel/FileSegment.st kernel/Object.st kernel/Time.st kernel/FileStream.st kernel/OrderColl.st kernel/CCallable.st kernel/CCallback.st kernel/CFuncs.st kernel/Float.st kernel/PkgLoader.st kernel/Transcript.st kernel/CObject.st kernel/Fraction.st kernel/Point.st kernel/True.st kernel/CStruct.st kernel/IdentDict.st kernel/PosStream.st kernel/UndefObject.st kernel/CType.st kernel/IdentitySet.st kernel/ProcSched.st kernel/ProcEnv.st kernel/ValueAdapt.st kernel/CharArray.st kernel/Integer.st kernel/Process.st kernel/CallinProcess.st kernel/WeakObjects.st kernel/Character.st kernel/UniChar.st kernel/Interval.st kernel/RWStream.st kernel/OtherArrays.st kernel/Class.st kernel/LargeInt.st kernel/Random.st kernel/WriteStream.st kernel/ClassDesc.st kernel/Link.st kernel/ReadStream.st kernel/ObjMemory.st kernel/Collection.st kernel/LinkedList.st kernel/Rectangle.st kernel/AnsiDates.st kernel/Comp ildCode.st kernel/LookupKey.st kernel/BindingDict.st kernel/AbstNamespc.st kernel/RootNamespc.st kernel/SysExcept.st kernel/DynVariable.st kernel/HashedColl.st kernel/FileDescr.st kernel/FloatD.st kernel/FloatE.st kernel/FloatQ.st kernel/URL.st kernel/VarBinding.st kernel/RecursionLock.st kernel/Getopt.st kernel/Regex.st kernel/StreamOps.st +kernel/Array.st kernel/CompildMeth.st kernel/LookupTable.st kernel/RunArray.st kernel/Iterable.st kernel/ArrayColl.st kernel/CompiledBlk.st kernel/Magnitude.st kernel/Semaphore.st kernel/DeferBinding.st kernel/Association.st kernel/HomedAssoc.st kernel/ContextPart.st kernel/MappedColl.st kernel/SeqCollect.st kernel/Autoload.st kernel/DLD.st kernel/Memory.st kernel/Set.st kernel/Bag.st kernel/Date.st kernel/Message.st kernel/MessageLookup.st kernel/SharedQueue.st kernel/Behavior.st kernel/Delay.st kernel/Metaclass.st kernel/SmallInt.st kernel/BlkClosure.st kernel/Continuation.st kernel/Generator.st kernel/Dictionary.st kernel/MethodDict.st kernel/SortCollect.st kernel/BlkContext.st kernel/DirMessage.st kernel/MethodInfo.st kernel/Stream.st kernel/Boolean.st kernel/Directory.st kernel/MthContext.st kernel/String.st kernel/UniString.st kernel/ExcHandling.st kernel/Namespace.st kernel/SymLink.st kernel/VFS.st kernel/VFSZip.st kernel/Builtins.st kernel/False.st kernel/Number.st kernel/Sy mbol.st kernel/ByteArray.st kernel/FilePath.st kernel/File.st kernel/SysDict.st kernel/ScaledDec.st kernel/FileSegment.st kernel/Object.st kernel/Time.st kernel/FileStream.st kernel/OrderColl.st kernel/CCallable.st kernel/CCallback.st kernel/CFuncs.st kernel/Float.st kernel/PkgLoader.st kernel/DirPackage.st kernel/Transcript.st kernel/CObject.st kernel/Fraction.st kernel/Point.st kernel/True.st kernel/CStruct.st kernel/IdentDict.st kernel/PosStream.st kernel/UndefObject.st kernel/CType.st kernel/IdentitySet.st kernel/ProcSched.st kernel/ProcEnv.st kernel/ValueAdapt.st kernel/CharArray.st kernel/Integer.st kernel/Process.st kernel/CallinProcess.st kernel/WeakObjects.st kernel/Character.st kernel/UniChar.st kernel/Interval.st kernel/RWStream.st kernel/OtherArrays.st kernel/Class.st kernel/LargeInt.st kernel/Random.st kernel/WriteStream.st kernel/ClassDesc.st kernel/Link.st kernel/ReadStream.st kernel/ObjMemory.st kernel/Collection.st kernel/LinkedList.st kernel/Rectangle.st kernel/Ans iDates.st kernel/CompildCode.st kernel/LookupKey.st kernel/BindingDict.st kernel/AbstNamespc.st kernel/RootNamespc.st kernel/SysExcept.st kernel/DynVariable.st kernel/HashedColl.st kernel/FileDescr.st kernel/FloatD.st kernel/FloatE.st kernel/FloatQ.st kernel/URL.st kernel/VarBinding.st kernel/RecursionLock.st kernel/Getopt.st kernel/Regex.st kernel/StreamOps.st touch $(srcdir)/kernel/stamp-classes diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st index b9748f2..53d9367 100644 --- a/kernel/PkgLoader.st +++ b/kernel/PkgLoader.st @@ -917,20 +917,12 @@ XML.'> Namespace current: Kernel [ -PackageInfo subclass: StarPackage [ +PackageInfo subclass: ExternalPackage [ | file loadedPackage | <category: 'Language-Packaging'> <comment: nil> - StarPackage class >> file: file [ - <category: 'accessing'> - ^(self new) - file: file; - name: (File stripPathFrom: (File stripExtensionFrom: file name)); - yourself - ] - fullPathOf: fileName [ "Try appending 'self directory' and fileName to each of the directory in baseDirectories, and return the path to the first tried filename that @@ -1079,6 +1071,24 @@ PackageInfo subclass: StarPackage [ ] loadedPackage [ + ^ self subclassResponsibility + ] +] + +ExternalPackage subclass: StarPackage [ + + <category: 'Language-Packaging'> + <comment: 'I represent an external package in the form of a .star package'> + + StarPackage class >> file: file [ + <category: 'accessing'> + ^(self new) + file: file; + name: (File stripPathFrom: (File stripExtensionFrom: file name)); + yourself + ] + + loadedPackage [ <category: 'accessing'> | package | loadedPackage isNil ifFalse: [^loadedPackage]. diff --git a/libgst/files.c b/libgst/files.c index ec33933..a7156f9 100644 --- a/libgst/files.c +++ b/libgst/files.c @@ -288,6 +288,7 @@ static const char standard_files[] = { "StreamOps.st\0" "Regex.st\0" "PkgLoader.st\0" + "DirPackage.st\0" "Autoload.st\0" }; diff --git a/packages.xml b/packages.xml index c6d0e8c..fc6a049 100644 --- a/packages.xml +++ b/packages.xml @@ -152,6 +152,7 @@ <file>CFuncs.st</file> <file>Float.st</file> <file>PkgLoader.st</file> + <file>DirPackage.st</file> <file>Transcript.st</file> <file>CObject.st</file> <file>Fraction.st</file> -- 1.7.10.4 _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Holger Freyther
Il 05/05/2013 11:23, Holger Hans Peter Freyther ha scritto:
> 2013-04-28 Holger Hans Peter Freyther <[hidden email]> > > * kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and > File>>#primSync to use the new primitives. #primFsync should be an additional file primitive, and the method should be in FileDescriptor. FileStream should override it and first flush the buffer. BTW, you probably want to check for fdatasync and use it is available. #primSync should just be #sync and a class method; #primLink:as: should have matching methods that call it on a File object (with an abstract version on FilePath, probably) and that call #checkError to raise exceptions properly. In other word you can copy a lot of how symlinks work (with some simplifications because you don't have to handle relative paths). Thanks! Paolo > 2013-04-28 Holger Hans Peter Freyther <[hidden email]> > > * libgst/cint.c: Bind link, fsync, sync for additional C level access. > --- > ChangeLog | 5 +++++ > kernel/File.st | 15 +++++++++++++++ > libgst/ChangeLog | 4 ++++ > libgst/cint.c | 3 +++ > 4 files changed, 27 insertions(+) > > diff --git a/ChangeLog b/ChangeLog > index 6b6d9d2..c45d2a0 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,3 +1,8 @@ > +2013-04-28 Holger Hans Peter Freyther <[hidden email]> > + > + * kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and > + File>>#primSync to use the new primitives. > + > 2013-03-04 Holger Hans Peter Freyther <[hidden email]> > > * kernel/PkgLoader.st: Remove unused variable. > diff --git a/kernel/File.st b/kernel/File.st > index 426a415..b40e9bd 100644 > --- a/kernel/File.st > +++ b/kernel/File.st > @@ -259,6 +259,11 @@ FilePath subclass: File [ > > ] > > + primLink: srcName as: destName [ > + <category: 'private-C call-outs'> > + <cCall: 'link' returning: #int args: #(#string #string)> > + ] > + > primSymlink: srcName as: destName [ > <category: 'private-C call-outs'> > <cCall: 'symlink' returning: #int args: #(#string #string)> > @@ -289,6 +294,16 @@ FilePath subclass: File [ > > ] > > + primFsync: aFd [ > + <category: 'private-C call-outs'> > + <cCall: 'fsync' returning: #int args: #(#int)> > + ] > + > + primSync [ > + <category: 'private-C call-outs'> > + <cCall: 'sync' returning: #int args: #()> > + ] > + > extractDirentName: dirent [ > <category: 'private-C call-outs'> > <cCall: 'extractDirentName' returning: #string args: #(#cObject)> > diff --git a/libgst/ChangeLog b/libgst/ChangeLog > index e95a837..9cf1626 100644 > --- a/libgst/ChangeLog > +++ b/libgst/ChangeLog > @@ -1,3 +1,7 @@ > +2013-04-28 Holger Hans Peter Freyther <[hidden email]> > + > + * libgst/cint.c: Bind link, fsync, sync for additional C level access. > + > 2013-02-24 Holger Hans Peter Freyther <[hidden email]> > > * libgst/dict.c: Remove ATTRIBUTE_HIDDEN from static methods. > diff --git a/libgst/cint.c b/libgst/cint.c > index 77c8f8c..57a6efd 100644 > --- a/libgst/cint.c > +++ b/libgst/cint.c > @@ -641,6 +641,7 @@ _gst_init_cfuncs (void) > _gst_define_cfunc ("rewinddir", rewinddir); > _gst_define_cfunc ("extractDirentName", extract_dirent_name); > > + _gst_define_cfunc ("link", link); > _gst_define_cfunc ("symlink", my_symlink); > _gst_define_cfunc ("unlink", unlink); > _gst_define_cfunc ("rename", rename); > @@ -649,6 +650,8 @@ _gst_init_cfuncs (void) > _gst_define_cfunc ("mkdir", my_mkdir); > _gst_define_cfunc ("mkdtemp", my_mkdtemp); > _gst_define_cfunc ("getCurDirName", _gst_get_cur_dir_name); > + _gst_define_cfunc ("fsync", fsync); > + _gst_define_cfunc ("sync", sync); > > _gst_define_cfunc ("fileIsReadable", _gst_file_is_readable); > _gst_define_cfunc ("fileIsWriteable", _gst_file_is_writeable); > _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Holger Freyther
Il 05/05/2013 11:23, Holger Hans Peter Freyther ha scritto:
> From: Holger Hans Peter Freyther <[hidden email]> > > Add a way to load a Package from the package.xml and not go through > the creation of a star file. This can make developing with packages > more effective. Almost ok, please fix the nits below and commit. > 2013-03-24 Holger Hans Peter Freyther <[hidden email]> > > * libgst/files.c: Add DirPackage.st to the bootstrap. > * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer. > * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass. > --- > ChangeLog | 7 ++++ > NEWS | 7 ++++ > kernel/DirPackage.st | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ > kernel/Makefile.frag | 2 +- > kernel/PkgLoader.st | 28 ++++++++++----- > libgst/files.c | 1 + > packages.xml | 1 + > 7 files changed, 128 insertions(+), 10 deletions(-) > create mode 100644 kernel/DirPackage.st > > diff --git a/ChangeLog b/ChangeLog > index c45d2a0..6c2abb5 100644 > --- a/ChangeLog > +++ b/ChangeLog > @@ -1,8 +1,15 @@ > +2013-03-24 Holger Hans Peter Freyther <[hidden email]> > + > + * libgst/files.c: Add DirPackage.st to the bootstrap. > + * kernel/DirPackage.st: Add new file with the DirPackage and DirPackagesContainer. > + * kernel/PkgLoader.st: Refactor and create ExternalPackage baseclass. Obsolete ChangeLog :) > 2013-04-28 Holger Hans Peter Freyther <[hidden email]> > > * kernel/File.st: Add File>>#primLink:as:, File>>#primFsync: and > File>>#primSync to use the new primitives. > > + > 2013-03-04 Holger Hans Peter Freyther <[hidden email]> > > * kernel/PkgLoader.st: Remove unused variable. > diff --git a/NEWS b/NEWS > index b5e9127..d768a8f 100644 > --- a/NEWS > +++ b/NEWS > @@ -1,5 +1,12 @@ > List of user-visible changes in GNU Smalltalk > > +NEWS FROM 3.2.5 to 3.2.90 > + > +o Add PackageLoader>>#loadPackageFromFile: to load a package by using > + a package.xml. This can make the development more effective. > + > +----------------------------------------------------------------------------- > + > NEWS FROM 3.2.4 to 3.2.5 > > o Add Delay>>#value:onTimeoutDo: as an easy way to timeout an operation. > diff --git a/kernel/DirPackage.st b/kernel/DirPackage.st > new file mode 100644 > index 0000000..784d5cd > --- /dev/null > +++ b/kernel/DirPackage.st > @@ -0,0 +1,92 @@ > +"====================================================================== > +| > +| Load packages from a directory without loading a Star file. > +| > +| > + ======================================================================" > + > +"====================================================================== > +| > +| Copyright 2013 > +| Free Software Foundation, Inc. > +| Written by Holger Hans Peter Freyther. > +| > +| This file is part of the GNU Smalltalk class library. > +| > +| The GNU Smalltalk class library is free software; you can redistribute it > +| and/or modify it under the terms of the GNU Lesser General Public License > +| as published by the Free Software Foundation; either version 2.1, or (at > +| your option) any later version. > +| > +| The GNU Smalltalk class library is distributed in the hope that it will be > +| useful, but WITHOUT ANY WARRANTY; without even the implied warranty of > +| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser > +| General Public License for more details. > +| > +| You should have received a copy of the GNU Lesser General Public License > +| along with the GNU Smalltalk class library; see the file COPYING.LIB. > +| If not, write to the Free Software Foundation, 59 Temple Place - Suite > +| 330, Boston, MA 02110-1301, USA. > +| > + ======================================================================" > + > +Namespace current: Kernel [ > + > +ExternalPackage subclass: DirPackage [ > + <category: 'Language-Packaging'> > + <comment: 'I can parse a package.xml from a directort and treat it typo (directory) > + like a package. This allows loading packages from a directory without > + the need of zipping them first.'> > + > + DirPackage class >> file: aFile [ > + ^ self new > + file: aFile; > + yourself > + ] > + > + directory [ > + ^ self file asFile directory. > + ] > + > + name [ > + "Pick the name of the loaded package" > + ^ self loadedPackage name. > + ] > + > + loadedPackage [ > + <category: 'accessing'> > + | file package | > + loadedPackage isNil ifFalse: [^loadedPackage]. > + file := self file asFile. > + package := Package parse: file readStream. > + package isNil > + ifTrue: [^self error: 'invalid disabled-package tag inside a star file']. > + package relativeDirectory: file directory. > + package baseDirectories: {file directory}. > + package name isNil > + ifTrue: [^self error: 'package name must not be nil']. > + loadedPackage := package. > + ^loadedPackage Anything we can move to ExternalPackage? Can be done as a followup, though. > + ] > +] > + > +] > + > +PackageLoader class extend [ > + > + loadPackageFromFile: aFileName [ > + | package | > + <category: '*Language-Kernel'> > + > + "Make sure that root is initialized." > + self refresh. > + > + "Add the 'directory' to the packages" > + package := Kernel.DirPackage file: aFileName. > + > + "And now file it in. Do not use >>fileIn as it will > + attempt to load the package by name." > + self fileInPackages: package prerequisites. > + package primFileIn. > + ] > +] > diff --git a/kernel/Makefile.frag b/kernel/Makefile.frag > index e61f2be..fb4b3d2 100644 > --- a/kernel/Makefile.frag > +++ b/kernel/Makefile.frag > @@ -1,3 +1,3 @@ > $(srcdir)/kernel/stamp-classes: \ > -kernel/Array.st kernel/CompildMeth.st kernel/LookupTable.st kernel/RunArray.st kernel/Iterable.st kernel/ArrayColl.st kernel/CompiledBlk.st kernel/Magnitude.st kernel/Semaphore.st kernel/DeferBinding.st kernel/Association.st kernel/HomedAssoc.st kernel/ContextPart.st kernel/MappedColl.st kernel/SeqCollect.st kernel/Autoload.st kernel/DLD.st kernel/Memory.st kernel/Set.st kernel/Bag.st kernel/Date.st kernel/Message.st kernel/MessageLookup.st kernel/SharedQueue.st kernel/Behavior.st kernel/Delay.st kernel/Metaclass.st kernel/SmallInt.st kernel/BlkClosure.st kernel/Continuation.st kernel/Generator.st kernel/Dictionary.st kernel/MethodDict.st kernel/SortCollect.st kernel/BlkContext.st kernel/DirMessage.st kernel/MethodInfo.st kernel/Stream.st kernel/Boolean.st kernel/Directory.st kernel/MthContext.st kernel/String.st kernel/UniString.st kernel/ExcHandling.st kernel/Namespace.st kernel/SymLink.st kernel/VFS.st kernel/VFSZip.st kernel/Builtins.st kernel/False.st kernel/Number.st kernel/S > mbol.st kernel/ByteArray.st kernel/FilePath.st kernel/File.st kernel/SysDict.st kernel/ScaledDec.st kernel/FileSegment.st kernel/Object.st kernel/Time.st kernel/FileStream.st kernel/OrderColl.st kernel/CCallable.st kernel/CCallback.st kernel/CFuncs.st kernel/Float.st kernel/PkgLoader.st kernel/Transcript.st kernel/CObject.st kernel/Fraction.st kernel/Point.st kernel/True.st kernel/CStruct.st kernel/IdentDict.st kernel/PosStream.st kernel/UndefObject.st kernel/CType.st kernel/IdentitySet.st kernel/ProcSched.st kernel/ProcEnv.st kernel/ValueAdapt.st kernel/CharArray.st kernel/Integer.st kernel/Process.st kernel/CallinProcess.st kernel/WeakObjects.st kernel/Character.st kernel/UniChar.st kernel/Interval.st kernel/RWStream.st kernel/OtherArrays.st kernel/Class.st kernel/LargeInt.st kernel/Random.st kernel/WriteStream.st kernel/ClassDesc.st kernel/Link.st kernel/ReadStream.st kernel/ObjMemory.st kernel/Collection.st kernel/LinkedList.st kernel/Rectangle.st kernel/AnsiDates.st kernel/Com p > ildCode.st kernel/LookupKey.st kernel/BindingDict.st kernel/AbstNamespc.st kernel/RootNamespc.st kernel/SysExcept.st kernel/DynVariable.st kernel/HashedColl.st kernel/FileDescr.st kernel/FloatD.st kernel/FloatE.st kernel/FloatQ.st kernel/URL.st kernel/VarBinding.st kernel/RecursionLock.st kernel/Getopt.st kernel/Regex.st kernel/StreamOps.st > +kernel/Array.st kernel/CompildMeth.st kernel/LookupTable.st kernel/RunArray.st kernel/Iterable.st kernel/ArrayColl.st kernel/CompiledBlk.st kernel/Magnitude.st kernel/Semaphore.st kernel/DeferBinding.st kernel/Association.st kernel/HomedAssoc.st kernel/ContextPart.st kernel/MappedColl.st kernel/SeqCollect.st kernel/Autoload.st kernel/DLD.st kernel/Memory.st kernel/Set.st kernel/Bag.st kernel/Date.st kernel/Message.st kernel/MessageLookup.st kernel/SharedQueue.st kernel/Behavior.st kernel/Delay.st kernel/Metaclass.st kernel/SmallInt.st kernel/BlkClosure.st kernel/Continuation.st kernel/Generator.st kernel/Dictionary.st kernel/MethodDict.st kernel/SortCollect.st kernel/BlkContext.st kernel/DirMessage.st kernel/MethodInfo.st kernel/Stream.st kernel/Boolean.st kernel/Directory.st kernel/MthContext.st kernel/String.st kernel/UniString.st kernel/ExcHandling.st kernel/Namespace.st kernel/SymLink.st kernel/VFS.st kernel/VFSZip.st kernel/Builtins.st kernel/False.st kernel/Number.st kernel/S y > mbol.st kernel/ByteArray.st kernel/FilePath.st kernel/File.st kernel/SysDict.st kernel/ScaledDec.st kernel/FileSegment.st kernel/Object.st kernel/Time.st kernel/FileStream.st kernel/OrderColl.st kernel/CCallable.st kernel/CCallback.st kernel/CFuncs.st kernel/Float.st kernel/PkgLoader.st kernel/DirPackage.st kernel/Transcript.st kernel/CObject.st kernel/Fraction.st kernel/Point.st kernel/True.st kernel/CStruct.st kernel/IdentDict.st kernel/PosStream.st kernel/UndefObject.st kernel/CType.st kernel/IdentitySet.st kernel/ProcSched.st kernel/ProcEnv.st kernel/ValueAdapt.st kernel/CharArray.st kernel/Integer.st kernel/Process.st kernel/CallinProcess.st kernel/WeakObjects.st kernel/Character.st kernel/UniChar.st kernel/Interval.st kernel/RWStream.st kernel/OtherArrays.st kernel/Class.st kernel/LargeInt.st kernel/Random.st kernel/WriteStream.st kernel/ClassDesc.st kernel/Link.st kernel/ReadStream.st kernel/ObjMemory.st kernel/Collection.st kernel/LinkedList.st kernel/Rectangle.st kernel/An s > iDates.st kernel/CompildCode.st kernel/LookupKey.st kernel/BindingDict.st kernel/AbstNamespc.st kernel/RootNamespc.st kernel/SysExcept.st kernel/DynVariable.st kernel/HashedColl.st kernel/FileDescr.st kernel/FloatD.st kernel/FloatE.st kernel/FloatQ.st kernel/URL.st kernel/VarBinding.st kernel/RecursionLock.st kernel/Getopt.st kernel/Regex.st kernel/StreamOps.st > touch $(srcdir)/kernel/stamp-classes > diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st > index b9748f2..53d9367 100644 > --- a/kernel/PkgLoader.st > +++ b/kernel/PkgLoader.st > @@ -917,20 +917,12 @@ XML.'> > > Namespace current: Kernel [ > > -PackageInfo subclass: StarPackage [ > +PackageInfo subclass: ExternalPackage [ > | file loadedPackage | > > <category: 'Language-Packaging'> > <comment: nil> > > - StarPackage class >> file: file [ > - <category: 'accessing'> > - ^(self new) > - file: file; > - name: (File stripPathFrom: (File stripExtensionFrom: file name)); > - yourself > - ] > - > fullPathOf: fileName [ > "Try appending 'self directory' and fileName to each of the directory > in baseDirectories, and return the path to the first tried filename that > @@ -1079,6 +1071,24 @@ PackageInfo subclass: StarPackage [ > ] > > loadedPackage [ > + ^ self subclassResponsibility > + ] > +] > + > +ExternalPackage subclass: StarPackage [ > + > + <category: 'Language-Packaging'> > + <comment: 'I represent an external package in the form of a .star package'> > + > + StarPackage class >> file: file [ > + <category: 'accessing'> > + ^(self new) > + file: file; > + name: (File stripPathFrom: (File stripExtensionFrom: file name)); > + yourself > + ] > + > + loadedPackage [ > <category: 'accessing'> > | package | > loadedPackage isNil ifFalse: [^loadedPackage]. > diff --git a/libgst/files.c b/libgst/files.c > index ec33933..a7156f9 100644 > --- a/libgst/files.c > +++ b/libgst/files.c > @@ -288,6 +288,7 @@ static const char standard_files[] = { > "StreamOps.st\0" > "Regex.st\0" > "PkgLoader.st\0" > + "DirPackage.st\0" > "Autoload.st\0" > }; > > diff --git a/packages.xml b/packages.xml > index c6d0e8c..fc6a049 100644 > --- a/packages.xml > +++ b/packages.xml > @@ -152,6 +152,7 @@ > <file>CFuncs.st</file> > <file>Float.st</file> > <file>PkgLoader.st</file> > + <file>DirPackage.st</file> > <file>Transcript.st</file> > <file>CObject.st</file> > <file>Fraction.st</file> > _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
On Sat, May 11, 2013 at 07:20:26PM +0200, Paolo Bonzini wrote:
> Il 05/05/2013 11:23, Holger Hans Peter Freyther ha scritto: > Anything we can move to ExternalPackage? Can be done > as a followup, though. there are similiarities but also some differences to the code. _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
In reply to this post by Paolo Bonzini-2
2013-08-09 Holger Hans Peter Freyther <[hidden email]>
* kernel/FilePath.st: Add FilePath>>#linkAs: and FilePath>>#linkFrom: selectors. * kernel/File.st: Add File class>>#sync, File class>>#primFsync:, File class>>#primFdatasync, File class>>#link:as:, File class>>#link:from:, File>>#primLink:as:, File>>#linkFrom:, File>>#linkAs: selectors. * kernel/FileDescr.st: Add >>#fsync and >>#fdatasync selectors. * kernel/FileStream.st: Override >>#fsync and >>#fdatasync selectors. 2013-08-09 Holger Hans Peter Freyther <[hidden email]> * libgst/cint.c: Bind link, fsync, fdatasync and sync for additional C level access. --- ChangeLog | 10 ++++++++++ configure.ac | 2 +- kernel/File.st | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ kernel/FileDescr.st | 11 +++++++++++ kernel/FilePath.st | 13 +++++++++++++ kernel/FileStream.st | 12 ++++++++++++ libgst/ChangeLog | 5 +++++ libgst/cint.c | 8 ++++++++ 8 files changed, 112 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3c2a4f5..8a52ed2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2013-08-09 Holger Hans Peter Freyther <[hidden email]> + + * kernel/FilePath.st: Add FilePath>>#linkAs: and FilePath>>#linkFrom: + selectors. + * kernel/File.st: Add File class>>#sync, File class>>#primFsync:, + File class>>#primFdatasync, File class>>#link:as:, File class>>#link:from:, + File>>#primLink:as:, File>>#linkFrom:, File>>#linkAs: selectors. + * kernel/FileDescr.st: Add >>#fsync and >>#fdatasync selectors. + * kernel/FileStream.st: Override >>#fsync and >>#fdatasync selectors. + 2013-07-01 Gwenael Casaccio <[hidden email]> * kernel/DirPackage.st: Return the loaded package. diff --git a/configure.ac b/configure.ac index 56c09cb..bb48016 100644 --- a/configure.ac +++ b/configure.ac @@ -359,7 +359,7 @@ AC_REPLACE_FUNCS(putenv strdup strerror strsignal mkstemp getpagesize \ lrint trunc strsep strpbrk symlink mkdtemp) AC_CHECK_FUNCS_ONCE(gethostname memcpy memmove sighold uname usleep lstat \ grantpt popen getrusage gettimeofday fork strchr utimes utime readlink \ - sigsetmask alarm select mprotect madvise waitpid accept4 \ + sigsetmask alarm select mprotect madvise waitpid accept4 fdatasync \ setsid spawnl pread pwrite _NSGetExecutablePath _NSGetEnviron \ chown getgrnam getpwnam endgrent endpwent setgroupent setpassent) diff --git a/kernel/File.st b/kernel/File.st index 426a415..fa34763 100644 --- a/kernel/File.st +++ b/kernel/File.st @@ -119,6 +119,20 @@ FilePath subclass: File [ (self path: fileName) touch ] + File class >> link: srcName as: destName [ + "Create a hard link for the srcName file with the given path name" + + <category: 'file operations'> + (self path: srcName) linkAs: destName + ] + + File class >> link: destName from: srcName [ + "Create a hard link named destName file from the given path" + + <category: 'file operations'> + (self path: destName) linkFrom: srcName + ] + File class >> symlink: srcName as: destName [ "Create a symlink for the srcName file with the given path name" @@ -197,6 +211,24 @@ FilePath subclass: File [ ^self path: ImageFileName ] + File class >> primFsync: aFd [ + <category: 'private-C call-outs'> + <cCall: 'fsync' returning: #int args: #(#int)> + ] + + File class >> primFdatasync: aFd [ + <category: 'private-C call-outs'> + "Depending on the version of the libc this might fail with a primitive + error. In that case primFsync should be called." + <cCall: 'fdatasync' returning: #int args: #(#int)> + ] + + File class >> sync [ + <category: 'C call-outs'> + "Blocking call to the kernel to sync all files to storage" + <cCall: 'sync' returning: #int args: #()> + ] + = aFile [ "Answer whether the receiver represents the same file as the receiver." @@ -259,6 +291,11 @@ FilePath subclass: File [ ] + primLink: srcName as: destName [ + <category: 'private-C call-outs'> + <cCall: 'link' returning: #int args: #(#string #string)> + ] + primSymlink: srcName as: destName [ <category: 'private-C call-outs'> <cCall: 'symlink' returning: #int args: #(#string #string)> @@ -526,6 +563,14 @@ FilePath subclass: File [ result < 0 ifTrue: [ File checkError ] ] + linkFrom: srcName [ + "Create the receiver as hard link from path destName" + + <category: 'file operations'> + (self primLink: srcName as: self asString) < 0 + ifTrue: [ File checkError ] + ] + symlinkFrom: srcName [ "Create the receiver as a symlink from path destName" @@ -592,6 +637,13 @@ FilePath subclass: File [ File checkError. ] + linkAs: destName [ + "Create destName as a symbolic link of the receiver." + + <category: 'file operations'> + (self class path: destName) linkFrom: self asString. + ] + symlinkAs: destName [ "Create destName as a symbolic link of the receiver. The appropriate relative path is computed automatically." diff --git a/kernel/FileDescr.st b/kernel/FileDescr.st index 3dc8d01..2896d89 100644 --- a/kernel/FileDescr.st +++ b/kernel/FileDescr.st @@ -1104,5 +1104,16 @@ do arbitrary processing on the files.'> ^true ] + fsync [ + <category: 'primitive'> + (File primFsync: fd) < 0 + ifTrue: [self checkError] + ] + + fdatasync [ + <category: 'primitive'> + (File primFdatasync: fd) < 0 + ifTrue: [self checkError] + ] ] diff --git a/kernel/FilePath.st b/kernel/FilePath.st index 8575c0b..84aae3e 100644 --- a/kernel/FilePath.st +++ b/kernel/FilePath.st @@ -688,6 +688,12 @@ size and timestamps.'> ^self open: FileStream write ] + linkAs: destName [ + "Create destName as a hard link of the receiver." + <category: 'file operations'> + self subclassResponsibility + ] + symlinkAs: destName [ "Create destName as a symbolic link of the receiver. The appropriate relative path is computed automatically." @@ -703,6 +709,13 @@ size and timestamps.'> self subclassResponsibility ] + linkFrom: srcName [ + "Create the receiver as a hard link from srcName." + + <category: 'file operations'> + self subclassResponsibility + ] + symlinkFrom: srcName [ "Create the receiver as a symbolic link from srcName (relative to the path of the receiver)." diff --git a/kernel/FileStream.st b/kernel/FileStream.st index 1aa5635..780feff 100644 --- a/kernel/FileStream.st +++ b/kernel/FileStream.st @@ -659,6 +659,18 @@ file object, such as /dev/rmt0 on UNIX or MTA0: on VMS).'> into: collection startingAt: endPtr + 1) ] + + fsync [ + <category: 'primitive'> + self flush. + ^super fsync + ] + + fdatasync [ + <category: 'primitive'> + self flush. + ^super fdatasync + ] ] diff --git a/libgst/ChangeLog b/libgst/ChangeLog index 0fd6549..3392dd9 100644 --- a/libgst/ChangeLog +++ b/libgst/ChangeLog @@ -1,3 +1,8 @@ +2013-08-09 Holger Hans Peter Freyther <[hidden email]> + + * libgst/cint.c: Bind link, fsync, fdatasync and sync for + additional C level access. + 2013-07-09 Gwenael Casaccio <[hidden email]> * oop.c: Protect oop1 and oop2 in _gst_swap_objects. diff --git a/libgst/cint.c b/libgst/cint.c index 77c8f8c..9dd441e 100644 --- a/libgst/cint.c +++ b/libgst/cint.c @@ -641,6 +641,7 @@ _gst_init_cfuncs (void) _gst_define_cfunc ("rewinddir", rewinddir); _gst_define_cfunc ("extractDirentName", extract_dirent_name); + _gst_define_cfunc ("link", link); _gst_define_cfunc ("symlink", my_symlink); _gst_define_cfunc ("unlink", unlink); _gst_define_cfunc ("rename", rename); @@ -649,6 +650,13 @@ _gst_init_cfuncs (void) _gst_define_cfunc ("mkdir", my_mkdir); _gst_define_cfunc ("mkdtemp", my_mkdtemp); _gst_define_cfunc ("getCurDirName", _gst_get_cur_dir_name); + _gst_define_cfunc ("fsync", fsync); +#ifdef HAVE_FDATASYNC + _gst_define_cfunc ("fdatasync", fdatasync); +#else + _gst_define_cfunc ("fdatasync", fsync); +#endif + _gst_define_cfunc ("sync", sync); _gst_define_cfunc ("fileIsReadable", _gst_file_is_readable); _gst_define_cfunc ("fileIsWriteable", _gst_file_is_writeable); -- 1.8.3.2 _______________________________________________ help-smalltalk mailing list [hidden email] https://lists.gnu.org/mailman/listinfo/help-smalltalk |
Free forum by Nabble | Edit this page |