apm_guess_file_type (public)
apm_guess_file_type package_key path
Defined in packages/acs-bootstrap-installer/tcl/30-apm-load-procs.tcl
Guesses and returns the file type key corresponding to a particular path (or an empty string if none is known).
$path
should be relative to the package directory (e.g.,www/index.tcl
) for/packages/bboard/admin-www/index.tcl
. We use the following rules:Rules are applied in this order (stopping with the first match).
- Files with extension
.sql
are considered data-model files,- Files with extension
.dat
are considered SQL data files.- Files with extension
.ctl
are considered sql data loader control files. or if any path contains the substringupgrade
, data-model upgrade files.- Files with extension
.sqlj
are considered sqlj_code files.- Files with extension
.info
are considered package specification files.- Files with extension
.xql
are considered query files.- Files with extension
.java
are considered java code files.- Files with extension
.jar
are considered java archive files.- Files with a path component named
doc
are considered documentation files.- Files with extension
.pl
or.sh
or which have a path component namedbin
, are considered shell-executable files.- Files with a path component named
templates
are considered template files.- Files with extension
.html
or.adp
, in the top level of the package, are considered documentation files.- Files with a path component named
www
oradmin-www
are considered content-page files.- Files with a path component named
lib
are considered include_page files.- Files under package-key/tcl ending in
-procs(-)+()*.tcl)
or-init.tcl
are considered Tcl procedure or Tcl initialization files, respectively.- File ending in
.tcl
are considered Tcl utility script files (normally found only in the bootstrap installer).- Files with extension
.xml
in the directory catalog are considered message catalog files.- Tcl procs or init files under package-key/tcl in a test directory are of type test_procs and test_init respectively.
- Parameters:
- package_key
path
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- apm_guess_file_type
Source code: set components [split $path "/"] set dirs_in_pageroot [llength [split $::acs::pageroot "/"]] ;# See comments by RBM # Fix to cope with both full and relative paths if { [string index $path 0] eq "/"} { set components_lesser [lrange $components $dirs_in_pageroot end] } else { set components_lesser $components } set extension [ad_file extension $path] set type "" # DRB: someone named a file "acs-mail-create-packages.sql" rather than # the conventional "acs-mail-packages-create.sql", causing it to be # recognized as a data_model_create file, causing it to be explicitly # run by the installer (the author intended it to be included by # acs-mail-create.sql only). I've tightened up the regexp below to # avoid this problem, along with renaming the file... # DRB: I've tightened it up again because forums-forums-create.sql # was being recognized as a datamodel create script for the forums # package. if {$extension eq ".sql"} { if { [lsearch -glob $components "*upgrade-*-*"] >= 0 } { set type "data_model_upgrade" } elseif { [regexp -- "^$package_key-(create|drop)\.sql\$" [ad_file tail $path] "" kind] } { set type "data_model_$kind" } else { set type "data_model" } } elseif {$extension eq ".dat"} { set type "sql_data" } elseif {$extension eq ".ctl"} { set type "ctl_file" } elseif {$extension eq ".sqlj"} { set type "sqlj_code" } elseif {$extension eq ".info"} { set type "package_spec" } elseif {$extension eq ".xql"} { set type "query_file" } elseif {$extension eq ".java"} { set type "java_code" } elseif {$extension eq ".jar"} { set type "java_archive" } elseif { "doc" in $components } { set type "documentation" } elseif { $extension eq ".pl" || $extension eq ".sh" || "bin" in $components } { set type "shell" } elseif { "templates" in $components } { set type "template" } elseif { [llength $components] == 1 && ($extension eq ".html" || $extension eq ".adp") } { # # HTML or ADP file in the top level of a package - assume it # is documentation. # set type "documentation" # RBM: Changed the next elseif to check for 'www' or # 'admin-www' only n levels down the path, since that'd be the # minimum in a path counting from the pageroot } elseif { "www" in $components_lesser || "admin-www" in $components_lesser } { set type "content_page" } elseif { "lib" in $components_lesser } { set type "include_page" } elseif { $extension eq ".tcl" && [lindex $components_lesser 0] eq "tcl" } { # A .tcl file residing under dir .../package_key/tcl/ if { [regexp -- {-(procs|init)(-[0-9a-zA-Z]*)?\.tcl$} [ad_file tail $path] "" kind] } { if {[lindex $components end-1] eq "test"} { set type "test_$kind" } else { set type "tcl_$kind" } } else { set type "tcl_util" } } elseif { [apm_is_catalog_file "${package_key}/${path}"] } { set type "message_catalog" } return $typeXQL Not present: Generic, PostgreSQL, Oracle