# Root directory, were all huge files are located set root /tmp/examples/ # Name of current server set server [ns_info server] # get query parameter for "file" and "create" set file [ns_queryget file] set create [ns_queryget create] # Create test files if { $create == 1 } { if { [catch { file mkdir $root set fd [open $root/test1.dat w] puts -nonewline $fd [string repeat "test" 1000000] close $fd } errmsg] } { ns_log error "writer.tcl: $errmsg" } } append data "
"
set writerthreads [ns_config ns/server/$server/module/nssock writerthreads]
append data \
"The current server (named $server
) " \
"is configured with $writerthreads writer thread(s).
" \
"You can change the number of writer threads in the used configuration file
" \
"[ns_info config]
.
The configuration file contains entries like the following:
" \ "
ns_section ns/server/$server/module/nssock\n ns_param writerthreads $writerthreads\n" \ "" # Show all files if { $file eq "" } { set files [lsort [glob -nocomplain $root/*.dat]] if { [llength $files] == 0 } { append data \ "No test files exist in the configured TMP folder
$root
." \
"Do you want to create them? Yes"
} else {
append data "List of available files in $root:
Back to example page.
"
ns_return 200 text/html $data
return
}
ns_log notice "check exist [ns_normalizepath $root/$file]"
# Check if it exists
set path [ns_normalizepath $root/$file]
if { ![file exists $path] } {
ns_returnnotfound
return
}
# Let the writer to handle headers and size
set rc [ns_writer submitfile -headers $path]
ns_log notice "call submitfile $path -> $rc"
if { $rc } {
ns_returnnotfound
}
ns_log Notice "file $file has been submitted: $rc"
#
# Local variables:
# mode: tcl
# tcl-indent-level: 4
# indent-tabs-mode: nil
# End: