struct
(** add_extension_if_absent filename ext append to the string filename
the extension ext but only if the filename has no already an extension.
This operation just works on strings and doesn't modify anything in the filesystem.
Example: *) |
let add_extension_if_absent filename ext =
try
let _ = (Filename.chop_extension filename) in
filename (* because the filename already has an extension *)
with _ -> (filename^"."^ext) (* because the filename has no extension *)
;;
end