;========================================================================================================================================== GoSub Test_udfDirGetExV1 GoSub Test_udfDirGetExV2 GoSub Test_Performance Exit ;========================================================================================================================================== :Test_udfDirGetExV1 ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfDirGetExV1 () Return FileNameLong (DirGet () : ".") : "\" ;.......................................................................................................................................... ; This UDF "udfDirGetExV1" returns the current folderpath with it's true name. ; "True name" means proper cased as shown on the commandline or in explorer view. ; ; This UDF works around a bug (?) in the function DirGet () that always returns ; the last used string value of a previous DirChange (). ; FileNameLong () makes the true name. ;.......................................................................................................................................... ; (c)Detlev Dalitz.20020210.20100227. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ strFolderTemp = ShortCutDir ("Local Settings") : "\Temp\" strFolderPath = strFolderTemp : "tRuEnAmEtEsT\" ; Just a common name. blnResult = DirMake (strFolderPath) strFolderPath = StrLower (strFolderPath) ; Change mixed case to lower case. blnResult = DirChange (strFolderPath) ; DirChange works with lower case folderpath. strFolderPath1 = DirGet () ; DirGet returns folderpath in lower case as in last use of DirChange. strFolderPath2 = udfDirGetExV1 () ; DirGetEx returns the actually really true name in mixed case. strMsgTitle = "udfDirGetExV1 () Get true named path of a folder" strMsgText = "DirGet = " : strFolderPath1 : @LF : "udfDirGetEx = " : strFolderPath2 Message (strMsgTitle, strMsgText) strFolderPath = StrUpper (strFolderPath) ; Change case to upper case. blnResult = DirChange (strFolderPath) ; DirChange works with upper case folderpath. strFolderPath1 = DirGet () ; DirGet returns folderpath in upper case as in last use of DirChange. strFolderPath2 = udfDirGetExV1 () ; DirGetEx returns the actually really true name in mixed case. strMsgTitle = "udfDirGetExV1 () Get true named path of a folder" strMsgText = "DirGet = " : strFolderPath1 : @LF : "udfDirGetEx = " : strFolderPath2 Message (strMsgTitle, strMsgText) DirChange (strFolderTemp) blnResult = DirRemove (StrUpper (strFolderPath)) ; DirRemove works with upper case folderpath. Return ;========================================================================================================================================== :Test_udfDirGetExV2 ;------------------------------------------------------------------------------------------------------------------------------------------ #DefineFunction udfDirGetExV2 () intIC5Prev = IntControl (5, 1, 0, 0, 0) ; System & Hidden files or directories are seen and used. strFolder = DirGet () intCount = ItemCount (strFolder, "\") - 1 For intI = intCount To 2 By -1 DirChange ("..") strFolder = ItemReplace (DirItemize (ItemExtract (intI, strFolder, "\")), intI, strFolder, "\") Next DirChange (strFolder) IntControl (5, intIC5Prev, 0, 0, 0) Return strFolder ;.......................................................................................................................................... ; This UDF "udfDirGetExV2" returns the current folderpath with it's true name. ; "True name" means proper cased as shown on the commandline or in explorer view. ; ; This UDF works around a bug (?) in the function DirGet () that always returns ; the last used string value of a previous DirChange (). ; DirItemize () makes the true name. ;.......................................................................................................................................... ; (c)Detlev Dalitz.20020210.20100227. ;.......................................................................................................................................... #EndFunction ;------------------------------------------------------------------------------------------------------------------------------------------ strFolderTemp = ShortCutDir ("Local Settings") : "\Temp\" strFolderPath = strFolderTemp : "tRuEnAmEtEsT\" ; Just a common name. blnResult = DirMake (strFolderPath) strFolderPath = StrLower (strFolderPath) ; Change mixed case to lower case. blnResult = DirChange (strFolderPath) ; DirChange works with lower case folderpath. strFolderPath1 = DirGet () ; DirGet returns folderpath in lower case as in last use of DirChange. strFolderPath2 = udfDirGetExV2 () ; DirGetEx returns the actually really true name in mixed case. strMsgTitle = "udfDirGetExV2 () Get true named path of a folder" strMsgText = "DirGet = " : strFolderPath1 : @LF : "udfDirGetEx = " : strFolderPath2 Message (strMsgTitle, strMsgText) strFolderPath = StrUpper (strFolderPath) ; Change case to upper case. blnResult = DirChange (strFolderPath) ; DirChange works with upper case folderpath. strFolderPath1 = DirGet () ; DirGet returns folderpath in upper case as in last use of DirChange. strFolderPath2 = udfDirGetExV2 () ; DirGetEx returns the actually really true name in mixed case. strMsgTitle = "udfDirGetExV2 () Get true named path of a folder" strMsgText = "DirGet = " : strFolderPath1 : @LF : "udfDirGetEx = " : strFolderPath2 Message (strMsgTitle, strMsgText) DirChange (strFolderTemp) blnResult = DirRemove (StrUpper (strFolderPath)) ; DirRemove works with upper case folderpath. Return ;========================================================================================================================================== :Test_Performance strMsgTitle = "Demo udfDirGetExV1 udfDirGetExV2 Performance Test" blnResult = DirChange (ShortCutDir ("Local Settings") : "\Temp\") intTestLoop = 1000 intTestMax = 2 intT = 1 Display (1, strMsgTitle, "Running Test " : intT : ", please wait ...") Exclusive (@ON) intStart = GetTickCount () For intI = 1 To intTestLoop strResult = udfDirGetExV1 () Next intTicks%intT% = GetTickCount () - intStart Exclusive (@OFF) intT = 2 Display (1, strMsgTitle, "Running Test " : intT : ", please wait ...") Exclusive (@ON) intStart = GetTickCount () For intI = 1 To intTestLoop strResult = udfDirGetExV2 () Next intTicks%intT% = GetTickCount () - intStart Exclusive (@OFF) Decimals (0) intTicksMax = 0 For intT = 1 To intTestMax intTicksMax = Max (intTicksMax, intTicks%intT%) Next If intTicksMax < 1 Then intTicksMax = 1 For intT = 1 To intTestMax intPct%intT% = 100 * intTicks%intT% / intTicksMax Next strMsgText = "" For intT = 1 To intTestMax strMsgText = strMsgText : "Test " : intT : @TAB : "intTicks = " : @TAB : intTicks%intT% : @TAB : intPct%intT% : " %%" : @CRLF Next ClipPut (strMsgText) Message (strMsgTitle, strMsgText) :CANCEL Exit ;------------------------------------------------------------------------------------------------------------------------------------------ ; Performance Test Result ; Test 1 intTicks = 782 27 % <== The winner. ; Test 2 intTicks = 2890 100 % ;------------------------------------------------------------------------------------------------------------------------------------------ ;==========================================================================================================================================