コード例 #1
0
/**
* @param ucfolder
*/
BT_BOOL btmtk_ftpc_get_folder_content(const U8 *ucFolderpath, const U8 *ucFilename) {

    char debug[256];

    if (NULL == act_client_cntx_p) {
	return FALSE;
    }

    // copy it to folder_obj
    if (BT_FTPC_STATE_CONNECTED == act_client_cntx_p->ftpc_state) {
	// check folder path
	if ((U32) (ext_ucs2strlen((S8 *) ucFolderpath) + ext_ucs2strlen((S8 *)ucFilename))+1 > (sizeof(act_client_cntx_p->folder_obj)/2)) {
	    //GOEP_TRACE( (BT_FTP_TRC_CLASS, BT_FTPC_TARGET_FOLDERPATH_NO_RESOURCE) );
	    // not be able to save in right place
	    GOEP_Report("[FTPC] get_folder_content no resource for filepath");
	    return FALSE;
	}
		
	if (NULL != ucFolderpath && NULL != ucFilename) {
	    GOEP_TRACE_PATH(BT_FTP_TRC_CLASS, BT_FTPC_TARGET_FOLDERPATH, ucFolderpath);
	    GOEP_TRACE_PATH(BT_FTP_TRC_CLASS, BT_FTPC_TARGET_FILENAME, ucFilename);

	    btmtk_goep_compose_filepath((const U8 *) ucFolderpath,
		    (const U8 *) ucFilename,
		    act_client_cntx_p->folder_obj,
		    sizeof(act_client_cntx_p->folder_obj)/2);

	    GOEP_TRACE_PATH(BT_FTP_TRC_CLASS, BT_FTPC_TARGET_FILEPATH, act_client_cntx_p->folder_obj);

	} else if (NULL == ucFolderpath && NULL == ucFilename) {
	    // Use default folder object path.
	    ext_ucs2_str_n_to_asc_str(debug,
		    (S8 *) act_client_cntx_p->folder_obj,
		    sizeof(act_client_cntx_p->folder_obj)/2);
	} else {
	    btmtk_goep_compose_filepath((const U8 *) ucFolderpath,
		    (const U8 *) ucFilename,
		    act_client_cntx_p->folder_obj,
		    sizeof(act_client_cntx_p->folder_obj)/2);

	    GOEP_TRACE_PATH(BT_FTP_TRC_CLASS, BT_FTPC_TARGET_FILEPATH, act_client_cntx_p->folder_obj);
	}

	return bt_ftpc_start_get_folder_content_routine(0);

    } else {
	GOEP_TRACE((BT_FTP_TRC_CLASS,
		BT_FTPC_FILE_STATE_CHECK,
		(act_client_cntx_p)->ftpc_fs_status,
		(act_client_cntx_p)->ftpc_total_len,
		(act_client_cntx_p)->ftpc_push_remain,
		(act_client_cntx_p)->fh_ftpc_push));
    }

    return FALSE;
}
コード例 #2
0
S32 btmtk_goep_fs_findfirst(U8 *ucFolderPath, bt_ftp_find_struct **findstruct, bt_ftp_obj_info_struct *ftp_file_info) {
#ifdef BTMTK_GOEP_USE_WIN32_FS
    char sdir[256];
    char filter[64];
    U32 test_arrtibe;
    struct _wfinddata_t c_file;
    long hFile;
    bt_ftp_find_struct *pfind;

    GOEP_MEMSET((U8 *)ftp_file_info, 0, sizeof(bt_ftp_obj_info_struct) );

    ext_ucs2_str_n_to_asc_str(sdir, ucFolderPath, sizeof(sdir));

    // keep the previous folder path
    g_oldcwd[0] = 0;
    if ( NULL == _wgetcwd( (U16 *)g_oldcwd, sizeof(g_oldcwd)/2 ) ) {
        /// cannot keep the current folder
        GOEP_Report("[FS][ERR] fail to get cwd bufsize:(%d) err:%d!", sizeof(g_oldcwd)/2, GetLastError());
        return EXT_FS_ERR;
    }

    printf( "[fs] getcwd is '%s'\n", g_oldcwd);
    printf( "[fs] fs findfirst '%s' \n", sdir );
    _wchdir( (U16 *) ucFolderPath );


    ext_strncpy (filter, "*.*", 64);
    hFile = _wfindfirst(L"*.*", &c_file);

    if( -1 == hFile ) {
        return EXT_FS_ERR;
    } else {
        //plong = (long * )malloc(sizeof(long));
        pfind = (bt_ftp_find_struct *) malloc( sizeof(bt_ftp_find_struct) );
        *findstruct = pfind;

        if( *findstruct == NULL ) {
            return EXT_FS_ERR;
        }
        ((bt_ftp_find_struct *)*findstruct)->hFile = hFile;

        ext_ucs2ncpy( (S8 *) ftp_file_info->file_name, (const S8 *) c_file.name, sizeof(ftp_file_info->file_name)/2);
        update_win32_file_time(ftp_file_info);
        test_arrtibe = (_A_SUBDIR & c_file.attrib);
        if( _A_SUBDIR == test_arrtibe) {
            ftp_file_info->isFile = FALSE;
        } else {
            ftp_file_info->isFile = TRUE;
        }
        return EXT_FS_OK;
    }
#endif

#ifdef BTMTK_ON_WISE
    U8 *filter;
    S32 hFile;
    S32 len;
    bt_ftp_find_struct *pfind;
    FS_DOSDirEntry dir_entry;
    U8 filename[ BTMTK_EP_MAX_FILENAME_LEN ]; /// output

    //ext_ucs2ncpy (filter, (const U8 *)L"\\*.*", sizeof(filter)/2);
    len = ext_ucs2strlen((const S8*)ucFolderPath)*2 + 10;
    filter = (U8 *) get_ctrl_buffer( len ); // plus L"\\*.*"
    if( NULL == filter ) {
        return EXT_FS_ERR;
    }
    btmtk_os_memset( filter, 0, len);
    ext_ucs2ncpy( (U8 *) filter,  (const U8 *) ucFolderPath , len-2);
    ext_ucs2ncat( (U8 *) filter, (const U8 *) L"\\*.*", len-2);

    ext_ucs2ncpy((S8 *)filename, (const U8 *)L"", (sizeof(filename)/2)-1);

    hFile = (S32) FS_FindFirst(
                (const WCHAR*)filter,
                0,
                0,
                &dir_entry,
                (U16*) filename,
                sizeof(filename) );
    if( NULL == filter ) {
        free_ctrl_buffer(filter);
        filter = NULL;
    }
    if ( hFile >= 0) {
        GOEP_MEMSET((U8 *)ftp_file_info, 0, sizeof(bt_ftp_obj_info_struct) );
        pfind = (bt_ftp_find_struct *) get_ctrl_buffer( sizeof(bt_ftp_find_struct) );
        *findstruct = pfind;
        if( *findstruct == NULL ) {
            FS_FindClose( (FS_HANDLE) hFile );
            return EXT_FS_ERR;
        }
        ((bt_ftp_find_struct *)*findstruct)->hFile = hFile;

        static_convert_DirEntry_to_file_info( &dir_entry, ftp_file_info , filename);

        return EXT_FS_OK;
    } else {
        return EXT_FS_ERR;
    }

#endif

#ifdef BTMTK_ON_LINUX

    int ret;
    int err_num;

    bt_ext_log("[GOEP_FS] btmtk_goep_fs_findfirst(): Linux Version.");

    ext_chset_ucs2_to_utf8_string((U8 *) g_folder_path, sizeof(g_folder_path)-1, ucFolderPath);
    // strncpy(g_folder_path, ucFolderPath, sizeof(g_folder_path));
    bt_ext_log("[GOEP_FS] g_folder_path: %s", g_folder_path);

    g_opened_dir = opendir( g_folder_path);
    if (g_opened_dir == NULL) {
        err_num = errno;
        bt_ext_err("[FS_ERR] opendir() failed. %s", (char*) strerror(err_num));
        return EXT_FS_ERR;
    }

    return static_linux_fill_file_info(ftp_file_info);

#endif

    return EXT_FS_ERR;
}