// // CXL_UTIL.CPP // // Source file for ArchiveLib 1.0 // // Copyright (c) Greenleaf Software, Inc. 1994 // All Rights Reserved // // CONTENTS // // StripFileName() // StripFileNameVB() // StripPath() // StripPathVB() // // DESCRIPTION // // This file contains a couple of C/VB functions that are used to // mangle file names. They defied ordinary categorization, so they // ended up here. The deal is that they operate on objects of class // ALName, but there is no C/VB translation for ALName. Because of // this, we provide these versions that return native string types. // // REVISION HISTORY // // May 25, 1994 1.0A : First release // // #include "arclib.h" #pragma hdrstop #include "al.h" #include "alcxl.h" // C TRANSLATION FUNCTION // // extern "C" char * StripFileName( char *filename ) // // VB TRANSLATION FUNCTION // // extern "C" long StripFileNameVB( char *filename ) // // ARGUMENTS: // // filename : An ordinary VB or C string that contains a file name. // // RETURNS // // Either a C or VB string type, containing just the path. Note that // the C version of the function copies over your existing string, // whereas the VB version creates a new VB string. // // DESCRIPTION // // This function takes a file name, and strips off any filename and // extension, leaving the drive and path name. These functions are // very handy when it comes to wild card expansion, which is why // they are in ArchiveLib. // // If you want to see how the C++ member functions perform these // amazing feats, see OBJNAME.CPP. // // REVISION HISTORY // // May 22, 1994 1.0A : First release // // // The C translation function. // extern "C" char AL_DLL_FAR * AL_FUNCTION StripFileName( char AL_DLL_FAR *filename ) { ALName temp = filename; temp.StripFileName(); strcpy( filename, temp ); return filename; } #if defined( AL_BUILDING_DLL ) && defined( AL_WINDOWS_GUI ) && !defined( AL_FLAT_MODEL ) // // The VB translation function. // extern "C" long AL_FUNCTION StripFileNameVB( char AL_DLL_FAR *filename ) { ALName temp = filename; char _far *p = temp.StripFileName(); return ALCreateVBString( p, (unsigned short int) _fstrlen( p ) ); } #endif // C TRANSLATION FUNCTION // // extern "C" char * StripPath( char *filename ) // // VB TRANSLATION FUNCTION // // extern "C" long StripPathVB( char *filename ) // // ARGUMENTS: // // filename : An ordinary VB or C string that contains a file name. // // RETURNS // // Either a C or VB string type, with the drive and path stripped, // leaving just a filename and extension. Note that // the C version of the function copies over your existing string, // whereas the VB version creates a new VB string. // // DESCRIPTION // // This function takes a file name, and strips off any path and drive // information, leaving the file and extension. These functions are // very handy when it comes to wild card expansion, which is why // they are in ArchiveLib. // // If you want to see how the C++ member functions perform these // amazing feats, see OBJNAME.CPP. // // REVISION HISTORY // // May 22, 1994 1.0A : First release // // // The C translation function. // extern "C" char AL_DLL_FAR * AL_FUNCTION StripPath( char AL_DLL_FAR *filename ) { ALName temp = filename; temp.StripPath(); strcpy( filename, temp ); return filename; } #if defined( AL_BUILDING_DLL ) && defined( AL_WINDOWS_GUI ) && !defined( AL_FLAT_MODEL ) // // The VB translation function // extern "C" long AL_FUNCTION StripPathVB( char AL_DLL_FAR *filename ) { ALName temp = filename; char _far *p = temp.StripPath(); return ALCreateVBString( p, (unsigned short int) _fstrlen( p ) ); } #endif