﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
2909	_PathMake() issues in <File.au3>	Synix <cross.fire@…>	guinness	"_PathMake() adds no backslash if the dir parameter is empty (only drive + filename set).
Also there are some other minor inconsistencies as you will see in my example:

{{{
#include <File.au3>

ConsoleWrite(@CRLF & ""! "" & _PathMake(""c"", """", ""testfile"", ""ext"")) ; no slash :(
ConsoleWrite(@CRLF & ""- "" & _PathMake("""", ""testfolder"", ""testfile"", ""ext"")) ; adding leading slash is incorrect behavior on no drive
ConsoleWrite(@CRLF & ""- "" & _PathMake("""", ""testfolder"", """", """")) ; adding trailing slash is incorrect behavior on no file
ConsoleWrite(@CRLF & ""- "" & _PathMake(""c"", ""testfolder\\testfolder2"", ""testfile"", ""ext"")) ; double slash :/
ConsoleWrite(@CRLF & ""- "" & _PathMake(""c"", ""testfolder/testfolder2"", ""testfile"", ""ext"")) ; wrong slash :/
ConsoleWrite(@CRLF & @CRLF)
}}}


This would be my fix for it:
{{{
Func _PathMake($sDrive, $sDir, $sFileName, $sExtension)
	; Format $sDrive, if it's not a UNC server name, then just get the drive letter and add a colon
	If StringLen($sDrive) Then
		If Not (StringLeft($sDrive, 2) = ""\\"") Then $sDrive = StringLeft($sDrive, 1) & "":""
	EndIf

	; Format the directory
	If StringLen($sDir) Then
		; Replace any [repeating] [back-]slashes with a single backslash
		$sDir = StringRegExpReplace($sDir, ""[/\\]+"", ""\\"")
		; Add leading backslash if drive is set
		If StringLen($sDrive) And Not (StringLeft($sDir, 1) = ""\"") Then $sDir = ""\"" & $sDir
	EndIf

	; Add trailing backslash to the directory if necessary
	If StringLen($sFileName) And (StringLen($sDrive) Or StringLen($sDir)) Then
		If Not (StringRight($sDir, 1) = ""\"") Then $sDir = $sDir & ""\""
	EndIf

	; Nothing to be done for the filename

	; Add the period to the extension if necessary
	If StringLen($sExtension) Then
		If Not (StringLeft($sExtension, 1) = ""."") Then $sExtension = ""."" & $sExtension
	EndIf

	Return $sDrive & $sDir & $sFileName & $sExtension
EndFunc   ;==>_PathMake
}}}
Surely you could improve the code even more (e.g. removing unnecessary preexisting leading/trailing slashes from the parameters), but I think you kept the function pretty minimalistic for efficiency reasons. That's why I hope you won't throw out the RegExpReplace from my suggestion code since it's not necessary for fixing the only real bug from my example (line 3), but it does way improve consistency."	Bug	closed	3.3.13.20	AutoIt	Other	None	Fixed		
