@@ -692,19 +692,6 @@ namespace eval turbine {
692692 }
693693 }
694694
695- proc file_lines { result input comment } {
696- set src [ lindex $input 0 ]
697- rule_file_helper " file_lines-$result -$src " [ list ] \
698- [ list $comment ] [ list $src ] \
699- $::turbine::WORK \
700- [ list file_lines_body $result $src ]
701- }
702- proc file_lines_body { result input } {
703- set input_val [ retrieve_decr_file $input ]
704- set comment_val [ retrive_decr $comment ]
705- set lines_val [ file_lines_impl $input_val $comment_val ]
706- array_kv_build $result $lines_val 1 integer string
707- }
708695 # input_file: local file representation
709696 proc file_lines_impl { input_file comment } {
710697 set input_name [ local_file_path $input_file ]
@@ -727,6 +714,40 @@ namespace eval turbine {
727714 return $lines
728715 }
729716
717+ # input_file: local file representation
718+ proc file_chunks_impl { input_file delimiter comment } {
719+ set input_name [ local_file_path $input_file ]
720+ set fp [ ::open $input_name r ]
721+ set chunk_number 0
722+ set chunks [ dict create ]
723+ # Comments are disabled if the comment string is empty
724+ # or just whitespace
725+ set comment [ string trim $comment ]
726+ set comments_enabled [ string length $comment ]
727+ while { ! [ eof $fp ] } {
728+ set chunk " "
729+ while { [ gets $fp line ] >= 0 } {
730+ if $comments_enabled {
731+ regsub "${comment} .*" $line "" line
732+ }
733+
734+ if { $line eq $delimiter } break
735+
736+ if { [ string length $line ] > 0 } {
737+ if { $chunk ne " " } {
738+ append chunk " \n "
739+ }
740+ append chunk $line
741+ }
742+ }
743+ set chunk [ string trim $chunk ]
744+ dict append chunks $chunk_number $chunk
745+ incr chunk_number
746+ }
747+ close $fp
748+ return $chunks
749+ }
750+
730751 proc file_mtime_impl { filename } {
731752 if [ catch { set result [ file mtime $filename ] } e ] {
732753 turbine_error " file_mtime(): $e "
0 commit comments