long file names

Post Reply
Peterg
Posts: 62
Joined: Mon Nov 28, 2005 5:36 pm
Location: Oxford UK
Contact:

long file names

Post by Peterg »

Hello
I am trying to use lcreat to create long file names but each time i try i get a truncated name 8 characters long.

I can use the clfn.dll and this seems to work but occassionally it writes truncated file names aswell

Anybody any ideas

Peter
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Peter,

Please review samples\LongName.prg
regards, saludos

Antonio Linares
www.fivetechsoft.com
Peterg
Posts: 62
Joined: Mon Nov 28, 2005 5:36 pm
Location: Oxford UK
Contact:

Post by Peterg »

I have used this but I just get truncated file names

Peter
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Peter,

It looks as a 16 bits limitation. With Harbour and FWH it works ok.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Peterg
Posts: 62
Joined: Mon Nov 28, 2005 5:36 pm
Location: Oxford UK
Contact:

Post by Peterg »

Yes it does work with fwh and gradually moving over to this

thanks
Peter
User avatar
dbSoft
Posts: 16
Joined: Thu Oct 13, 2005 8:31 pm
Location: Greece
Contact:

Post by dbSoft »

REDEFINE GET oGetXls VAR cGetXls ID 102 OF oDlg ;
FONT oFont
REDEFINE BTNBMP ID 106 FILENAME lCUR + "\openXls.bmp" OF oDlg ;
ACTION ( cGetXls := cGetDir32("Select folder") , oGetXls:Refresh() )

Code: Select all

//-------------------------------------------
//  DLGS32.PRG
//-------------------------------------------
// 32 bits common dialogs from 16 bits apps

#include "FiveWin.ch"

#define INIFILE GetWinDir()+"\rundlg32.ini"

static nFilterIndex := 0

//----------------------------------------------------------------------------//

Function cGetFile32(cFileMask, cTitle, nDefaultMask, cInitDir, lSave, nFlags)

   local cSection, cFile
   local nRet

   DEFAULT lSave := .f.

   // On cGetFile() that parameter is a boolean for long filenames

   if nFlags != Nil .and. Valtype(nFlags) != "N"
      nFlags := Nil
   endif

   if !lSave
      cSection := "GetOpenFileName"
   else
      cSection := "GetSaveFileName"
   endif

   if File(INIFILE)
      Ferase(INIFILE)
   endif

   if cFileMask != Nil
      if "|"$cFileMask
         cFileMask := StrTran(cFileMask, " |", "|")
         cFileMask := StrTran(cFileMask, "| ", "|")
         WritePProString( cSection, "lpstrFilter", cFileMask, INIFILE )
      else
         WritePProString( cSection, "lpstrFile", cFileMask, INIFILE )
      endif
   endif

   if cTitle != Nil
      WritePProString( cSection, "lpstrTitle", cTitle, INIFILE )
   endif

   if nDefaultMask != Nil
      WritePProString( cSection, "nFilterIndex", ltrim(Str(nDefaultMask)), INIFILE )
   endif

   if cInitDir != Nil
      WritePProString( cSection, "lpstrInitialDir", cInitDir, INIFILE )
   endif

   if nFlags != Nil
      WritePProString( cSection, "Flags", ltrim(Str(nFlags)), INIFILE )
   endif

   WritePProString( cSection, "hwndOwner", lTrim(Str( GetActiveWindow()) ),;
                    INIFILE )
   if IsWin2000()
     nRet := WinExec( "rundlg32 "+iif( lSave, "2", "1") )
   else
     nRet := 0
   endif
   if nRet > 21 .or. nRet < 0
      StopUntil( {|| GetPvProfString( cSection, "working", "0", INIFILE ) != "1"} )
      /*while GetPvProfString( cSection, "working", "0", INIFILE ) == "1"
         SysRefresh()
      end*/

      cFile        := GetPvProfString( cSection, "lpstrFile", "", INIFILE )
      nFilterIndex := Val(GetPvProfString( cSection, "nFilterIndex", "", INIFILE ))
   else
       cFile := cGetFile(cFileMask, cTitle, nDefaultMask, cInitDir, lSave,, nFlags)
   endif

   Ferase(INIFILE)

return cFile

//----------------------------------------------------------------------------//

Function nGetFilter32()

Return nFilterIndex

//----------------------------------------------------------------------------//

Function cGetDir32(cTitle)

   local cDir
   local nRet

   if File(INIFILE)
      Ferase(INIFILE)
   endif

   if cTitle != Nil
      WritePProString( "GetDirectory", "lpstrTitle", cTitle, INIFILE )
   endif

   WritePProString( "GetDirectory", "hwndOwner", lTrim(Str( GetActiveWindow()) ),;
                    INIFILE )

   nRet := WinExec( "rundlg32 3" )

   if nRet > 21 .or. nRet < 0
      StopUntil( {|| GetPvProfString( "GetDirectory", "working", "0", INIFILE ) != "1"} )
      /*while GetPvProfString( "GetDirectory", "working", "0", INIFILE ) == "1"
         SysRefresh()
      end*/
      cDir := GetPvProfString( "GetDirectory", "lpstrDirectory", "", INIFILE )
   else
      cDir := cGetDir(cTitle)
   endif

   Ferase(INIFILE)

return cDir

//----------------------------------------------------------------------------//

FUNCTION IsWin2000() ; RETURN IsWinNT() .and. GetWinVer()[2] == 95


[quote][/quote]
Mdandrea
Posts: 21
Joined: Wed Nov 23, 2005 12:24 am

Post by Mdandrea »

You could create it with a temp file name using 8.3 convention, and use the movefile api call to move it to a long file name.

Movefile ( "c:\temp\temp.fil" +chr(0) , "c:\folder\long file name.fil" +chr(0))
DLL32 FUNCTION MOVEFILE( cOldName AS LPSTR, cNewName AS LPSTR ) AS BOOL;
PASCAL FROM "MoveFileA" LIB "kernel32.dll"
Peterg
Posts: 62
Joined: Mon Nov 28, 2005 5:36 pm
Location: Oxford UK
Contact:

Post by Peterg »

I have found a tfln on Patrick Mast old pages which works very well. Only needs an extra obj linked in and very simple

Peter
Post Reply