[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
test[LuaStudio] StringIO
Test to read/write String instances from/to file
e.g. #fileContents and #outputToFile:
! String class methodsFor: #sample !
outputToFileExample
" sample "
| root path |
root := MediaFile applicationStorageDirectory nativePath.
path := root, '/test.txt'.
'testing content' outputToFile: path! !
" Install #read: function in global space "
"
[:path | (FileSystem new exists: path) ifFalse: [ ^nil ].
^IOFile new getContent: path ] installAs: #read:
"!
! String methodsFor: 'platform-io' !
fileContents
" Return the contents of file stored at fileName given by the receiver.
Return nil if the file do not exist.
"
^# #read: self! !
! String class methodsFor: #sample !
fileContentsExample
" sample "
| root path |
root := MediaFile applicationStorageDirectory nativePath.
path := root, '/test.txt'.
# #print: path fileContents! !
! String class methodsFor: #sample !
fileContentsForNoFileExample
" sample "
| root path |
root := MediaFile applicationStorageDirectory nativePath.
path := root, '/noFile.txt'.
# #print: path fileContents! !
! String class methodsFor: #sample !
outputToRelativeFileExample
" sample "
| directory path |
directory := 'assets'.
path := directory, '/sample.txt'.
'test' outputToFile: path! !
! String class methodsFor: #sample !
fileContentsForRelativeFile
" sample "
| directory path |
directory := 'assets'.
path := directory, '/sample.txt'.
# #print: path fileContents! !
String outputToFileExample
String fileContentsForNoFileExample
String fileContentsExample
String outputToRelativeFileExample
String fileContentsForRelativeFile