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

test[nodeJS] 045 File Stat (sync)

"045-1 Reading device info with #fstatSync:"
| fs stats |
fs := NodeJS fs.
fs open: (TestPath, 'Sample.txt') flags:#r with: [:error :fd| 
   error isNil ifFalse: [ ^self error: '045-1 ' ,error].
   [  stats := fs fstatSync: fd.
      "self print: '045-7 Sample.txt has ', stats size,' bytes'."
      fs closeSync:fd ] on: Error do: [:ex| ^self error: '045-1 ' ,ex]      
].


"045-2 Reading device info with #lstatSync:"
| stats |
[ stats := NodeJS fs lstatSync: (TestPath, 'Sample.txt').
  "self print: '045-2 Sample.txt has ', stats size,' bytes'"]
   on: Error
   do: [:ex| ^self error: '045-2 ' ,ex].


"045-3 Reading device info with #statSync:"
| stats |
[ stats := NodeJS fs statSync: (TestPath, 'Sample.txt').
  "self print: '045-3 Sample.txt has ', stats size,' bytes'"]
   on: Error
   do: [:ex| ^self error: '045-3 ' ,ex].