Permalink
Browse files

[fix] stdlib/file: improve and add bindings

  • Loading branch information...
1 parent eb38538 commit 18cc3e93fbf259befb44eb9d0fec508423c3f8bb François-Régis Sinot committed Aug 23, 2011
Showing with 17 additions and 14 deletions.
  1. +5 −6 opabsl/mlbsl/bslFile.ml
  2. +4 −4 stdlib/core/web/resource/resource_private.opa
  3. +8 −4 stdlib/io/file/file.opa
View
@@ -38,13 +38,12 @@ let is_directory x =
let make_dir n =
try Unix.mkdir n 0o700; true with _ -> false
-##register basename : string -> option(string)
-let basename f =
- try Some (Filename.basename f) with _ -> None
+##register basename \ `Filename.basename` : string -> string
-##register dirname : string -> option(string)
-let dirname f =
- try Some (Filename.dirname f) with _ -> None
+##register dirname \ `Filename.dirname` : string -> string
+
+##register dir_sep : string
+let dir_sep = Filename.dir_sep
##register copy: string, string, bool -> void
let copy a b force = ignore (File.copy ~force a b)
@@ -149,8 +149,8 @@ Resource_private =
file_create = %% BslFile.of_string %%: string, string -> void
dir_exists = %% BslFile.is_directory %%: string -> bool
dir_create = %% BslFile.create_full_path %%: string -> void
- //get_base_name = %% BslFile.basename %%: string -> option(string)
- get_dir_name = %% BslFile.dirname %%: string -> option(string)
+ //get_base_name = %% BslFile.basename %%: string -> string
+ get_dir_name = %% BslFile.dirname %%: string -> string
file_move = %% BslFile.move %%: string,string,bool -> void
//If necessary, show resources as they appear
@@ -195,8 +195,8 @@ Resource_private =
else void
//2. If path doesn't exist, create path
- //base_name = Option.get(get_base_name(name)) //Note: error case corresponds to weird characters in file name
- dir_name = Option.get(get_dir_name(name)) //Note: error case corresponds to weird characters in file name
+ //base_name = get_base_name(name)
+ dir_name = get_dir_name(name)
do if not(dir_exists(dir_name)) then dir_create(dir_name) else void
must_create =
View
@@ -36,10 +36,14 @@
* A module for very basic file access
*/
File = {{
-content = %% BslFile.content %% : string -> string
-content_opt = %% BslFile.content_opt %% : string -> option(string)
-is_directory = %% BslFile.is_directory %% : string -> bool
-mimetype_opt = %% BslFile.mimetype_opt %% : string -> option(string)
+ content = %% BslFile.content %% : string -> string
+ content_opt = %% BslFile.content_opt %% : string -> option(string)
+ is_directory = %% BslFile.is_directory %% : string -> bool
+ mimetype = %% BslFile.mimetype_opt %% : string -> option(string)
+ @deprecated({use="File.mimetype"}) mimetype_opt = %% BslFile.mimetype_opt %% : string -> option(string)
+ basename = %% BslFile.basename %% : string -> string
+ dirname = %% BslFile.dirname %% : string -> string
+ dir_sep = %% BslFile.dir_sep %% : string
}}

0 comments on commit 18cc3e9

Please sign in to comment.