Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change temporary file creation api #169

Merged
merged 17 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
deleteFile: aPathString

GsFile removeServerFile: aPathString
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files
newTemporaryFile

^ self newTemporaryFileNamed: UUID new greaseString
theseion marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
files
newTemporaryFileNamed: aName

^ (GsFile openWriteOnServer: '/tmp/', aName) pathName
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 @@
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 @@
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,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 @@
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-Pharo70-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo70-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 @@
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-Pharo70-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo70-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,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 @@
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-Pharo90-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReference.st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo90-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 @@
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-Pharo90-Core.package/GRPharoPlatform.class/instance/newTemporaryFileReferenceNamed..st

View check run for this annotation

Codecov / codecov/patch

repository/Grease-Pharo90-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,3 @@
files
deleteFile: aPathString
FileDirectory deleteFilePath: aPathString
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

^ (FileDirectory default / aName) pathName
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
files
deleteFile: aPathString
FileDirectory deleteFilePath: aPathString
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

^ (FileDirectory default / aName) pathName
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
as yet unclassified
theseion marked this conversation as resolved.
Show resolved Hide resolved
writeFileStreamOn: aString do: aBlock binary: aBoolean
| stream |
stream := aBoolean
ifTrue: [ (MultiByteFileStream fileNamed: aString) ascii; wantsLineEndConversion: true; yourself ]
theseion marked this conversation as resolved.
Show resolved Hide resolved
ifFalse: [ (FileStream fileNamed: aString) binary ].
[ aBlock value: stream ]
ensure: [ stream close ]
theseion marked this conversation as resolved.
Show resolved Hide resolved
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)
theseion marked this conversation as resolved.
Show resolved Hide resolved
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)
Loading