JanetDocsPlaygroundI'm feeling luckyGitHub sign in

file/flush



    cfunction
    src/core/io.c on line 250, column 1

    (file/flush f)

    Flush any buffered bytes to the file system. In most files, writes 
    are buffered for efficiency reasons. Returns the file handle.


1 exampleSign in to add an example
Loading...
# Demonstrate file/flush -- tail %flushtest.csv to see new
# entries appended as the program runs. Otherwise, entries
# wouldn't be visible until file was closed. @oofoe

(def fp (file/open "flushtest.csv" :wb))

(file/write fp "Timestamp,Fiducial\n")
(for i 0 5
  (print "-- Writing " i)
  (file/flush (file/write fp (string (os/time) "," i "\n")))
  (os/sleep (* 5 (math/random))))

(file/close fp)
oofoePlayground