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 long to short filenames in TSE v4? [API/DLL]

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


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

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

---

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

---

FORWARD PROC Main()
FORWARD STRING PROC FNStringGetShortFilenameS( STRING s1 )


// --- MAIN --- //

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

<F12> Main()

// --- LIBRARY --- //

// library: string: get: short: filename (filenamemacro=getstsfi.s) 
(author: http://www.semware.com, see macro 'f.s' in 
directory '..\mac') [kn, ni, th, 02-10-2003 19:41:35]
#IF WIN32
DLL "<kernel32.dll>"
 INTEGER PROC GetShortPathName( STRING lpszLongPath : cstrval, VAR 
STRING lpszShortPath : strptr, INTEGER cchBuffer : 
long ): "GetShortPathNameA"
END
#ENDIF
//
STRING PROC FNStringGetShortFilenameS( STRING lpszLongPath )
 // e.g. PROC Main()
 // e.g.  STRING longfilenameS[255] = "c:\autoexec.bat.nb" // make 
sure this file exists on your computer
 // e.g.  Warn( FNStringGetShortFilenameS( longfilenameS ) )
 // e.g. END
 // e.g.
 // e.g. <F12> Main()
 #IFDEF WIN32
  INTEGER h
  INTEGER lengthI
  STRING lpszShortPath[_MAXPATH_] = Format( "":_MAXPATH_:CHR( 0 ) )
  h = IIF( FileExists( lpszLongPath ), -1, Fcreate( lpszLongPath ) )
  lengthI = GetShortPathName( lpszLongPath, lpszShortPath, _MAXPATH_ )
  IF h <> -1
   Fclose( h )
   EraseDiskFile( lpszLongPath )
  ENDIF
  RETURN( IIF( lengthI > 0, lpszShortPath[1:Pos( CHR( 0 ), 
lpszShortPath ) - 1], lpszLongPath ) )
 #ELSE
  Warn( "use 4DOS / 4NT and @SFN, 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 short filenames to 
long filenames in TSE v4.x?
http://www.faqts.com/knowledge_base/view.phtml/aid/25065/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

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