BOOL TRecvDlg::EndRecvFile(BOOL manual_suspend) { if (fileObj->hThread) { HANDLE hThread = fileObj->hThread; fileObj->hThread = 0; // 中断の合図 WaitForSingleObject(hThread, INFINITE); ::CloseHandle(hThread); } fileObj->lastTick = fileObj->conInfo->lastTick = ::GetTickCount(); SetTransferButtonText(); int target = ShareMng::GetFileInfoNo(shareInfo, fileObj->fileInfo); FileInfo *fileInfo = fileObj->fileInfo; BOOL isSingleTrans = fileObj->startTick == fileObj->conInfo->startTick; ::closesocket(fileObj->conInfo->sd); delete [] fileObj->recvBuf; delete fileObj->conInfo; fileObj->conInfo = NULL; if (fileObj->status == FS_COMPLETE) { for (int cnt=0; cnt < shareInfo->fileCnt; cnt++) { if (shareInfo->fileInfo[cnt]->IsSelected() && shareInfo->fileInfo[cnt] != fileInfo) { FreeDecodeShareMsgFile(shareInfo, target); return SaveFile(); } } } int ret = manual_suspend ? IDCANCEL : RecvTransEndDlg(fileObj, this).Exec(); if (ret == EXEC_BUTTON || ret == FOLDER_BUTTON && fileObj->isDir && isSingleTrans) { char buf[MAX_BUF]; MakePath(buf, fileObj->saveDir, fileInfo->Fname()); ShellExecuteU8(NULL, NULL, buf, 0, 0, SW_SHOW); } else if (ret == FOLDER_BUTTON) ShellExecuteU8(NULL, NULL, fileObj->saveDir, 0, 0, SW_SHOW); if (ret == IDOK || ret == FOLDER_BUTTON || ret == EXEC_BUTTON) FreeDecodeShareMsgFile(shareInfo, target); SetFileButton(this, FILE_BUTTON, shareInfo); EvSize(SIZE_RESTORED, 0, 0); if (ret == IDRETRY) PostMessage(WM_COMMAND, FILE_BUTTON, 0); return TRUE; }
int TSaveCommonDlg::Exec(void) { modalFlg = TRUE; char fname[MAX_BUF], last_dir[MAX_BUF], buf[MAX_BUF], *ext; // 最終保存ディレクトリが無くなっている場合、少しさかのぼる for (int i=0; i < 5; i++) { if (*cfg->lastSaveDir && GetFileAttributesU8(cfg->lastSaveDir) == 0xffffffff) if (!PathToDir(cfg->lastSaveDir, cfg->lastSaveDir)) break; } strcpy(last_dir, *cfg->lastSaveDir ? cfg->lastSaveDir : "."); while (1) { FileInfo *fileInfo = shareInfo->fileInfo[offset]; MakePath(fname, last_dir, fileInfo->Fname()); // ファイルダイアログ TApp::GetApp()->AddWin(this); BOOL ret = OpenFileDlg(parentWin, OpenFileDlg::NODEREF_SAVE, (LPOFNHOOKPROC)TApp::WinProc).Exec(fname, GetLoadStrU8(IDS_SAVEFILE), GetLoadStrAsFilterU8(IDS_OPENFILEALLFLTR), last_dir); TApp::GetApp()->DelWin(this); hWnd = NULL; if (!ret) return FALSE; // shortcut の場合は、リンク先に飛ぶ if (!isLinkFile && (ext = strrchr(fname, '.')) && stricmp(ext, ".lnk") == 0) { char arg[MAX_BUF]; if (ReadLinkU8(fname, last_dir, arg)) { if ((GetFileAttributesU8(last_dir) & FILE_ATTRIBUTE_DIRECTORY) == 0) GetParentDir(last_dir, last_dir); } continue; } fileInfo = shareInfo->fileInfo[offset]; PathToDir(fname, last_dir); ForcePathToFname(fname, fname); fileInfo->SetSelected(TRUE); // 上書き確認 for (int i=0; i < shareInfo->fileCnt; i++) { if (!shareInfo->fileInfo[i]->IsSelected()) continue; MakePath(buf, last_dir, offset == i ? fname : shareInfo->fileInfo[i]->Fname()); if (GetFileAttributesU8(buf) != 0xffffffff) { ret = parentWin->MessageBoxU8(GetLoadStrU8(IDS_OVERWRITE), GetLoadStrU8(IDS_ATTENTION), MB_OKCANCEL|MB_ICONEXCLAMATION); if (ret != IDOK) { for (int j=0; j < shareInfo->fileCnt; j++) shareInfo->fileInfo[j]->SetSelected(FALSE); } break; } } if (ret) { fileInfo->SetFname(fname); strcpy(cfg->lastSaveDir, last_dir); cfg->WriteRegistry(CFG_GENERAL); return TRUE; } } // not reach }