-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of readFileStream and writeFileStream on GRPlatform fo…
…r Pharo9
- Loading branch information
Johan Brichau
committed
May 21, 2020
1 parent
cafef9b
commit 2908a8f
Showing
8 changed files
with
30 additions
and
26 deletions.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
repository/Grease-Core.package/GRPlatform.class/instance/fileStreamOn.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,3 +1,6 @@ | ||
file library | ||
fileStreamOn: aString do: aBlock binary: aBoolean | ||
self subclassResponsibility | ||
self | ||
greaseDeprecatedApi: 'GRPlatform>>#fileStreamOn:do:binary:' | ||
details: 'Use readFileStreamOn:do:binary:'. | ||
^ self readFileStreamOn: aString do: aBlock binary: aBoolean |
3 changes: 3 additions & 0 deletions
3
repository/Grease-Core.package/GRPlatform.class/instance/readFileStreamOn.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,3 @@ | ||
file library | ||
readFileStreamOn: aString do: aBlock binary: aBoolean | ||
self subclassResponsibility |
3 changes: 3 additions & 0 deletions
3
repository/Grease-Core.package/GRPlatform.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,3 @@ | ||
file library | ||
writeFileStreamOn: aString do: aBlock binary: aBoolean | ||
self subclassResponsibility |
2 changes: 1 addition & 1 deletion
2
...tory/Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/contentsOfFile.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,3 +1,3 @@ | ||
file library | ||
contentsOfFile: aString binary: aBoolean | ||
^ self fileStreamOn: aString do: [ :stream | stream contents ] binary: aBoolean | ||
^ self readFileStreamOn: aString do: [ :stream | stream contents ] binary: aBoolean |
13 changes: 0 additions & 13 deletions
13
...ory/Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/fileStreamOn.do.binary..st
This file was deleted.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/readFileStreamOn.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,7 @@ | ||
file library | ||
readFileStreamOn: aString do: aBlock binary: aBoolean | ||
"Line end conversion is no longer done for ascii... TBD!" | ||
|
||
^ aBoolean | ||
ifTrue: [ aString asFileReference binaryReadStreamDo: aBlock ] | ||
ifFalse: [ aString asFileReference readStreamEncoded: 'ascii' do: aBlock ] |
18 changes: 7 additions & 11 deletions
18
...tory/Grease-Pharo90-Core.package/GRPharoPlatform.class/instance/write.toFile.inFolder..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,15 +1,11 @@ | ||
file library | ||
write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString | ||
"writes aStringOrByteArray to a file named aFilenameString in the folder aFolderString" | ||
| folder stream fullFilePath | | ||
|
||
| folder | | ||
folder := FileSystem disk resolveString: aFolderString. | ||
fullFilePath := (folder / aFileNameString) asFileReference. | ||
stream := aStringOrByteArray isString | ||
ifTrue: [ | ||
(MultiByteFileStream forceNewFileNamed: fullFilePath fullName) | ||
ascii; | ||
wantsLineEndConversion: true; | ||
yourself ] | ||
ifFalse: [ (FileStream forceNewFileNamed: fullFilePath fullName) binary ]. | ||
[ stream nextPutAll: aStringOrByteArray ] | ||
ensure: [ stream close ] | ||
"TODO: wantsLineEndConversion: true; ??" | ||
^ self | ||
writeFileStreamOn: (folder / aFileNameString) asFileReference ensureDelete fullName | ||
do: [ :stream | stream nextPutAll: aStringOrByteArray ] | ||
binary: aStringOrByteArray isString not | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
5 changes: 5 additions & 0 deletions
5
...rease-Pharo90-Core.package/GRPharoPlatform.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,5 @@ | ||
file library | ||
writeFileStreamOn: aString do: aBlock binary: aBoolean | ||
^ aBoolean | ||
ifTrue: [ aString asFileReference binaryWriteStreamDo: aBlock ] | ||
ifFalse: [ aString asFileReference writeStreamEncoded: 'ascii' do: aBlock ] |
I would write this a bit more concise: