@@ -174,7 +174,7 @@ def preprocess_file_and_save_result(
174174 result = preprocessor (output_directory , filepath , all_files , includes , stats ,
175175 hip_clang_launch , is_pytorch_extension , clean_ctx , show_progress )
176176
177- fin_path = os .path .join (output_directory , filepath )
177+ fin_path = os .path .abspath ( os . path . join (output_directory , filepath ) )
178178 # Show what happened
179179 if show_progress :
180180 print (
@@ -711,7 +711,7 @@ def preprocessor(
711711 clean_ctx : GeneratedFileCleaner ,
712712 show_progress : bool ) -> HipifyResult :
713713 """ Executes the CUDA -> HIP conversion on the specified file. """
714- fin_path = os .path .join (output_directory , filepath )
714+ fin_path = os .path .abspath ( os . path . join (output_directory , filepath ) )
715715
716716 with open (fin_path , 'r' , encoding = 'utf-8' ) as fin :
717717 if fin .readline () == HIPIFY_C_BREADCRUMB :
@@ -721,7 +721,7 @@ def preprocessor(
721721
722722 orig_output_source = output_source
723723
724- fout_path = os .path .join (output_directory , get_hip_file_path (filepath , is_pytorch_extension ))
724+ fout_path = os .path .abspath ( os . path . join (output_directory , get_hip_file_path (filepath , is_pytorch_extension ) ))
725725 if not os .path .exists (os .path .dirname (fout_path )):
726726 clean_ctx .makedirs (os .path .dirname (fout_path ))
727727
@@ -829,9 +829,14 @@ def repl(m):
829829 with open (fout_path , 'r' , encoding = 'utf-8' ) as fout_old :
830830 do_write = fout_old .read () != output_source
831831 if do_write :
832- with clean_ctx .open (fout_path , 'w' , encoding = 'utf-8' ) as fout :
833- fout .write (output_source )
834- return {"hipified_path" : fout_path , "status" : "ok" }
832+ try :
833+ with clean_ctx .open (fout_path , 'w' , encoding = 'utf-8' ) as fout :
834+ fout .write (output_source )
835+ return {"hipified_path" : fout_path , "status" : "ok" }
836+ except PermissionError as e :
837+ print (f"{ bcolors .WARNING } Failed to save { fout_path } with \" { e .strerror } \" , leaving { fin_path } unchanged.{ bcolors .ENDC } " ,
838+ file = sys .stderr )
839+ return {"hipified_path" : fin_path , "status" : "skipped" }
835840 else :
836841 return {"hipified_path" : fout_path , "status" : "skipped" }
837842
0 commit comments