//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Confidential Trade Secret.
// Copyright 1987-2001 Data Access Corporation, Miami FL, USA
// All Rights reserved
// DataFlex is a registered trademark of Data Access Corporation.
//
// Module:
//      PathFindExtension.Pkg
//
// Purpose:
//      Defines interface to WinAPI function PathFindExtension.
//
// Author:
//      Vincent Oorsprong
//
// Date:
//      2001, May, 26th
//
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#IFNDEF GET_PathFindExtension
External_Function WinAPI_PathFindExtension "PathFindExtensionA" SHLWAPI.DLL Pointer lpszPath Returns Pointer

//=============================================================================
// Searches a path for a file extension.
//
// Returns the extension of the filename in the passed path
//    Example:
//       In: c:\vdf7\bin\dfrun.exe
//       Out: .exe
//
// Parameters:
//      sPath - Path that contains the extension for which to search.
//=============================================================================
Function PathFindExtension Desktop String sPath Returns String
    String sRetVal
    Pointer pExtension pPath
    
    Move (sPath - Character (0)) To sPath
    GetAddress Of sPath To pPath
    Move (WinAPI_PathFindExtension (pPath)) To pExtension
    Move (pExtension - pPath) To pPath
    Move (Right (sPath, Length (sPath) - pPath)) To sRetVal
    
    Function_Return (Trim (CString (sRetVal)))
End_Function // PathFindExtension
#ENDIF