apm_guess_file_type

one of the documented procedures in this installation of the ACS
Usage:
apm_guess_file_type   path
What it does:
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., apm/admin-www/index.tcl for /packages/acs-core/apm/admin-www/index.tcl. We use the following rules:
  1. Files with extension .sql are considered data-model files, or if any path contains the substring upgrade, data-model upgrade files.
  2. Files with extension .info are considered package specification files.
  3. Files with a path component named doc are considered documentation files.
  4. Files with extension .pl or .sh or which have a path component named bin, are considered shell-executable files.
  5. Files with a path component named templates are considered template files.
  6. Files with extension .html or .adp, in the top level of the package, are considered documentation files.
  7. Files with a path component named www or admin-www are considered content-page files.
  8. Files ending in -procs.tcl or -init.tcl are considered Tcl procedure or Tcl initialization files, respectively.
Rules are applied in this order (stopping with the first match).
Defined in: /web/philip/packages/acs-core/apm-procs.tcl

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


philg@mit.edu