diff --git a/kernel/File.st b/kernel/File.st index 3cc77eb..a6e9dc9 100644 --- a/kernel/File.st +++ b/kernel/File.st @@ -52,6 +52,12 @@ FilePath subclass: File [ second: 0 ] + File class >> tempName: aDirString prefix: aPrefixString [ + + + + ] + File class >> stringError: errno [ "Answer C strerror's result for errno." @@ -490,7 +496,7 @@ FilePath subclass: File [ setOwnerFor: self asString owner: ownerString group: groupString) < 0 - ifTrue: [ File checkError ] + ifTrue: [ File checkError ] ] lastAccessTime: accessDateTime lastModifyTime: modifyDateTime [ @@ -501,7 +507,7 @@ FilePath subclass: File [ setTimeFor: self asString atime: (self secondsFromDateTime: accessDateTime) mtime: (self secondsFromDateTime: modifyDateTime)) < 0 - ifTrue: [ File checkError ] + ifTrue: [ File checkError ] ] open: class mode: mode ifFail: aBlock [ diff --git a/kernel/PkgLoader.st b/kernel/PkgLoader.st index c3aac39..55d0c95 100644 --- a/kernel/PkgLoader.st +++ b/kernel/PkgLoader.st @@ -1188,7 +1188,7 @@ Kernel.PackageInfo subclass: Package [ information on a Smalltalk package, and can output my description in XML.'> - Package class [ | Tags | ] + Package class [ | Tags SessionFile | ] Package class >> tags [ @@ -1212,6 +1212,35 @@ XML.'> 'callout' -> #addCallout: } ] ] + Package class >> sessionFile [ + + + ^ SessionFile ifNil: [ SessionFile := Set new ] + ] + + Package class >> initialize [ + + + ObjectMemory addDependent: self + ] + + Package class >> sessionInitialize [ + + + SessionDirectory := (File tempName: '/home/gwenael/.st/' prefix: 'session') asFile. + SessionDirectory createDirectory. + ] + + Package class >> update: aSymbol [ + + + aSymbol == #returnFromSnapshot ifTrue: [ + self sessionInitialize ]. + aSymbol == #aboutToQuit ifTrue: [ + self sessionFile do: [ :each | each remove ]. + SessionDirectory isNil ifFalse: [ SessionDirectory remove ] ] + ] + Package class >> parse: file [ "Answer a package from the XML description in file." @@ -1561,7 +1590,7 @@ XML.'> (CFunctionDescriptor isFunction: func) ifFalse: [^self error: 'C callout not available: ' , func]]]. loadedFiles := self fullPathsOf: self fileIns. - loadedFiles do: [:each | each fileIn]. + loadedFiles do: [:each | (self class sessionFile add: each sessionFile) fileIn ]. self name isNil ifFalse: [Smalltalk addFeature: self name]. self features do: [:each | Smalltalk addFeature: each]] ensure: @@ -1931,3 +1960,9 @@ into a Smalltalk image, correctly handling dependencies.'> ] ] +Eval [ + + Package initialize + +] + diff --git a/kernel/VFS.st b/kernel/VFS.st index a4d0d72..aae45b1 100644 --- a/kernel/VFS.st +++ b/kernel/VFS.st @@ -652,6 +652,20 @@ on them, to extract them to a real file, and so on.'> self subclassResponsibility ] + extractMemberForSession: anArchiveMember [ + "Extract the contents of anArchiveMember into a file + that resides on disk, and answer the name of the file." + + + + extractedFiles isNil ifTrue: [ extractedFiles := IdentityDictionary new ]. + ^ extractedFiles at: anArchiveMember + ifAbsentPut: [ | temp path | + temp := FileStream openTemporaryFile: (SessionDirectory / 'vfs'). + self extractMember: anArchiveMember into: temp. + File name: temp name] + ] + extractMember: anArchiveMember [ "Extract the contents of anArchiveMember into a file that resides on disk, and answer the name of the file." @@ -1097,6 +1111,17 @@ ArchiveMember subclass: TmpFileArchiveMember [ file := self archive extractMember: self. ^file ] + + sessionFile [ + "Answer the real file name which holds the file contents, + or nil if it does not apply." + + + file ifNotNil: [ ^ file ]. + self exists ifFalse: [ ^ nil ]. + file := self archive extractMemberForSession: self. + ^ file + ] ] ] diff --git a/libgst/cint.c b/libgst/cint.c index ec6bc18..e1405d0 100644 --- a/libgst/cint.c +++ b/libgst/cint.c @@ -198,6 +198,7 @@ static int my_chdir (const char *str); static int my_chown (const char *file, const char *owner, const char *group); static int my_symlink (const char* oldpath, const char* newpath); static char *my_mkdtemp (char* template); +static char*my_tempnam(const char *dir, const char *pfx); static int my_mkdir (const char* name, int mode); static DIR *my_opendir (const char *str); static char *extract_dirent_name (struct dirent *dir); @@ -617,6 +618,7 @@ _gst_init_cfuncs (void) _gst_define_cfunc ("chdir", my_chdir); _gst_define_cfunc ("mkdir", my_mkdir); _gst_define_cfunc ("mkdtemp", my_mkdtemp); + _gst_define_cfunc ("tempnam", my_tempnam); _gst_define_cfunc ("getCurDirName", _gst_get_cur_dir_name); _gst_define_cfunc ("fileIsReadable", _gst_file_is_readable); @@ -1557,3 +1559,10 @@ my_mkdtemp(char* template) { return mkdtemp(template); } + +char* +my_tempnam(const char *dir, const char *pfx) +{ + return tempnam(dir, pfx); +} + diff --git a/snprintfv/snprintfv/filament.h b/snprintfv/snprintfv/filament.h index 4a91eb6..8a7ce6c 100644 --- a/snprintfv/snprintfv/filament.h +++ b/snprintfv/snprintfv/filament.h @@ -1,4 +1,4 @@ -#line 1 "../../../snprintfv/snprintfv/filament.in" +#line 1 "./filament.in" /* -*- Mode: C -*- */ /* filament.h --- a bit like a string but different =)O| @@ -118,7 +118,7 @@ extern char * fildelete (Filament *fil); extern void _fil_extend (Filament *fil, size_t len, boolean copy); -#line 61 "../../../snprintfv/snprintfv/filament.in" +#line 61 "./filament.in" /* Save the overhead of a function call in the great majority of cases. */ #define fil_maybe_extend(fil, len, copy) \ diff --git a/snprintfv/snprintfv/printf.h b/snprintfv/snprintfv/printf.h index 49a2e9f..1437dd5 100644 --- a/snprintfv/snprintfv/printf.h +++ b/snprintfv/snprintfv/printf.h @@ -1,4 +1,4 @@ -#line 1 "../../../snprintfv/snprintfv/printf.in" +#line 1 "./printf.in" /* -*- Mode: C -*- */ /* printf.in --- printf clone for argv arrays @@ -266,7 +266,7 @@ enum } \ } SNV_STMT_END -#line 269 "../../../snprintfv/snprintfv/printf.in" +#line 269 "./printf.in" /** * printf_generic_info: * @pinfo: the current state information for the format @@ -302,7 +302,7 @@ extern int printf_generic_info (struct printf_info *const pinfo, size_t n, int * extern int printf_generic (STREAM *stream, struct printf_info *const pinfo, union printf_arg const *args); -#line 270 "../../../snprintfv/snprintfv/printf.in" +#line 270 "./printf.in" /** * register_printf_function: * @spec: the character which will trigger @func, cast to an unsigned int. @@ -789,7 +789,7 @@ extern int snv_vasprintf (char **result, const char *format, va_list ap); extern int snv_asprintfv (char **result, const char *format, snv_constpointer const args[]); -#line 271 "../../../snprintfv/snprintfv/printf.in" +#line 271 "./printf.in" /* If you don't want to use snprintfv functions for *all* of your string formatting API, then define COMPILING_SNPRINTFV_C and use the snv_ diff --git a/snprintfv/snprintfv/stream.h b/snprintfv/snprintfv/stream.h index 496bd33..0bebce1 100644 --- a/snprintfv/snprintfv/stream.h +++ b/snprintfv/snprintfv/stream.h @@ -1,4 +1,4 @@ -#line 1 "../../../snprintfv/snprintfv/stream.in" +#line 1 "./stream.in" /* -*- Mode: C -*- */ /* stream.h --- customizable stream routines @@ -180,7 +180,7 @@ extern int stream_puts (char *s, STREAM *stream); extern int stream_get (STREAM *stream); -#line 88 "../../../snprintfv/snprintfv/stream.in" +#line 88 "./stream.in" #ifdef __cplusplus #if 0 /* This brace is so that emacs can still indent properly: */