For some reason, blitzmax doesn't like paths with ~1 in them: "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ssftmp\"
Is there a way to convert the path to its full name?
Is there a way to convert the path to its full name?
DebugLog GetFullPath(getenv_("temp")) Function GetFullPath:String(shortpath:String) Local lngpath:Byte Ptr, size:Int = Len(shortpath) GetLongPathNameW(shortpath, lngpath, 1024) Return String.fromcstring(lngpath) End Function Extern "win32" Function GetLongPathNameW(lpzshortpath:String, lpzlongpath:Byte Ptr, cchbuff:Int) = "GetLongPathNameW@12" End Extern
Function NiceFileName$(file$) size = Len(file) + 100 temp = CreateBank(size) GetShortPathName(file$, temp, size) file$ = PeekString(temp, 0) GetLongPathName(file$, temp, size) s$ = PeekString(temp, 0) FreeBank temp Return s End Function
Print GetFullPath(getenv_("temp")) Function GetFullPath:String( shortpath:String) Local buf:Short[1024] GetLongPathNameW( shortpath, buf, buf.Length) Return String.FromWString(buf) EndFunction Extern "win32" Function GetLongPathNameW( lpzshortpath$w, lpzlongpath:Short Ptr, cchbuff:Int) EndExtern
Function LongPath$(sp$) Local spa$[] = sp.Replace("/","").Split("") Local con$[] Local spp$ = "" Local s$,si% Local po$ For Local i% = 1 To spa.Length-1 spp :+ spa[i-1]+"" If spa[i].Find("~~") = -1 Then Continue EndIf s = spa[i].ToLower()[..spa[i].Length-2] si = Int(spa[i][spa[i].Length-1..]) con = LoadDir( spp ) For Local p$ = EachIn con po = p p = p.Replace(" ","").ToLower()[..6] If p = s Then si :- 1 If si = 0 Then spa[i] = po Exit EndIf EndIf Next Next spp :+ spa[spa.length-1] Return spp End FunctionIt's hacky, but it should work.