From 44e5d4d4e6a90ee6900e5dc7e2bdf51fd6c35d87 Mon Sep 17 00:00:00 2001 From: kenmo-pb <25482520+kenmo-pb@users.noreply.github.com> Date: Thu, 31 Jul 2025 23:24:20 -0400 Subject: [PATCH] Recursively create target folder before attempting to compile there --- PureBasicIDE/CompilerInterface.pb | 4 ++++ PureBasicIDE/Declarations.pb | 1 + PureBasicIDE/FileSystem.pb | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/PureBasicIDE/CompilerInterface.pb b/PureBasicIDE/CompilerInterface.pb index 8e458e81..1178ab8f 100644 --- a/PureBasicIDE/CompilerInterface.pb +++ b/PureBasicIDE/CompilerInterface.pb @@ -2500,6 +2500,10 @@ Procedure Compiler_BuildTarget(SourceFileName$, TargetFileName$, *Target.Compile Command$ + Chr(9) + "DLL" EndIf + CompilerIf Not #SpiderBasic + CreateDirectoryRecursive(GetPathPart(TargetFileName$)) + CompilerEndIf + CompilerWrite(Command$) ; We need the *ActiveSource for HandleCompilerResponse if the mainfile option is set diff --git a/PureBasicIDE/Declarations.pb b/PureBasicIDE/Declarations.pb index 6885dafb..aa672600 100644 --- a/PureBasicIDE/Declarations.pb +++ b/PureBasicIDE/Declarations.pb @@ -366,6 +366,7 @@ Declare.s UniqueFilename(File$) ; return a unique representa Declare IsEqualFile(File1$, File2$) ; returns true if the 2 filenames identify the same file Declare.s CreateRelativePath(BasePath$, FileName$) ; turn the full path FileName$ into a relative one to BasePath$ Declare.s ResolveRelativePath(BasePath$, FileName$) ; merge a base path and a relative path to a full path +Declare CreateDirectoryRecursive(Directory$) ; create a directory and its parent directories, recursively if necessary ;- GotoWindow.pb ; diff --git a/PureBasicIDE/FileSystem.pb b/PureBasicIDE/FileSystem.pb index 70d73c56..055270c6 100644 --- a/PureBasicIDE/FileSystem.pb +++ b/PureBasicIDE/FileSystem.pb @@ -275,3 +275,26 @@ Procedure.s ResolveRelativePath(BasePath$, FileName$) ProcedureReturn UniqueFilename(FileName$) EndProcedure +Procedure CreateDirectoryRecursive(Directory$) + If Directory$ <> "" + Select FileSize(Directory$) + Case -2 ; already exists - OK! + ProcedureReturn #True + + Case -1 ; does not exist - create it + Parent$ = UniqueFilename(Directory$ + #Separator + ".." + #Separator) + If Parent$ <> "" + CreateDirectoryRecursive(Parent$) + EndIf + CreateDirectory(Directory$) + If FileSize(Directory$) = -2 + ProcedureReturn #True + EndIf + + Default ; it's a file! + ProcedureReturn #False + EndSelect + EndIf + ProcedureReturn #False +EndProcedure +