-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from SeasideSt/temporaryfiles-gemstone
Change temporary file creation api
- Loading branch information
Showing
36 changed files
with
182 additions
and
48 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
6 changes: 6 additions & 0 deletions
6
repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
8 changes: 0 additions & 8 deletions
8
repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReference.st
This file was deleted.
Oops, something went wrong.
3 changes: 0 additions & 3 deletions
3
repository/Grease-Core.package/GRPlatform.class/instance/newTemporaryFileReferenceNamed..st
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
repository/Grease-GemStone-Core.package/GRGemStonePlatform.class/instance/deleteFile..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
deleteFile: aPathString | ||
|
||
GsFile removeServerFile: aPathString |
4 changes: 4 additions & 0 deletions
4
...sitory/Grease-GemStone-Core.package/GRGemStonePlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
.../Grease-GemStone-Core.package/GRGemStonePlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| fileName | | ||
fileName := GRPlatform current pathSeparator,'tmp', GRPlatform current pathSeparator, aName. | ||
(self fileExists: fileName) ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ (GsFile openWriteOnServer: fileName) pathName |
4 changes: 4 additions & 0 deletions
4
repository/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
...ory/Grease-Pharo100-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| newFile | | ||
newFile := FileLocator temp / aName. | ||
newFile exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ newFile pathString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
repository/Grease-Pharo100-Core.package/monticello.meta/categories.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SystemOrganization addCategory: #'Grease-Pharo100-Core'! | ||
self packageOrganizer ensurePackage: #'Grease-Pharo100-Core' withTags: #()! |
4 changes: 4 additions & 0 deletions
4
repository/Grease-Pharo70-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
...tory/Grease-Pharo70-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| newFile | | ||
newFile := FileLocator temp / aName. | ||
newFile exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ newFile pathString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
repository/Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
...tory/Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| newFile | | ||
newFile := FileLocator temp / aName. | ||
newFile exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ newFile pathString |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
repository/Grease-Squeak5-Core.package/GRSqueakPlatform.class/instance/deleteFile..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
files | ||
deleteFile: aPathString | ||
FileDirectory deleteFilePath: aPathString |
4 changes: 4 additions & 0 deletions
4
repository/Grease-Squeak5-Core.package/GRSqueakPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
...ory/Grease-Squeak5-Core.package/GRSqueakPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| file | | ||
file := FileDirectory default / aName. | ||
file exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ file pathName |
6 changes: 3 additions & 3 deletions
6
...ease-Squeak5-Core.package/GRSqueakPlatform.class/instance/writeFileStreamOn.do.binary..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
as yet unclassified | ||
files | ||
writeFileStreamOn: aString do: aBlock binary: aBoolean | ||
| stream | | ||
stream := aBoolean | ||
ifTrue: [ (MultiByteFileStream fileNamed: aString) ascii; wantsLineEndConversion: true; yourself ] | ||
ifFalse: [ (FileStream fileNamed: aString) binary ]. | ||
ifTrue: [ (FileStream fileNamed: aString) binary ] | ||
ifFalse: [ (MultiByteFileStream fileNamed: aString) ascii; wantsLineEndConversion: true; yourself ]. | ||
[ aBlock value: stream ] | ||
ensure: [ stream close ] |
3 changes: 3 additions & 0 deletions
3
repository/Grease-Squeak6-Core.package/GRSqueakPlatform.class/instance/deleteFile..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
files | ||
deleteFile: aPathString | ||
FileDirectory deleteFilePath: aPathString |
4 changes: 4 additions & 0 deletions
4
repository/Grease-Squeak6-Core.package/GRSqueakPlatform.class/instance/newTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
files | ||
newTemporaryFile | ||
|
||
^ self newTemporaryFileNamed: UUID new greaseString |
7 changes: 7 additions & 0 deletions
7
...ory/Grease-Squeak6-Core.package/GRSqueakPlatform.class/instance/newTemporaryFileNamed..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
files | ||
newTemporaryFileNamed: aName | ||
|
||
| file | | ||
file := FileDirectory default / aName. | ||
file exists ifTrue: [ GRError new signal: 'A (temporary) file with name ', aName, ' already exists.' ]. | ||
^ file pathName |
8 changes: 8 additions & 0 deletions
8
...ease-Squeak6-Core.package/GRSqueakPlatform.class/instance/writeFileStreamOn.do.binary..st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
files | ||
writeFileStreamOn: aString do: aBlock binary: aBoolean | ||
| stream | | ||
stream := aBoolean | ||
ifTrue: [ (FileStream fileNamed: aString) binary ] | ||
ifFalse: [ (MultiByteFileStream fileNamed: aString) ascii; wantsLineEndConversion: true; yourself ]. | ||
[ aBlock value: stream ] | ||
ensure: [ stream close ] |
20 changes: 20 additions & 0 deletions
20
repository/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFile.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
tests-files | ||
testNewTemporaryFile | ||
|
||
| temporaryFile1 temporaryFile2 | | ||
[ | ||
temporaryFile1 := GRPlatform current newTemporaryFile. | ||
temporaryFile2 := GRPlatform current newTemporaryFile. | ||
GRPlatform current | ||
writeFileStreamOn: temporaryFile1 | ||
do: [ :str | str nextPutAll: 'test temporary' ] | ||
binary: false. | ||
GRPlatform current | ||
writeFileStreamOn: temporaryFile2 | ||
do: [ :str | str nextPutAll: #[116 101 115 116 32 116 101 109 112 111 114 97 114 121] ] | ||
binary: true. | ||
self assert: (GRPlatform current fileExists: temporaryFile1). | ||
self deny: (GRPlatform current localNameOf: temporaryFile1) equals: (GRPlatform current localNameOf: temporaryFile2) | ||
] ensure: [ GRPlatform current deleteFile: temporaryFile1. GRPlatform current deleteFile: temporaryFile2 ]. | ||
self deny: (GRPlatform current fileExists: temporaryFile1). | ||
self deny: (GRPlatform current fileExists: temporaryFile2) |
16 changes: 16 additions & 0 deletions
16
...tory/Grease-Tests-Core.package/GRPlatformTest.class/instance/testNewTemporaryFileNamed.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
tests-files | ||
testNewTemporaryFileNamed | ||
|
||
| temporaryFile fileName | | ||
fileName := 'GRPlatformTestTemporaryFile'. | ||
[ | ||
temporaryFile := GRPlatform current newTemporaryFileNamed: fileName. | ||
GRPlatform current | ||
writeFileStreamOn: temporaryFile | ||
do: [ :str | str nextPutAll: 'test temporary' ] | ||
binary: false. | ||
self assert: (GRPlatform current fileExists: temporaryFile). | ||
self should: [ GRPlatform current newTemporaryFileNamed: fileName ] raise: GRError. | ||
] ensure: [ GRPlatform current deleteFile: temporaryFile ]. | ||
self deny: (GRPlatform current fileExists: temporaryFile). | ||
|
8 changes: 0 additions & 8 deletions
8
...-Tests-Core.package/GRPlatformTest.class/instance/testReadWriteEmptyFileInFolderBinary.st
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...se-Tests-Core.package/GRPlatformTest.class/instance/testReadWriteEmptyFileInFolderText.st
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...ase-Tests-Core.package/GRPlatformTest.class/instance/testReadWriteToFileInFolderBinary.st
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...rease-Tests-Core.package/GRPlatformTest.class/instance/testReadWriteToFileInFolderText.st
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...sitory/Grease-Tests-Core.package/GRPlatformTest.class/instance/testWriteToFileInFolder.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
tests-files | ||
testWriteToFileInFolder | ||
|
||
| bytes text | | ||
bytes := ByteArray new. | ||
self | ||
writeToFile: bytes | ||
withFileNameDo:[ :fileName | | ||
self assert: (GRPlatform current contentsOfFile: fileName binary: true) equals: bytes ]. | ||
|
||
bytes := #[80 104 39 110 103 108 117 105 32 109 103 108 119 39 110 97 102 104 32 67 116 104 117 108 104 117 32 82 39 108 121 101 104 32 119 103 97 104 39 110 97 103 108 32 102 104 116 97 103 110]. | ||
self | ||
writeToFile: bytes | ||
withFileNameDo:[ :fileName | | ||
self assert:(GRPlatform current contentsOfFile: fileName binary: true) equals: bytes ]. | ||
|
||
text := String new. | ||
self | ||
writeToFile: text | ||
withFileNameDo:[ :fileName | | ||
self assert: (GRPlatform current contentsOfFile: fileName binary: false) equals: text ]. | ||
|
||
text := 'Ph''nglui mglw''nafh Cthulhu R''lyeh wgah''nagl fhtagn'. | ||
self | ||
writeToFile: text | ||
withFileNameDo:[ :fileName | | ||
self assert: (GRPlatform current contentsOfFile: fileName binary: false) equals: text ] |
2 changes: 1 addition & 1 deletion
2
repository/Grease-Tests-Core.package/monticello.meta/categories.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
SystemOrganization addCategory: #'Grease-Tests-Core'! | ||
self packageOrganizer ensurePackage: #'Grease-Tests-Core' withTags: #()! |