From 4d9ea9f26ec9f130c1b09fed367d75c41c70c4aa Mon Sep 17 00:00:00 2001 From: Johan Brichau Date: Sun, 4 Feb 2024 09:25:16 +0100 Subject: [PATCH] Deprecate existing `newTemporaryFileReference` in favour of `newTemporaryFile` which returns a pathString consistent with other Grease file-handling methods --- .../GRPlatform.class/instance/newTemporaryFile.st | 6 ++++++ .../instance/newTemporaryFileNamed..st | 6 ++++++ .../instance/newTemporaryFileReference.st | 8 -------- .../instance/newTemporaryFileReferenceNamed..st | 3 --- .../instance/newTemporaryFile.st | 4 ++++ .../instance/newTemporaryFileNamed..st | 4 ++++ .../instance/newTemporaryFileReference.st | 3 +++ .../instance/newTemporaryFileReferenceNamed..st | 3 +++ .../instance/testNewTemporaryFile.st | 13 +++++++++++++ .../instance/testNewTemporaryFileNamed.st | 13 +++++++++++++ 10 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFile.st create mode 100644 repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileNamed..st delete mode 100644 repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReference.st delete mode 100644 repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReferenceNamed..st create mode 100644 repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st create mode 100644 repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st create mode 100644 repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFile.st create mode 100644 repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFileNamed.st diff --git a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFile.st b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFile.st new file mode 100644 index 00000000..e92ccc4c --- /dev/null +++ b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFile.st @@ -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 \ No newline at end of file diff --git a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileNamed..st b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileNamed..st new file mode 100644 index 00000000..c03ea7f2 --- /dev/null +++ b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileNamed..st @@ -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 \ No newline at end of file diff --git a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReference.st b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReference.st deleted file mode 100644 index 91961b92..00000000 --- a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReference.st +++ /dev/null @@ -1,8 +0,0 @@ -files -newTemporaryFileReference - "Create a new temporary file in the systems temp directory - and answer a reference to it. - 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 \ No newline at end of file diff --git a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReferenceNamed..st b/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReferenceNamed..st deleted file mode 100644 index 93059d5f..00000000 --- a/repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReferenceNamed..st +++ /dev/null @@ -1,3 +0,0 @@ -files -newTemporaryFileReferenceNamed: aName - self subclassResponsibility \ No newline at end of file diff --git a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st new file mode 100644 index 00000000..01578607 --- /dev/null +++ b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st @@ -0,0 +1,4 @@ +files +newTemporaryFile + + ^ self newTemporaryFileNamed: UUID new greaseString \ No newline at end of file diff --git a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st new file mode 100644 index 00000000..5e778cdd --- /dev/null +++ b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st @@ -0,0 +1,4 @@ +files +newTemporaryFileNamed: aName + + ^ (FileLocator temp / aName) pathString \ No newline at end of file diff --git a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st index cd503715..7992374f 100644 --- a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st +++ b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st @@ -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'. ^ self newTemporaryFileReferenceNamed: UUID new asString \ No newline at end of file diff --git a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st index 5f4d0602..81baa7c1 100644 --- a/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st +++ b/repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st @@ -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:'. ^ FileLocator temp / aName \ No newline at end of file diff --git a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFile.st b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFile.st new file mode 100644 index 00000000..f02a8289 --- /dev/null +++ b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFile.st @@ -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) \ No newline at end of file diff --git a/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFileNamed.st b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFileNamed.st new file mode 100644 index 00000000..68d6ff3c --- /dev/null +++ b/repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFileNamed.st @@ -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) \ No newline at end of file