# ------------------------------------------------------------ # Copyright (c) 2019-2020 # Q.W.Page Associates Inc. # www.qwpage.com # All rights reserved. # ------------------------------------------------------------ ::namespace eval ::qw::ifsutil {}; ::proc ::qw::ifsutil::dump_ifs_file {sargs} { /* { Usage: qw::ifs2util::dump_ifs_file .path $PathToIfsFile ?.host_path $PathToHostFile? ?.formatted 0/1?; Dumps the specified ifs file records to a destination host file. If the destination host file is not specified then a record list is returned. This could easily blow memory or cause a time out on either server or client side. If you want to send a mothership ifs file to a host file on the client side then you can first check the number of records using cpp_file_record_count. Small file can be downloaded using dump_ifs_file and larger files can be downloaded a record at a time or in groups using cpp_file_record_read_vector. */ } ::set rwb1_debug 0; ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::ifsutil::dump_ifs_file,dump_ifs_file,1000.1,sargs==$sargs";} ::set Database [::sargs::get $sargs .database]; ::if {$Database eq ""} { ::qw::error 314120200902153402 "[::qw::procname] - .database not specified"; } ::set SrcPath [::sargs::get $sargs .path]; ::if {$SrcPath eq ""} { ::qw::error 314120200902153403 "[::qw::procname] - .path not specified"; } ::set DstPath [::sargs::get $sargs .host_path]; ::if {$DstPath eq ""} { ::qw::error 314120200902153404 "[::qw::procname] - .host_path not specified"; } ::set TotalsLoad [::sargs::boolean_get $sargs .totals_load]; ::set IfsFile [$Database cpp_file_factory]; ::qw::finally [::list $IfsFile cpp_destroy]; $IfsFile cpp_file_open .path $SrcPath; ::set DstHandle [::open $DstPath w+]; ::fconfigure $DstHandle -translation binary; ::qw::finally [::list ::close $DstHandle]; ::for {::set Record [$IfsFile cpp_record_first .totals_load $TotalsLoad]} {[::sargs::size $Record]!=0} {::set Record [$IfsFile cpp_record_next $Record .totals_load $TotalsLoad]} { ::if {[::sargs::boolean_get $sargs .formatted]} { ::puts $DstHandle "[::sargs::format $Record]"; } else { ::puts $DstHandle "$Record"; } } ::if {$rwb1_debug} {::puts "rwb1_debug,::qw::ifsutil::dump_ifs_file,dump_ifs_file,1000.99";} ::return ""; }