Permalink
Browse files

[fix] mime: update deprecated option

  • Loading branch information...
1 parent 36445d8 commit 53cc0326f3f2fb1fef064da27efa64613b171cca Raja committed Sep 6, 2011
Showing with 14 additions and 17 deletions.
  1. +2 −2 libbase/file.ml
  2. +2 −2 libbase/file.mli
  3. +8 −11 opalib/opaEnv.ml
  4. +2 −2 passes/surfaceAstStaticInclude.ml
View
@@ -414,9 +414,9 @@ let is_directory path =
st.Unix.st_kind = Unix.S_DIR
with Unix.Unix_error _ -> false
-let mimetype ?magic_file file =
+let mimetype ?mime_db file =
let database =
- match magic_file with
+ match mime_db with
| Some s -> File_mimetype.get_mimetype_database s
| None -> File_mimetype.mimetype_database mlstatelibs in
try
View
@@ -110,10 +110,10 @@ val content_opt : string -> string option
@return [None] if an error occurred, [Some] of the content instead
*)
-val mimetype : ?magic_file:string -> string -> string
+val mimetype : ?mime_db:string -> string -> string
(**
@return the mimetype of the given filename
- @param magic_file is a filename as accepted by the -m option of the command file
+ @param mime_db is a filename as accepted by the -m option of the command file
*)
val is_relative: string -> bool
View
@@ -119,7 +119,7 @@ type opa_options = {
rpc_options : int * int * int;
profile : bool;
- magic_file : string option;
+ mime_database : string option;
project_root : string;
root_inclusions : string option;
undot : bool;
@@ -201,7 +201,7 @@ struct
let slicer_test = ref false
let slicer_dump = ref false
let rpc_options = ref (1,0,0)
- let magic_file = ref None
+ let mime_database = ref None
let project_root = ref cwd
let root_inclusions = ref None
let undot = ref true
@@ -309,15 +309,12 @@ struct
let set_root_inclusions dir = root_inclusions := Some dir
- let set_magic_file f =
+ let set_mime_database f =
if Sys.file_exists f && not (Sys.is_directory f) then
- if File.extension f = "mime" then
- if Sys.command ("file -C -m "^f) = 0 then
- magic_file := Some (File.chop_extension f )
- else
- OManager.error "%S : Bad magic file, try with another one which compiles" f
+ if File.extension f = "xml" then
+ mime_database := Some f
else
- OManager.error "%S : Bad extension. Given file must be a .mime file" f
+ OManager.error "%S : Bad extension. Given file must be a .xml file" f
else
OManager.error "I/O error: @{<bright>%S@} -> No such file or directory" f
@@ -486,7 +483,7 @@ where options are :
("--opack", Arg.String (fun s -> (!opack_file_function) s), "<opack-file> Use an options-packaging file");
("--project-root", Arg.String set_project_root, " Specify the root directory of the project");
("--root-inclusions", Arg.String set_root_inclusions, "<root> Specify the root directory of static inclusions");
- ("--set-mime-magic-file", Arg.String set_magic_file, " Consider given magic file <my_file>.mime for detecting mimetypes. Used with the directive @static_include_directory");
+ ("--set-mime-database", Arg.String set_mime_database, " Consider given mime database for detecting mimetypes. Used with the directive @static_include_directory");
("--show-types", Arg.Set show_types, " Show types of declarations (L0 elements)");
("--slicer-dump", Arg.Set slicer_dump ," Dumps a file containing the side of identifiers and the remote calls they make");
("--version", Arg.Unit (fun () -> print_version (); exit 0), " Print version and exit");
@@ -751,7 +748,7 @@ where options are :
slicer_dump = !ArgParser.slicer_dump;
rpc_options = !ArgParser.rpc_options;
profile = !ArgParser.profile;
- magic_file = !ArgParser.magic_file;
+ mime_database = !ArgParser.mime_database;
project_root = !ArgParser.project_root;
root_inclusions = !ArgParser.root_inclusions;
undot = !ArgParser.undot;
@@ -23,7 +23,7 @@ module F : sig
val normalize_relative_path : string -> string option
val concat : string -> string -> string
val path_sep : string
- val mimetype : ?magic_file:string -> string -> string
+ val mimetype : ?mime_db:string -> string -> string
val explicit_path : string -> string option -> string
val is_relative : string -> bool
@@ -284,7 +284,7 @@ let pass_static_inclusions ~options lcode: (Ident.t, 'a) SurfaceAst.code =
let full_path = PathTransform.string_to_mysys ~relative_position path in
let mimetype =
- try F.mimetype ?magic_file:options.OpaEnv.magic_file full_path
+ try F.mimetype ?mime_db:options.OpaEnv.mime_database full_path
with (File_mimetype.Open s) ->
(OManager.warning ~wclass:warning_file_does_not_exist
"Could not open file %s. Error encountered: %s. I'll replace that file by some debugging code." full_path s;

0 comments on commit 53cc032

Please sign in to comment.