#REFACTORING
class: Filename
changed: #newTemporaryIn:nameTemplate:
use characters as random component
--- a/Filename.st Mon Mar 14 18:44:38 2016 +0100
+++ b/Filename.st Mon Mar 14 18:47:07 2016 +0100
@@ -629,29 +629,29 @@
|nameString newTempFilename|
self isAbstract ifTrue:[
- ^ ConcreteClass newTemporaryIn:aDirectoryOrNil nameTemplate:template
+ ^ ConcreteClass newTemporaryIn:aDirectoryOrNil nameTemplate:template
].
"although the above allows things to be redefined in concrete classes,
the following should work on all systems ..."
[
- "Use random numbers in order to improve the security
- by making the generated names less predictable"
- nameString := template bindWith:(OperatingSystem getProcessId) with:RandomGenerator new nextInteger.
-
- aDirectoryOrNil isNil ifTrue:[
- newTempFilename := self named:nameString
- ] ifFalse:[
- newTempFilename := aDirectoryOrNil asFilename construct:nameString
- ]
+ "Use random numbers in order to improve the security
+ by making the generated names less predictable"
+ nameString := template bindWith:(OperatingSystem getProcessId) with:(RandomGenerator nextLettersOrDigits:4).
+
+ aDirectoryOrNil isNil ifTrue:[
+ newTempFilename := self named:nameString
+ ] ifFalse:[
+ newTempFilename := aDirectoryOrNil asFilename construct:nameString
+ ]
] doWhile:[
- "care for existing leftOver tempFiles
- from a previous boot of the OS
- i.e. my pid could be the same as when executed
- the last time before system reboot ...)"
-
- newTempFilename exists
+ "care for existing leftOver tempFiles
+ from a previous boot of the OS
+ i.e. my pid could be the same as when executed
+ the last time before system reboot ...)"
+
+ newTempFilename exists
].
^ newTempFilename