$include (..\lib\compStch.ext) /* *============================================================================ * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE * * Permission to use for any purpose, modify, copy, and make enhancements * and derivative works of the software is granted if attribution is given to * R.M. Gillmore, dba the ACME Software Deli, as the author * * While the ACME Software Deli does not work for money, there is nonetheless * a significant amount of work involved. The ACME Software Deli maintains the * rights to all code written, though it may be used and distributed as long as * the following conditions are maintained. * * 1. The copyright statement at the top of each code block is maintained in * your distribution. * 2. You do not identify yourself as the ACME Software Deli * 3. Any changes made to the software are sent to the ACME Software Deli *============================================================================ */ changeFileExtensionModule: do; $if not noID declare IDString (*) byte data ( '@(#)changExt.p86 $Author: rmgillmore $ $Date:: 2025-05-04 19:35:39#$:', 0 ); $endif $include (..\lib\comnDefs.ext) $set (chgExtensionImplementation) $include (..\lib\changExt.ext) $include (..\lib\string.ext) $include (..\lib\ptrMath.ext) changeExtension: procedure ( fileNameString, newExtension ) public; declare fileNameString pointer, newExtension pointer; declare dotPtr pointer, dot based dotPtr (*) char, slashPtr pointer; declare extensionDelimiter (*) char data ( '.', 0 ); /* * Look for the last '.' character in the string. If * there is no '.' character, or if it appears BEFORE the * last path delimiter, we need to append one */ dotPtr = strrchr( fileNameString, extensionDelimiter( 0 ) ); slashPtr = strrchr( fileNameString, PATH_DELIM ); if ( ( dotPtr = NULL ) or ( ptdw( normalizePtr( slashPtr ) ) > ptdw( normalizePtr( dotPtr ) ) ) ) then do; call strcat( fileNameString, @extensionDelimiter ); dotPtr = strrchr( fileNameString, extensionDelimiter( 0 ) ); end; /* * The '.' character DEFINITELY exists now, point to the * first character past it, and move the new extension * into that position. It should be noted that the NUL * character is copied also */ call strcpy( @dot( 1 ), newExtension ); end changeExtension; end changeFileExtensionModule;