Esempio n. 1
0
/*****************************************************************************
 * FUNCTION
 *  bt_goep_gen_folder_recursive
 * DESCRIPTION
 *  This function is to generate receive folder
 * PARAMETERS
 * fldr_path   [IN]
 * RETURNS
 *  S32
 *****************************************************************************/
static S32 bt_goep_gen_folder_recursive(U16 *fldr_path)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    S32 retval = EXT_FS_OK;
    U16 *p1 = NULL, *p2 = NULL, t;

    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/
    //Assert(fldr_path);

    for (p1 = (U16 *)ext_ucs2rchr( (const S8 *)fldr_path, (U16)L'\\'); p1; p1 = (U16 *)ext_ucs2rchr( (const S8 *)p2, (U16)L'\\'))
    {
        p2 = p1 + 1;
        t = *p2;
        *p2 = L'\0';

        retval = btmtk_goep_create_folder( (const U16*) fldr_path);
        *p2 = t;
        if ( EXT_FS_OK != retval )
        {
            return retval;
        }
    }

    return retval;
}
Esempio n. 2
0
FS_STATUS btmtk_goep_get_file_basename(const U8 *filepath, U8 *basename, U32 u4MaxSize){
    S8 *pDelimitor;
    if( NULL == filepath ||  0 == ext_ucs2strlen((const S8*)filepath) ){
        return EXT_FS_ERR;
    }
    pDelimitor = ext_ucs2rchr((const S8 *)filepath, (U16)0x005c); // "\\" 0x5c
    if( NULL != pDelimitor ){
        ext_ucs2ncpy((S8 *)basename, (const S8 *)pDelimitor+2, u4MaxSize); // skip the delimitor
    }else{
		pDelimitor = ext_ucs2rchr((const S8 *)filepath, (U16) 0x002f); // "\\" 0x5c
		if( NULL != pDelimitor ){
			ext_ucs2ncpy((S8 *)basename, (const S8 *)pDelimitor+2, u4MaxSize); // skip the delimitor
		}else{
			GOEP_Report("[goep][warn] func:get_file_basename cannot find basename\n");
	        return EXT_FS_ERR;
		}
    }
    return     EXT_FS_OK;
}
Esempio n. 3
0
/**
* @brief This function is to truncate object name if exceeds max buffer size
* PARAMETERS
* new_name    [OUT]
* old_name    [IN]
* max_len     [IN]
**/
void bt_goep_truncate_ntoh_filename(U16 *dst_name, const U16 *src_netname, U16 max_dst_len)
{
    /*----------------------------------------------------------------*/
    /* Local Variables                                                */
    /*----------------------------------------------------------------*/
    U32 src_name_len;
    U16 *p_ext, *p1;
    U32 ext_len;
    U16 copy_len;
    S8 l_wave[8];
    if( 0 == max_dst_len ){
        GOEP_ASSERT(0);
    }
    
    /*----------------------------------------------------------------*/
    /* Code Body                                                      */
    /*----------------------------------------------------------------*/

    src_name_len = ext_ucs2strlen((const S8*)src_netname);

    // max_dst_len /= ENCODING_LENGTH;
    max_dst_len /= 2; //TODO unicode is 2 byte
     
    if (src_name_len < max_dst_len)
    {
        /* need not truncate */
        ext_ucs2ncpy((S8 *)dst_name, (S8 *) src_netname, max_dst_len);

        p1 = dst_name;
        for(; *p1; p1++)
        {
            *p1 = bt_goep_ntohs(*p1);
        }
        *p1 = (U16)'\0';

    }
    else
    {
        /* need truncate */
        GOEP_MEMSET( (U8*) dst_name, 0, max_dst_len * 2 ); //* ENCODING_LENGTH);
        
        /* find filename ext */
        p_ext = (U16 *)ext_ucs2rchr((const S8 *)(S8 *)src_netname, (U16)(L'.'));
        
        if(p_ext)
        {
            ext_len = ext_ucs2strlen((const S8*)p_ext);
        }
        else
        {
            ext_len = 0;
        }
        
        /* 1 char for '~'; 1 char for \0 */
        copy_len = (U16) (max_dst_len - ext_len - 1 - 1 );
        ext_ucs2ncpy((S8 *) l_wave, (const S8*) L"-", 8);
        p1 = (U16 *)l_wave;
        for(; *p1; p1++)
        {
            *p1 = bt_goep_ntohs(*p1);
        }
        
        
        ext_ucs2ncpy((S8 *)dst_name, (const S8 *)src_netname, copy_len);
        ext_ucs2ncat((S8 *)dst_name, (const S8 *)l_wave, max_dst_len);
        if (p_ext)
        {
            ext_ucs2ncat((S8 *)dst_name, (const S8 *)p_ext, max_dst_len);
        }
        
        p1 = dst_name;
        for(; *p1; p1++)
        {
            *p1 = bt_goep_ntohs(*p1);
        }
        *p1 = (U16)'\0';
        
    }
    
}