cr_filename_to_mime_type (public)
cr_filename_to_mime_type [ -create ] filename
Defined in packages/acs-content-repository/tcl/revision-procs.tcl
given a filename, returns the mime type. If the -create flag is given the mime type will be created; this assumes there is some other way such as ns_guesstype to find the filename
- Switches:
- -create
(boolean) (optional)- flag whether to create the mime type the routine picks for filename
- Parameters:
- filename - the filename to try to guess a mime type for (the file need not exist, the routine does not attempt to access the file in any way)
- Returns:
- mimetype (or */* of unknown)
- Author:
- Jeff Davis <davis@xarg.net>
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- auth_authenticate
Source code: set extension [string tolower [string trimleft [file extension $filename] "."]] if {$extension eq ""} { return "*/*" } if {[db_0or1row lookup_mimetype { select mime_type from cr_extension_mime_type_map where extension = :extension }]} { return $mime_type } else { set mime_type [string tolower [ns_guesstype $filename]] ns_log Debug "guessed mime \"$mime_type\" create_p $create_p" if {(!$create_p) || $mime_type eq "*/*" || $mime_type eq ""} { # we don't have anything meaningful for this mimetype # so just */* it. return "*/*" } # We guessed a type but there was no mapping # create it and map it. We know the extension cr_create_mime_type -extension $extension -mime_type $mime_type -description {} return $mime_type }XQL Not present: Generic PostgreSQL XQL file: packages/acs-content-repository/tcl/revision-procs-postgresql.xql
Oracle XQL file: packages/acs-content-repository/tcl/revision-procs-oracle.xql