Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
V6s5 - Can ADIR() return both Short and Long File names
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00871673
Message ID:
00872172
Views:
30
This message has been marked as a message which has helped to the initial question of the thread.
>I want the default Short File Names by which they are stored in the order they are stored (this I doubt that ADIR is able to not in terms of SFNs) but also want the corresponding Long File Names for reporting purposes.

I take this to mean that ADIR lists the SFN's in the order you want. You can just convert them one at a time to LFNs using:
FUNCTION Fn2Lfn
LPARAMETERS pcFileName
* FN2LFN = "FileName" To "LongFileName"
*
*    AUTHOR: Wgcs.. Function derived from sample code posted by
*             AirCon (IS/IT--Manageme)  on TekTips.com on May 12, 2003
*      DATE: added LASv10.40, adjusted to convert all parts of the path, May 27, 2003 LASv10.42
*   PURPOSE: converts an 8.3 or an all-uppercase filename into
*             it's proper-case long filename.
* REFERENCE: Used by aasApplication.GetFile
*     NOTES: If the file isn't found, then the original passed
*            filename is returned.

Declare Long FindFirstFile in Kernel32 as fnFindFirst ;
   String cFileName, String @WIN32_DATA
Declare FindClose in Kernel32 as fnFindClose Long hFile
LOCAL lcFile, lcBuffer, lcPath, lcLastPath, lcFullPath
  lcFullPath = ''
  lcPath     = pcFileName
  lcLastPath = ''
  
  do while !(lcPath==lcLastPath)
    lcLastPath = lcPath
    lcBuffer   = replicate(chr(0), 318)
    hFile = fnFindFirst(lcPath, @lcBuffer)
    If (hFile <= 0)
      lcFile = JustFName(lcPath)
    else
      lcFile = substr(lcBuffer, 45)
      lcFile = left(lcFile, at(chr(0), lcFile)-1)
      fnFindClose(hFile)
    endif    
    
    lcFullPath = iif(Empty(lcFullPath),lcFile,addbs(lcFile)+lcFullPath)
    lcPath = JustPath(lcPath) && Remove rightmost file/dir reference
  enddo
  lcFullPath = AddBS(lcPath)+lcFullpath
  
  Clear Dlls fnFindFirst, fnFindClose
  RETURN lcFullPath
ENDFUNC
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform