template::util::read_file (public)

 template::util::read_file path

Defined in packages/acs-templating/tcl/util-procs.tcl

Reads a text file.

Parameters:
path (required)
The absolute path to the file
Returns:
A string with the contents of the file.

Partial Call Graph (max 5 caller/called nodes):
%3 test_read_write_file read_write_file (test acs-templating) template::util::read_file template::util::read_file test_read_write_file->template::util::read_file test_sync_file_get_document sync_file_get_document (test acs-authentication) test_sync_file_get_document->template::util::read_file ad_try ad_try (public) template::util::read_file->ad_try template::util::set_file_encoding template::util::set_file_encoding (public) template::util::read_file->template::util::set_file_encoding aa_test::parse_install_file aa_test::parse_install_file (public) aa_test::parse_install_file->template::util::read_file aa_test::parse_test_file aa_test::parse_test_file (public) aa_test::parse_test_file->template::util::read_file acs::disk_cache_eval acs::disk_cache_eval (public) acs::disk_cache_eval->template::util::read_file api_add_calling_info_to_procdoc api_add_calling_info_to_procdoc (private) api_add_calling_info_to_procdoc->template::util::read_file apidoc::get_xql_snippet apidoc::get_xql_snippet (private) apidoc::get_xql_snippet->template::util::read_file

Testcases:
sync_file_get_document, read_write_file
Source code:
    if {![file exists $path]} {
        error "File $path does not exist"
    }

    #
    # Use ad_try to make sure that the file descriptor is finally
    # closed.
    #
    ad_try {
        set fd [open $path]
        template::util::set_file_encoding $fd
        set text [read $fd]
    } on error {errMsg opts} {
        dict incr opts -level
        ns_log error "template::util::read_file on fd $fd: $errMsg,\n$::errorInfo"
        return -options [dict replace $opts -inside $opts$errMsg
    } finally {
        close $fd
    }

    return $text
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: