#include <WinAPIShPath.au3>
Func _PathIsValid($sPath)
Return _WinAPI_PathIsUNC($sPath) Or Not _WinAPI_PathIsFileSpec($sPath)
EndFunc
Func Path_IsCorrect_($_sPath)
Local $_iResult = StringRegExp($_sPath, '\A\z|[|/\*<>?"\v\t]|((\A([^[:alpha:]]|))|.{2}):|:(\z|[^\\])|\\{2}|\.{2}\z|(\A|\\)\h+|(\.{2,}[\h\.]+|\\\.|[^\.\\]\.+|\h+)(\z|\\)|(\A|\\)\.[^\.\h\\]+(\\|\z)', '')
Return Not $_iResult
EndFunc
$Path = '.D:\Folder Name\.SubFolder Name\.0'&@LF
$Path &= ' \D:\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= ' :D\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'я:\ Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'DD:\Folder Name \SubFolder Name\File Name.Type'&@LF
$Path &= 'D: '&@LF
$Path &= 'D:\Folder Name\ \File Name.Type'&@LF
$Path &= 'D:\Folder Name\ . . . \File Name.Type . . .'&@LF
$Path &= '\D:\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= ':D\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'я:\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'DD:\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:'&@LF
$Path &= 'D:\Folder Name\:SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name\SubFolder Name\File Name.Type:'&@LF
$Path &= '\ \Folder.k'&@LF
$Path &= 'Folder.k'&@LF
$Path &= 'Folder .name'&@LF
$Path &= 'Folder. name'&@LF
$Path &= 'Folder Name\. '&@LF
$Path &= 'Folder Name\. .'&@LF
$Path &= 'Folder Name\. . '&@LF
$Path &= '. \Folder Name'&@LF
$Path &= '. .\Folder Name'&@LF
$Path &= '. . \Folder Name'&@LF
$Path &= '.\Folder Name\SubFolder Name'&@LF
$Path &= '..\Folder Name\SubFolder Name'&@LF
$Path &= '...\Folder Name\SubFolder Name'&@LF
$Path &= 'Folder Name\SubFolder Name\.'&@LF
$Path &= 'Folder Name\SubFolder Name\..'&@LF
$Path &= 'Folder Name\SubFolder Name\...'&@LF
$Path &= ' .\Folder Name\SubFolder Name'&@LF
$Path &= 'Folder Name\SubFolder Name\ .'&@LF
$Path &= '..\Folder Name\SubFolder Name\..\..\..\'&@LF
$Path &= '.Folder Name\SubFolder Name\..\..\..\'&@LF
$Path &= 'Folder Name\SubFolder Name\..\..\gg..\'&@LF
$Path &= '..Folder Name\SubFolder Name\..\..\..\'&@LF
$Path &= '...\Folder Name\SubFolder Name\..\..\..\'&@LF
$Path &= 'Folder Name\SubFolder Name\..\..\.'&@LF
$Path &= '.\.\Folder Name\SubFolder Name\..\..\..\'&@LF
$Path &= 'Folder Name\SubFolder Name\'&@LF
$Path &= '.\Folder Name\SubFolder Name\'&@LF
$Path &= '\Folder Name\SubFolder Name\'&@LF
$Path &= 'D:\Folder Name\SubFolder Name\'&@LF
$Path &= 'D:\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\. Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\'&@LF
$Path &= 'D:\. 0'&@LF
$Path &= 'D:\..0'&@LF
$Path &= 'D:\.0.0'&@LF
$Path &= 'D:\.0 0'&@LF
$Path &= 'D:\.0'&@LF
$Path &= 'D:\. '&@LF
$Path &= 'D:\..'&@LF
$Path &= 'D:\Fol>der Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name \SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name.\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name\SubFolder Name\File Name.Type '&@LF
$Path &= 'D:\Folder Name\SubFolder Name\File Name.Type.'&@LF
$Path &= ' D\Folder Name\SubFolder Name\File Name.Type'&@LF
$Path &= '.D\Folder Na.me\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name\\SubFolder Name\File Name.Type'&@LF
$Path &= 'D:\Folder Name\ SubFolder Name\File Name.Type'&@LF
$Path = StringSplit($Path, @LF)
$c=0
$t=TimerInit()
For $b=1 To 10
For $a=1 To $Path[0]
Path_IsCorrect_($Path[$a])
$c +=1
Next
Next
$t=TimerDiff($t)
ConsoleWrite('Path_IsCorrect_() - For: ' & $c&' / Time: '&$t&@LF)
$c=0
$t=TimerInit()
For $b=1 To 10
For $a=1 To $Path[0]
_PathIsValid($Path[$a])
$c +=1
Next
Next
$t=TimerDiff($t)
ConsoleWrite('_PathIsValid() - For: ' & $c&' / Time: '&$t&@LF)
ConsoleWrite(@LF&@LF&@LF)
ConsoleWrite('_PathIsValid() - Result: '&@LF)
For $z1=1 To $Path[0]-1
If $Path[$z1] = '' Then
ConsoleWrite(@LF & @LF & @LF)
ContinueLoop
EndIf
If Not _PathIsValid($Path[$z1]) Then
ConsoleWrite(StringFormat('%-10s', '-Error: ') & '[' & $Path[$z1] & ']' & @LF)
Else
ConsoleWrite(StringFormat('%-10s', '+Ok: ') & '[' & $Path[$z1] & ']' & @LF)
EndIf
Next
ConsoleWrite(@LF&@LF&@LF)
ConsoleWrite('Path_IsCorrect_() - Result: '&@LF)
For $z1=1 To $Path[0]-1
If $Path[$z1] = '' Then
ConsoleWrite(@LF & @LF & @LF)
ContinueLoop
EndIf
If Not Path_IsCorrect_($Path[$z1]) Then
ConsoleWrite(StringFormat('%-10s', '-Error: ') & '[' & $Path[$z1] & ']' & @LF)
Else
ConsoleWrite(StringFormat('%-10s', '+Ok: ') & '[' & $Path[$z1] & ']' & @LF)
EndIf
Next