X Tutup
Skip to content

Commit 2816e8e

Browse files
author
Johan Brichau
committed
throw error when creating a duplicate temporary file
1 parent 22b0950 commit 2816e8e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
files
22
newTemporaryFileNamed: aName
33

4-
^ (FileLocator temp / aName) pathString
4+
| newFile |
5+
newFile := FileLocator temp / aName.
6+
newFile exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ].
7+
^ newFile pathString
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SystemOrganization addCategory: #'Grease-Pharo100-Core'!
1+
self packageOrganizer ensurePackage: #'Grease-Pharo100-Core' withTags: #()!
Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
tests-files
22
testNewTemporaryFileNamed
33

4-
| temporaryFile |
4+
| temporaryFile fileName |
5+
fileName := 'GRPlatformTestTemporaryFile'.
56
[
6-
temporaryFile := GRPlatform current newTemporaryFileNamed: 'test_temporary'.
7+
temporaryFile := GRPlatform current newTemporaryFileNamed: fileName.
78
GRPlatform current
89
writeFileStreamOn: temporaryFile
910
do: [ :str | str nextPutAll: 'test temporary' ]
1011
binary: false.
11-
self assert: (GRPlatform current fileExists: temporaryFile)
12+
self assert: (GRPlatform current fileExists: temporaryFile).
13+
self should: [ GRPlatform current newTemporaryFileNamed: fileName ] raise: GRError.
1214
] ensure: [ GRPlatform current deleteFile: temporaryFile ].
13-
self deny: (GRPlatform current fileExists: temporaryFile)
15+
self deny: (GRPlatform current fileExists: temporaryFile).
16+

0 commit comments

Comments
 (0)
X Tutup