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

test[nodeJS] 040 File System (setup)

Initialization code for File System tests

"Platform dependent settings"
| platform |
platform := NodeJS process platform.
platform = #ios ifTrue: [
	self print: 'File System tests skipped on IOS'.
	self rejectPages: '[nodeJS] 04'.
	^self abortPage
].
platform = #android ifTrue: [ 		
   Smalltalk at: #TestPath put: '/sdcard/Download/'	
].
platform = #win32 ifTrue: [
   Smalltalk at: #TestPath put: './'
]! !


"Implement a fileWrite function if not present in this system"
[ #{fileWrite} isNil ] on: Error do: [:ex|
    self print: 'Implementing #outputToFile: support'.
    [:fileName :string :mode|
        mode = #ab ifTrue: [ NodeJS fs appendFileSync: fileName data: string ].
        mode = #wb ifTrue: [ NodeJS fs  writeFileSync: fileName data: string ].
    ] installAs: #fileWrite
]! !


"Creating Samples files"
'Content generated by S8.' outputToFile: TestPath,'Sample.txt'.