Ver Fonte

strip tailing slashes in mkdir_recursive, since Unix.mkdir doesn't like it (also use mkdir_from_path in gencs/genjava) (closes #6212)

Dan Korostelev há 8 anos atrás
pai
commit
e5e0879929
3 ficheiros alterados com 10 adições e 6 exclusões
  1. 8 1
      src/context/common.ml
  2. 1 2
      src/generators/gencs.ml
  3. 1 3
      src/generators/genjava.ml

+ 8 - 1
src/context/common.ml

@@ -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

+ 1 - 2
src/generators/gencs.ml

@@ -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

+ 1 - 3
src/generators/genjava.ml

@@ -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