fill_buffer_with_file   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/contrib/word_count.xtm

Implementation

(bind-func fill_buffer_with_file
  "fill buffer with up to maxlen bytes from filename"
  (lambda (buf filename maxlen)
    (let ((fp (fopen filename "rb")))
      (if (null? fp)
          (begin (println "Error reading file.")
                 -1)
          (let ((filesize (file_size fp))
                (bytes_read (fread buf 1 (if (> filesize maxlen) maxlen filesize) fp)))
            (if (<> bytes_read filesize)
                (println "Warning: filesize is" filesize "but only read" bytes_read "bytes.\nPerhaps you need a bigger buffer?")
                (begin (printf "Read %lld bytes from %s\n" bytes_read filename)
                       void))
            (fclose fp)
            bytes_read)))))


Back to Index

Similar Entries

  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer    xtlang
  • AudioBuffer_concat    xtlang
  • AudioBuffer_cstring    xtlang
  • AudioBuffer_data_b64    xtlang
  • AudioBuffer_data_b64_cstring    xtlang
  • AudioBuffer_from_aiff    xtlang
  • AudioBuffer_from_wave    xtlang
  • AudioBuffer_malloc    xtlang
  • AudioBuffer_read    xtlang
  • AudioBuffer_read    xtlang
  • AudioBuffer_read_interp    xtlang
  • AudioBuffer_read_interp_mix    xtlang
  • AudioBuffer_read_interp_pw    xtlang
  • AudioBuffer_read_looped    xtlang
  • AudioBuffer_read_looped    xtlang
  • AudioBuffer_set_data_b64    xtlang
  • AudioBuffer_shared_data    xtlang
  • Complex_bufferize    xtlang
  • Complex_bufferize    xtlang
  • Complex_bufferize    xtlang
  • Complex_bufferize    xtlang
  • Complex_unbufferize    xtlang
  • Complex_unbufferize    xtlang
  • Complex_unbufferize    xtlang
  • Complex_unbufferize    xtlang
  • FBO_create_with_textures    xtlang
  • Vfill    xtlang
  • Widget_with_cb    xtlang
  • ai_load_ogl_texture_from_buffer    xtlang
  • analogue_remove_file    xtlang
  • audiofile_16bitPCM_to_sample_be    xtlang
  • audiofile_16bitPCM_to_sample_le    xtlang
  • audiofile_24bitPCM_to_sample_be    xtlang
  • audiofile_24bitPCM_to_sample_le    xtlang
  • audiofile_aiff_read_samples    xtlang
  • audiofile_copy_samples    xtlang
  • audiofile_float_to_sample_be    xtlang
  • audiofile_float_to_sample_le    xtlang
  • audiofile_read_samples    xtlang
  • audiofile_wave_read_samples    xtlang
  • bindfunc_with_docstring    xtlang
  • bindfunc_with_zone_size    xtlang
  • bindfunc_with_zone_size_and_docstring    xtlang
  • buffers    xtlang
  • call-with-input-file    scheme
  • call-with-output-file    scheme
  • cerberus_remove_file    xtlang
  • curl_request_with_auth    xtlang
  • curl_request_with_header    xtlang
  • define-with-return    macro
  • draw_color_body_frame_with_hands    xtlang
  • fbo_create_depth_buffer    xtlang
  • fbo_create_depth_buffer_rect    xtlang
  • file->string    scheme
  • file-exists?    scheme
  • file_size    xtlang
  • file_word_count    xtlang
  • filename-from-path    scheme
  • filename-strip-extension    scheme
  • fill_direction_vector    xtlang
  • fill_direction_vector    xtlang
  • fill_identity_matrix    xtlang
  • fill_identity_matrix    xtlang
  • fill_orthographic_matrix    xtlang
  • fill_orthographic_matrix    xtlang
  • fill_pos_scale_matrix    xtlang
  • fill_projection_matrix    xtlang
  • fill_projection_matrix    xtlang
  • fill_projection_matrix    xtlang
  • fill_view_matrix    xtlang
  • fill_view_matrix    xtlang
  • fill_view_matrix_dir    xtlang
  • fill_view_matrix_dir    xtlang
  • fits-file-print    xtlang
  • fits-file-print    xtlang
  • fits-open-file    xtlang
  • fits-open-file    xtlang
  • get_file_name    xtlang
  • ghttp_copy_request_body_into_buffer    xtlang
  • ghttp_perform_request_with_setup_fn    xtlang
  • gl_print_error_with_msg    xtlang
  • glfw_get_framebuffer_height    xtlang
  • glfw_get_framebuffer_width    xtlang
  • glfw_set_compatibility_profile    xtlang
  • glfw_set_core_profile    xtlang
  • glfw_swap_buffers    xtlang
  • gui_find_widget_with_id    xtlang
  • impc:aot:compile-xtm-file    scheme
  • impc:compiler:print-bad-type-error-with-ast    scheme
  • impc:ir:compiler:heap-alloc-with-size    scheme
  • impc:ir:compiler:heap-alloc-without-size    scheme
  • impc:ir:compiler:stack-alloc-with-size    scheme
  • impc:ir:compiler:stack-alloc-without-size    scheme
  • impc:ir:compiler:zone-alloc-with-size    scheme
  • impc:ir:compiler:zone-alloc-without-size    scheme
  • impc:ti:afill!    scheme
  • impc:ti:initialize-closure-with-new-zone    scheme
  • impc:ti:pfill!    scheme
  • impc:ti:tfill!    scheme
  • impc:ti:vfill!    scheme
  • ipc:proc-name-with-mapping    scheme
  • make-list-with-proc    scheme
  • make-vector-with-proc    scheme
  • pm_device_with_id    xtlang
  • pm_input_device_with_name    xtlang
  • pm_output_device_with_name    xtlang
  • print-with-colors    macro
  • qr_create_with_level    xtlang
  • return_ptr_gv_first_with_docstring    xtlang
  • return_ptr_gv_second_with_docstring    xtlang
  • sampler-parse-filename    scheme
  • sampler-parse-midinote-filename    scheme
  • sampler-parse-spn-filename    scheme
  • set_cairo_source_with_colour    xtlang
  • set_sampler_audiobuffer    xtlang
  • sf_channels_from_file    xtlang
  • sf_frames_from_file    xtlang
  • sf_print_audio_file_info    xtlang
  • sf_read_file_into_buffer    xtlang
  • sf_samples_from_file    xtlang
  • string-fill!    scheme
  • string_list_from_file    xtlang
  • sys:file-path-components    scheme
  • sys:with-noisy-compiler    macro
  • sys:with-quiet-compiler    macro
  • sys_file_append    xtlang
  • sys_file_close    xtlang
  • sys_file_copy    xtlang
  • sys_file_datasync    xtlang
  • sys_file_datasync    xtlang
  • sys_file_eof    xtlang
  • sys_file_flush    xtlang
  • sys_file_getc    xtlang
  • sys_file_gets    xtlang
  • sys_file_link    xtlang
  • sys_file_mktemp    xtlang
  • sys_file_open    xtlang
  • sys_file_open_stderr    xtlang
  • sys_file_open_stdin    xtlang
  • sys_file_open_stdout    xtlang
  • sys_file_putc    xtlang
  • sys_file_puts    xtlang
  • sys_file_read    xtlang
  • sys_file_remove    xtlang
  • sys_file_rename    xtlang
  • sys_file_seek    xtlang
  • sys_file_sync    xtlang
  • sys_file_ungetc    xtlang
  • sys_file_write    xtlang
  • sys_filepath_root    xtlang
  • sys_g_file_test    xtlang
  • thread_native_call_with_zone    xtlang
  • unzip1-with-cdr    scheme
  • unzip1-with-cdr-iterative    scheme
  • vector-fill!    scheme
  • with-input-from-file    scheme
  • with-input-output-from-to-files    scheme
  • with-output-to-file    scheme
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_arc_fill    xtlang
  • xtm_draw_bezier_fill    xtlang
  • xtm_draw_bezier_fill    xtlang
  • xtm_draw_bezier_fill    xtlang
  • xtm_draw_bezier_fill    xtlang
  • xtm_draw_circle_fill    xtlang
  • xtm_draw_circle_fill    xtlang
  • xtm_draw_circle_fill    xtlang
  • xtm_draw_circle_fill    xtlang
  • xtm_draw_ellipse_fill    xtlang
  • xtm_draw_ellipse_fill    xtlang
  • xtm_draw_ellipse_fill    xtlang
  • xtm_draw_ellipse_fill    xtlang
  • xtm_draw_quad_fill    xtlang
  • xtm_draw_quad_fill    xtlang
  • xtm_draw_quad_fill    xtlang
  • xtm_draw_quad_fill    xtlang
  • xtm_draw_rect_fill    xtlang
  • xtm_draw_rect_fill    xtlang
  • xtm_draw_rect_fill    xtlang
  • xtm_draw_rect_fill    xtlang
  • xtm_draw_rounded_rect_fill    xtlang
  • xtm_draw_rounded_rect_fill    xtlang
  • xtm_draw_rounded_rect_fill    xtlang
  • xtm_draw_rounded_rect_fill    xtlang
  • xtm_draw_rounded_rect_varying_fill    xtlang
  • xtm_draw_rounded_rect_varying_fill    xtlang
  • xtm_draw_rounded_rect_varying_fill    xtlang
  • xtm_draw_rounded_rect_varying_fill    xtlang
  • xtm_draw_tri_fill    xtlang
  • xtm_draw_tri_fill    xtlang
  • xtm_draw_tri_fill    xtlang
  • xtm_draw_tri_fill    xtlang
  • xtm_fill    xtlang
  • xtm_fill    xtlang
  • xtm_fill_path    xtlang
  • xtm_fill_path_keep    xtlang
  • xtm_paint_set_fill    xtlang
  • xtmtest-with-fixture    macro
  • xtmtest-with-fixture-body    scheme
  • xtmtest-with-fixture-body    scheme