Skip to content

Commit 10246ae

Browse files
committed
Recursively create target folder before attempting to compile there
1 parent 0a1f335 commit 10246ae

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

PureBasicIDE/CompilerInterface.pb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2500,6 +2500,10 @@ Procedure Compiler_BuildTarget(SourceFileName$, TargetFileName$, *Target.Compile
25002500
Command$ + Chr(9) + "DLL"
25012501
EndIf
25022502

2503+
CompilerIf Not #SpiderBasic
2504+
CreateDirectoryRecursive(GetPathPart(TargetFileName$))
2505+
CompilerEndIf
2506+
25032507
CompilerWrite(Command$)
25042508

25052509
; We need the *ActiveSource for HandleCompilerResponse if the mainfile option is set

PureBasicIDE/Declarations.pb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ Declare.s UniqueFilename(File$) ; return a unique representa
366366
Declare IsEqualFile(File1$, File2$) ; returns true if the 2 filenames identify the same file
367367
Declare.s CreateRelativePath(BasePath$, FileName$) ; turn the full path FileName$ into a relative one to BasePath$
368368
Declare.s ResolveRelativePath(BasePath$, FileName$) ; merge a base path and a relative path to a full path
369+
Declare CreateDirectoryRecursive(Directory$) ; create a directory and its parent directories, recursively if necessary
369370

370371
;- GotoWindow.pb
371372
;

PureBasicIDE/FileSystem.pb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,3 +275,26 @@ Procedure.s ResolveRelativePath(BasePath$, FileName$)
275275
ProcedureReturn UniqueFilename(FileName$)
276276
EndProcedure
277277

278+
Procedure CreateDirectoryRecursive(Directory$)
279+
If Directory$
280+
Select FileSize(Directory$)
281+
Case -2 ; already exists - OK!
282+
ProcedureReturn #True
283+
284+
Case -1 ; does not exist - create it
285+
Parent$ = UniqueFilename(Directory$ + #Separator + ".." + #Separator)
286+
If Parent$ <> ""
287+
CreateDirectoryRecursive(Parent$)
288+
EndIf
289+
CreateDirectory(Directory$)
290+
If FileSize(Directory$) = -2
291+
ProcedureReturn #True
292+
EndIf
293+
294+
Default ; it's a file!
295+
ProcedureReturn #False
296+
EndSelect
297+
EndIf
298+
ProcedureReturn #False
299+
EndProcedure
300+

0 commit comments

Comments
 (0)