Skip to content

Commit

Permalink
Deprecate existing newTemporaryFileReference in favour of `newTempo…
Browse files Browse the repository at this point in the history
…raryFile` which returns a pathString consistent with other Grease file-handling methods
  • Loading branch information
jbrichau committed Feb 4, 2024
1 parent 788fa15 commit 4d9ea9f
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
files
newTemporaryFile
"Create a new temporary file in the systems temp directory and answer its pathString.
It is the users responsibility to delete or move the file, it will not be cleaned up automatically
(unless the host system has a policy for it)."
^ self subclassResponsibility
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
files
newTemporaryFileNamed: aName
"Create a new temporary file in the systems temp directory and answer its pathString.
It is the users responsibility to delete or move the file, it will not be cleaned up automatically
(unless the host system has a policy for it)."
self subclassResponsibility

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files
newTemporaryFile

^ self newTemporaryFileNamed: UUID new greaseString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files
newTemporaryFileNamed: aName

^ (FileLocator temp / aName) pathString
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ newTemporaryFileReference
It is the users responsibility to delete or move the file,
it will not be cleaned up automatically (unless the host system
has a policy for it)."
self
greaseDeprecatedApi: 'GRPlatform>>newTemporaryFileReference'
details: 'Use newTemporaryFile'.

Check warning on line 10 in repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st#L8-L10

Added lines #L8 - L10 were not covered by tests
^ self newTemporaryFileReferenceNamed: UUID new asString
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ newTemporaryFileReferenceNamed: aName
It is the users responsibility to delete or move the file,
it will not be cleaned up automatically (unless the host system
has a policy for it)."
self
greaseDeprecatedApi: 'GRPlatform>>newTemporaryFileReferenceNamed:'
details: 'Use newTemporaryFileNamed:'.

Check warning on line 10 in repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st#L8-L10

Added lines #L8 - L10 were not covered by tests
^ FileLocator temp / aName
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests-files
testNewTemporaryFile

| temporaryFile |
[
temporaryFile := GRPlatform current newTemporaryFile.
GRPlatform current
writeFileStreamOn: temporaryFile
do: [ :str | str nextPutAll: 'test temporary' ]
binary: false.
self assert: (GRPlatform current fileExists: temporaryFile)
] ensure: [ GRPlatform current deleteFile: temporaryFile ].
self deny: (GRPlatform current fileExists: temporaryFile)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
tests-files
testNewTemporaryFileNamed

| temporaryFile |
[
temporaryFile := GRPlatform current newTemporaryFileNamed: 'test_temporary'.
GRPlatform current
writeFileStreamOn: temporaryFile
do: [ :str | str nextPutAll: 'test temporary' ]
binary: false.
self assert: (GRPlatform current fileExists: temporaryFile)
] ensure: [ GRPlatform current deleteFile: temporaryFile ].
self deny: (GRPlatform current fileExists: temporaryFile)

0 comments on commit 4d9ea9f

Please sign in to comment.