/** * @brief change remote path to local path, store it in path * * @see * @note * path: ../test/.DS_Store * req_path: ../test * local_path: ../output2/ * if (dst_path_exist) * path output: ../output2/test/.DS_Store * else * path output: ../output2/.DS_Store * @author auxten <*****@*****.**> * @date 2011-8-1 **/ int change_to_local_path(char * path, const char * req_path, const char * local_path, char dst_path_exist) { if (!path || !req_path || !local_path) { GKOLOG(FATAL, "%s %s passed NULL p", __FILE__, __func__); return -1; } char base_name[MAX_PATH_LEN] = "\0"; char tmp_req_path[MAX_PATH_LEN] = "\0"; strncpy(tmp_req_path, req_path, MAX_PATH_LEN); /// ../test ///printf("tmp2: %s", tmp2); inplace_strip_tailing_slash(tmp_req_path); /// ../test ///printf("tmp2: %s", tmp2); int d; if (dst_path_exist) { d = get_base_name_index(NULL, tmp_req_path); } else { d = strlen(tmp_req_path) + 1; } if (d < 0) { GKOLOG(FATAL, FLF("change_to_local_path failed")); return -1; } ///printf("d: %d,path+d: %s", d, tmp2+d); strncpy(base_name, path + d, MAX_PATH_LEN); /// test/.DS_Store merge_path(path, local_path, base_name); /// ../output2/ + test/.DS_Store inplace_strip_tailing_slash(path); /// ../test return 0; }
//to calculate the similarity of miRNA MatrixXd process::cal_Sim(const MatrixXd & MD, const MatrixXd& DD, const int& iter_num, const double& b) { int miRNA_num = MD.rows(); MatrixXd out = MatrixXd::Zero(miRNA_num,miRNA_num); double out_sum = 0; for (int i=0; i<=iter_num; i++) { MatrixXd out_temp = merge_path(MD,DD,i); double d_temp = pow(b,i); out += d_temp * out_temp; out_sum += d_temp; } out = out * (1/out_sum); MatrixXd sim = MatrixXd::Zero(miRNA_num,miRNA_num); for (int i=0; i!=miRNA_num; i++) { for (int j=0; j!=miRNA_num; j++) { sim(i,j) = 2*out(i,j)/(out(i,i)+out(j,j)); } } return sim; }
static HRESULT download_url(InstallEngine *This, char *id, char *display, char *url, DWORD flags, DWORD dl_size) { struct downloadcb *callback = NULL; char *filename = NULL; IUnknown *unk = NULL; IMoniker *mon = NULL; IBindCtx *bindctx = NULL; HANDLE event = NULL; HRESULT hr; if (!This->downloaddir) { WARN("No download directory set\n"); return E_FAIL; } hr = generate_moniker(This->baseurl, url, flags, &mon); if (FAILED(hr)) { FIXME("Failed to create moniker\n"); return hr; } event = CreateEventW(NULL, TRUE, FALSE, NULL); if (!event) { IMoniker_Release(mon); return E_FAIL; } filename = strrchr(url, '/'); if (!filename) filename = url; filename = merge_path(This->downloaddir, filename); if (!filename) { hr = E_OUTOFMEMORY; goto error; } hr = downloadcb_create(This, event, filename, id, display, dl_size, &callback); if (FAILED(hr)) goto error; hr = CreateAsyncBindCtx(0, &callback->IBindStatusCallback_iface, NULL, &bindctx); if(FAILED(hr)) goto error; hr = IMoniker_BindToStorage(mon, bindctx, NULL, &IID_IUnknown, (void**)&unk); if (FAILED(hr)) goto error; if (unk) IUnknown_Release(unk); heap_free(filename); IMoniker_Release(mon); IBindCtx_Release(bindctx); WaitForSingleObject(event, INFINITE); hr = callback->hr; CloseHandle(event); IBindStatusCallback_Release(&callback->IBindStatusCallback_iface); return hr; error: if (mon) IMoniker_Release(mon); if (event) CloseHandle(event); if (callback) IBindStatusCallback_Release(&callback->IBindStatusCallback_iface); if (bindctx) IBindCtx_Release(bindctx); if (filename) heap_free(filename); return hr; }