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 - 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_sync_file_get_document sync_file_get_document (test acs-authentication) template::util::read_file template::util::read_file test_sync_file_get_document->template::util::read_file 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 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 auth::sync::get_doc::file::GetDocument auth::sync::get_doc::file::GetDocument (private) auth::sync::get_doc::file::GetDocument->template::util::read_file

Testcases:
sync_file_get_document
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: