Skip to content

Commit

Permalink
strip tailing slashes in mkdir_recursive, since Unix.mkdir doesn't li…
Browse files Browse the repository at this point in the history
…ke it (also use mkdir_from_path in gencs/genjava) (closes #6212)
  • Loading branch information
nadako committed Jun 7, 2017
1 parent d686184 commit e5e0879
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
9 changes: 8 additions & 1 deletion src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,14 @@ let rec mkdir_recursive base dir_list =
| "/" -> "/" ^ dir
| _ -> base ^ "/" ^ dir
in
if not ( (path = "") || ( ((String.length path) = 2) && ((String.sub path 1 1) = ":") ) ) then
let path_len = String.length path in
let path =
if path_len > 0 && path.[path_len - 1] = '/' || path.[path_len - 1] == '\\' then
String.sub path 0 (path_len - 1)
else
path
in
if not ( (path = "") || ( (path_len = 2) && ((String.sub path 1 1) = ":") ) ) then
if not (Sys.file_exists path) then
Unix.mkdir path 0o755;
mkdir_recursive (if (path = "") then "/" else path) remaining
Expand Down
3 changes: 1 addition & 2 deletions src/generators/gencs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3186,8 +3186,7 @@ let generate con =

RenameTypeParameters.run gen.gtypes_list;

let parts = Str.split_delim (Str.regexp "[\\/]+") gen.gcon.file in
mkdir_recursive "" parts;
mkdir_from_path gen.gcon.file;

List.iter (fun md_def ->
let source_dir = gen.gcon.file ^ "/src/" ^ (String.concat "/" (fst (path_of_md_def md_def))) in
Expand Down
4 changes: 1 addition & 3 deletions src/generators/genjava.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2384,9 +2384,7 @@ let generate con =
let str_cl = match gen.gcon.basic.tstring with | TInst(cl,_) -> cl | _ -> assert false in
str_cl.cl_super <- Some (get_cl (get_type gen (["haxe";"lang"], "NativeString")), []);

let mkdir dir = if not (Sys.file_exists dir) then Unix.mkdir dir 0o755 in
mkdir gen.gcon.file;
mkdir (gen.gcon.file ^ "/src");
mkdir_from_path (gen.gcon.file ^ "/src");

let out_files = ref [] in

Expand Down

0 comments on commit e5e0879

Please sign in to comment.