WinFakt! - (7762 of 826967 - 1%) 

 Home | Tips & Tricks | General Info | Downloads | NG Archive | Links | Email | Search | Register | Users | Login

 


 

Tips & Tricks

 

Rating: 47% (3 votes registred)
Rate this item:

Back to list

How can I make Directory() return Long Filenames?

Long time ago I wrote a little utility hDir(). We needed this utility because we needed long filenames from a directory. hDir() is written in Harbour, and because Harbour is 32 bits, it does not have a problem with Long Filenames.

This morning I woke up and had a wonderful simple idea! ;-) There is a function in FiveWin that converts a Short Filename into a Long Filename; SFN2LFN(). When SFN2LFN receives a Short Filename, it just returns the filename, no changes. So, when we put the array we get returned from Directory() through SFN2LFN(), we get a array with ALL Long Filenames. Simple as that!

This is the code that does the trick:

Function LFNDirectory(cDir,cAttr)
Local aDir, cPath := "", nSlash

IF ( nSlash := RAt( "\", cDir ) ) > 0
cPath:=AnsiToOem(LFN2SFN(OemToAnsi(SubStr(cDir,1,nSlash))))
cDir :=SubStr( cDir, nSlash + 1 )
ENDIF

aDir:=Directory( cPath + cDir, cAttr )
AEval(aDir,{|aFile|aFile[1]:=SFN2LFN(OemToAnsi(cPath+aFile[1]))})

RETU aDir

 

 

 

 

© 2002 Bekz.net, Inc. All Rights Reserved.