[View]  [Edit]  [Lock]  [References]  [Attachments]  [History]  [Home]  [Changes]  [Search]  [Help] 

test[jx8-android] 082 - readfile tests



"Accessing (xml) file contents through NodeJS API"
| folder fileNames fName contents |
folder := '/vendor/etc/'.
fileNames := (NodeJS fs readdirSync: folder)
	select: [:each| each includes: '.xml' ].
fileNames isEmpty ifTrue: [ self error: 'Directory is missing, or without xml files' ].
fName := fileNames
	detect: [:one| one = 'fonts.xml' ]
	ifNone: [ fileNames sorted first ].
contents := (NodeJS fs
	readFileSync: folder ,fName)
	toString: #utf8.
contents size = 0 ifTrue: [ ^self error: 'Empty contents' ].
self print: 'Ok - File ',fName,' contents size=',contents size