Browse Source

Allow absolute path names

Hugh Sanderson 14 years ago
parent
commit
128dd3beb8
1 changed files with 9 additions and 4 deletions
  1. 9 4
      gencpp.ml

+ 9 - 4
gencpp.ml

@@ -105,10 +105,15 @@ let rec make_class_directories base dir_list =
 	( match dir_list with
 	( match dir_list with
 	| [] -> ()
 	| [] -> ()
 	| dir :: remaining ->
 	| dir :: remaining ->
-		let path = base ^ "/" ^ dir  in
-		if not (Sys.file_exists path) then
+		let path = match base with
+                   | "" ->  dir
+                   | "/" -> "/" ^ dir
+                   | _ -> base ^ "/" ^ dir  in
+                if ( not ( (path="") ||
+                     ( ((String.length path)=3) && ((String.sub path 1 1)=":") ) ) ) then
+		   if not (Sys.file_exists path) then
 			Unix.mkdir path 0o755;
 			Unix.mkdir path 0o755;
-		make_class_directories path remaining
+		make_class_directories (if (path="") then "/" else path) remaining 
 	);;
 	);;
 
 
 
 
@@ -124,7 +129,7 @@ let new_cpp_file base_dir = new_source_file base_dir "src" ".cpp";;
 let new_header_file base_dir = new_source_file base_dir "include" ".h";;
 let new_header_file base_dir = new_source_file base_dir "include" ".h";;
 
 
 let make_base_directory file =
 let make_base_directory file =
-	make_class_directories "." (file :: []);;
+	make_class_directories "" ( ( Str.split_delim (Str.regexp_string "/") file ) );
 
 
 
 
 (* CPP code generation context *)
 (* CPP code generation context *)