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

test[nodeJS] 049 file mode bits change (async)

"049-7 Changing file mode bits with #chmod:mode:with:"
| options |
options := ((#encoding -> #utf8),(#mode -> 0777),(#flag -> #a)).
[NodeJS fs appendFileSync: (TestPath, 'Sample49-7.txt') 
           data:'More S8 data.' 
           options: options ]
   on: Error
   do: [:ex| ^self error: '049-7 ' ,ex].
NodeJS fs chmod:(TestPath,'Sample49-7.txt') mode:0666 with:[:error| 
   error isNil ifFalse:[^self error: '049-7 ', error]
].


"049-8 Changing file mode bits with #fchmod:mode:with:"
| fs data text|
fs := NodeJS fs.
text := 'S8 data'.	
fs open: (TestPath, 'Sample49-8.txt') flags: #w with: [:error :fd| | jsObject |
   error isNil ifFalse: [^self error: '049-8 ' ,error].
   jsObject := {'new Buffer(7);'}.
   data := (NodeBuffer @ jsObject).   
   data write: text.   	   
   fs writeSync: fd buffer: data offset: 0 length: (data length) position:0.
   fs fchmod: fd mode: 0666 with:[:err|
      err isNil ifFalse:[^self error:'049-8 ',err].
      fs closeSync:fd.
   ].  
].


"049-9 Changing file mode bits with #lchmod:mode:with:"
"| options |
options := ((#encoding -> #utf8),(#mode -> 0777),(#flag -> #a)).
[NodeJS fs appendFileSync: (TestPath, 'Sample49-9.txt') 
           data:'More S8 data.' 
           options: options ]
   on: Error
   do: [:ex| ^self error: '049-9 ' ,ex].
NodeJS fs lchmod: (TestPath, 'Sample49-9.txt') mode: 0666 with:[:err|
      err isNil ifFalse:[^self error:'049-9 ',err]     
]."
self print: '049-9 Not working on win32 or android, only available on mac OSX. TO FIX'.