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

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

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


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


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