Exemplo n.º 1
0
/**
 * @param ucfolder
 */
BT_BOOL btmtk_ftpc_get_folder_content_ex(const U8 *ucFolderpath, const U8 *ucFilename) {
	bt_ftpc_pullfile_req_struct * req;

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

	// copy it to folder_obj
	if ( BT_FTPC_STATE_CONNECTED== act_client_cntx_p->ftpc_state )
	{
		if( NULL != ucFolderpath && NULL != 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 );
		}

		BT_FTPC_STATE_TRANS(0, BT_FTPC_STATE_GETTING_FOLDER);
		/* send get current folder req */
		/* construct get folder req ilm */
		req = (bt_ftpc_pullfile_req_struct*) CONSTRUCT_LOCAL_PARAM(sizeof(bt_ftpc_pullfile_req_struct),TD_CTRL);
		GOEP_MEMSET( req, 0, sizeof(bt_ftpc_pullfile_req_struct));
		req->goep_conn_id = ftpc_cntx_p->goep_conn_id[0];
		ext_strncpy((S8 *) req->obj_mime_type, "x-obex/folder-listing", GOEP_MAX_MIME_TYPE);

		GOEP_MEMCPY( req->filepath, act_client_cntx_p->folder_obj, ext_ucs2strlen( (const S8 *)act_client_cntx_p->folder_obj) *2);
		req->filepath_len = ext_ucs2strlen( (const S8 *)act_client_cntx_p->folder_obj) *2;

		/* send get folder req */
		bt_ftp_send_msg(MSG_ID_BT_FTPC_PULLFILE_REQ, req ,sizeof(bt_ftpc_pullfile_req_struct));
		
		return TRUE;
	}
	return FALSE;
}
Exemplo n.º 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;
}