apm_guess_file_type pathWhat it does:
Guesses and returns the file type key corresponding to a particular path (or an empty string if none is known).Defined in: /web/philip/packages/acs-core/apm-procs.tcl$pathshould be relative to the package directory (e.g.,apm/admin-www/index.tclfor/packages/acs-core/apm/admin-www/index.tcl. We use the following rules:Rules are applied in this order (stopping with the first match).
- Files with extension
.sqlare considered data-model files, or if any path contains the substringupgrade, data-model upgrade files.- Files with extension
.infoare considered package specification files.- Files with a path component named
docare considered documentation files.- Files with extension
.plor.shor which have a path component namedbin, are considered shell-executable files.- Files with a path component named
templatesare considered template files.- Files with extension
.htmlor.adp, in the top level of the package, are considered documentation files.- Files with a path component named
wwworadmin-wwware considered content-page files.- Files ending in
-procs.tclor-init.tclare considered Tcl procedure or Tcl initialization files, respectively.
Source code:
    set components [split $path "/"]
    set extension [file extension $path]
    set type ""
    if { [string equal $extension ".sql"] } {
	if { [lsearch -glob $components "*upgrade*"] >= 0 } {
	    set type "data_model_upgrade"
	} else {
	    set type "data_model"
	}
    } elseif { [string equal $extension ".info"] } {
	set type "package_spec"
    } elseif { [lsearch $components "doc"] >= 0 } {
	set type "documentation"
    } elseif { [string equal $extension ".pl"] ||  [string equal $extension ".sh"] ||  [lsearch $components "bin"] >= 0 } {
	set type "shell"
    } elseif { [lsearch $components "templates"] >= 0 } {
	set type "template"
    } elseif { [llength $components] == 1 &&  ([string equal $extension ".html"] || [string equal $extension ".adp"]) } {
	# HTML or ADP file in the top level of a package - assume it's documentation.
	set type "documentation"
    } elseif { [lsearch $components "www"] >= 0 || [lsearch $components "admin-www"] >= 0 } {
	set type "content_page"
    } else {
	if { [string equal $extension ".tcl"] &&  [regexp -- {-(procs|init)\.tcl$} [file tail $path] "" kind] } {
	    set type "tcl_$kind"
	}
    }
    return $type