faqts : Computers : Programming : Languages : Tse : File : Filename

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

Entry

TSE: Filename: Long: Short: Convert: How convert short to long filenames in TSE v4? [API/DLL]

Oct 2nd, 2003 15:50
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 02 October 2003 - 11:42 pm --------------------

TSE: Filename: Long: Short: Convert: How to convert short filenames to 
long filenames in TSE v4.x?

---

Use e.g. the Windows API 'GetLongPathName':

---

FORWARD PROC Main()
FORWARD STRING PROC FNStringGetLongFilenameS( STRING s1 )


// --- MAIN --- //

PROC Main()
 STRING shortfilenameS[255] = "c:\autoexec.bat" // make sure this file 
exists on your computer
 Warn( FNStringGetLongFilenameS( shortfilenameS ) )
END

<F12> Main()

// --- LIBRARY --- //

// library: string: get: long: filename (filenamemacro=getstsfj.s) 
(adapted from author: http://www.semware.com, see macro 'f.s' in 
directory '..\mac') [kn, ni, fr, 03-10-2003  0:39:17]
DLL "<kernel32.dll>"
 INTEGER PROC GetLongPathName( STRING lpszShortPath : cstrval, VAR 
STRING lpszLongPath : strptr, INTEGER cchBuffer : 
long ): "GetLongPathNameA"
END
//
// STRING PROC FNStringGetLongFilenameS( STRING lpszShortPath )
 // e.g. PROC Main()
 // e.g.  STRING shortfilenameS[255] = "c:\autoexec.bat" // make sure 
this file exists on your computer
 // e.g.  Warn( FNStringGetLongFilenameS( shortfilenameS ) )
 // e.g. END
 // e.g.
 // e.g. <F12> Main()
 #IFDEF WIN32
  INTEGER h
  INTEGER lengthI
  STRING lpszLongPath[_MAXPATH_] = Format( "":_MAXPATH_:CHR( 0 ) )
  h = IIF( FileExists( lpszShortPath ), -1, Fcreate( lpszShortPath ) )
  lengthI = GetLongPathName( lpszShortPath, lpszLongPath, _MAXPATH_ )
  IF h <> -1
   Fclose( h )
   EraseDiskFile( lpszShortPath )
  ENDIF
  RETURN( IIF( lengthI > 0, lpszLongPath[1:Pos( CHR( 0 ), 
lpszLongPath ) - 1], lpszShortPath ) )
 #ELSE
  Warn( "use 4DOS / 4NT and @LFN, to redirect to a file, then read 
first line of this file" )
 #ENDIF
END

---
---

Internet: see also:

4DOS/4NT: What is 4DOS?
http://www.faqts.com/knowledge_base/view.phtml/aid/12731/fid/936

4DOS/4NT: How to convert the path long filename (LFN) to/from short 
filename (SFN), in 4DOS?
http://www.faqts.com/knowledge_base/view.phtml/aid/12700/fid/936

TSE: Filename: Long: Short: Convert: How to convert long filenames to 
short filenames in TSE v4.x?
http://www.faqts.com/knowledge_base/view.phtml/aid/25064/fid/939

TSE: How to convert a long filename (LFN) to a short filename (SFN), 
including path, in TSE for DOS?
http://www.faqts.com/knowledge_base/view.phtml/aid/12707/fid/939

TSE: How to convert a short filename (SFN) to a long filename (LFN), 
including path, in TSE for DOS?
http://www.faqts.com/knowledge_base/view.phtml/aid/12711/fid/939

----------------------------------------------------------------------