<filename>rename/4DPlugin-RENAME.cpp
/* --------------------------------------------------------------------------------
 #
 #  4DPlugin-RENAME.cpp
 #	source generated by 4D Plugin Wizard
 #	Project : RENAME
 #	author : miyako
 #	2019/10/14
 #  
 # --------------------------------------------------------------------------------*/

#include "4DPlugin-RENAME.h"

#pragma mark -

void PluginMain(PA_long32 selector, PA_PluginParameters params) {
    
	try
	{
        switch(selector)
        {
			// --- RENAME
            
			case 1 :
				RENAME(params);
				break;

        }

	}
	catch(...)
	{

	}
}

#pragma mark -

void RENAME(PA_PluginParameters params) {

//    sLONG_PTR *pResult = (sLONG_PTR *)params->fResult;
    PackagePtr pParams = (PackagePtr)params->fParameters;
    
    C_TEXT Param1;
    C_TEXT Param2;
    C_LONGINT Param3;
    
    Param1.fromParamAtIndex(pParams, 1);
    Param2.fromParamAtIndex(pParams, 2);
    
#if VERSIONWIN
    Param3.setIntValue(
                       _wrename((const wchar_t *)Param1.getUTF16StringPtr(), (const wchar_t *)Param2.getUTF16StringPtr())
                       );
#else
    CUTF8String oldName, newName;
    Param1.copyPath(&oldName);
    Param2.copyPath(&newName);
    Param3.setIntValue(
                       rename((const char *)oldName.c_str(), (const char *)newName.c_str())
                       );
#endif
    
    Param3.toParamAtIndex(pParams, 3);
}

