//--------------------------------------------------------------------------- bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString & Target, UnicodeString & FileMask, bool & DirectCopy) { FCurrentSession = -1; for (int Index = 0; Index < SessionCombo->Items->Count; Index++) { if (SessionCombo->Items->Objects[Index] == Session) { FCurrentSession = Index; SessionCombo->ItemIndex = Index; break; } } assert(FCurrentSession >= 0); DirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteTarget"]; DirectoryEdit->Text = UnixIncludeTrailingBackslash(Target) + FileMask; FDirectCopy = DirectCopy; NotDirectCopyCheck->Checked = !DirectCopy; bool Result = (ShowModal() == DefaultResult(this)); if (Result) { Session = SessionCombo->Items->Objects[SessionCombo->ItemIndex]; CustomWinConfiguration->History[L"RemoteTarget"] = DirectoryEdit->Items; Target = UnixExtractFilePath(DirectoryEdit->Text); FileMask = UnixExtractFileName(DirectoryEdit->Text); DirectCopy = !NotDirectCopyCheck->Checked; } return Result; }
//--------------------------------------------------------------------------- void __fastcall TRemoteTransferDialog::SessionComboChange(TObject * /*Sender*/) { DirectoryEdit->Text = UnixIncludeTrailingBackslash(FDirectories->Strings[SessionCombo->ItemIndex]) + UnixExtractFileName(DirectoryEdit->Text); if (SessionCombo->ItemIndex == FCurrentSession) { NotDirectCopyCheck->Checked = !FDirectCopy; } else { NotDirectCopyCheck->Checked = true; } UpdateControls(); }
//--------------------------------------------------------------------------- void __fastcall TFileOperationProgressType::SetFile(UnicodeString AFileName, bool AFileInProgress) { FullFileName = AFileName; if (Side == osRemote) { // historically set were passing filename-only for remote site operations, // now we need to collect a full paths, so we pass in full path, // but still want to have filename-only in FileName AFileName = UnixExtractFileName(AFileName); } FileName = AFileName; FileInProgress = AFileInProgress; ClearTransfer(); FFileStartTime = Now(); DoProgress(); }
//--------------------------------------------------------------------------- IShellLink * __fastcall CreateDesktopSessionShortCut( const UnicodeString & SessionName, UnicodeString Name, const UnicodeString & AdditionalParams, int SpecialFolder, int IconIndex, bool Return) { bool DefaultsOnly; UnicodeString InfoTip; bool IsFolder = StoredSessions->IsFolder(SessionName); bool IsWorkspace = StoredSessions->IsWorkspace(SessionName); if (IsFolder || IsWorkspace) { InfoTip = FMTLOAD( (IsFolder ? SHORTCUT_INFO_TIP_FOLDER : SHORTCUT_INFO_TIP_WORKSPACE), (SessionName)); if (Name.IsEmpty()) { // no slashes in filename Name = UnixExtractFileName(SessionName); } } else { TSessionData * SessionData = StoredSessions->ParseUrl(SessionName, NULL, DefaultsOnly); InfoTip = FMTLOAD(SHORTCUT_INFO_TIP, (SessionName, SessionData->InfoTip)); if (Name.IsEmpty()) { // no slashes in filename Name = SessionData->LocalName; } delete SessionData; } return CreateDesktopShortCut(ValidLocalFileName(Name), Application->ExeName, FORMAT(L"\"%s\"%s%s", (SessionName, (AdditionalParams.IsEmpty() ? L"" : L" "), AdditionalParams)), InfoTip, SpecialFolder, IconIndex, Return); }
//--------------------------------------------------------------------------- bool TFileMasks::Matches(const UnicodeString & FileName, bool Local, bool Directory, const TParams * Params, bool & ImplicitMatch) const { bool Result; if (Local) { UnicodeString Path = ExtractFilePath(FileName); if (!Path.IsEmpty()) { Path = ToUnixPath(ExcludeTrailingBackslash(Path)); } Result = Matches(ExtractFileName(FileName, false), Directory, Path, Params, ImplicitMatch); } else { Result = Matches(UnixExtractFileName(FileName), Directory, UnixExcludeTrailingBackslash(::UnixExtractFilePath(FileName)), Params, ImplicitMatch); } return Result; }
//--------------------------------------------------------------------------- bool TFileMasks::MatchesMasks(const UnicodeString & FileName, bool Directory, const UnicodeString & Path, const TParams * Params, const TMasks & Masks, bool Recurse) { bool Result = false; TMasks::const_iterator it = Masks.begin(); while (!Result && (it != Masks.end())) { const TMask & Mask = *it; Result = MatchesMaskMask(Mask.DirectoryMask, Path) && MatchesMaskMask(Mask.FileNameMask, FileName); if (Result) { bool HasSize = (Params != nullptr); switch (Mask.HighSizeMask) { case TMask::None: Result = true; break; case TMask::Open: Result = HasSize && (Params->Size < Mask.HighSize); break; case TMask::Close: Result = HasSize && (Params->Size <= Mask.HighSize); break; } if (Result) { switch (Mask.LowSizeMask) { case TMask::None: Result = true; break; case TMask::Open: Result = HasSize && (Params->Size > Mask.LowSize); break; case TMask::Close: Result = HasSize && (Params->Size >= Mask.LowSize); //-V595 break; } } bool HasModification = (Params != nullptr); if (Result) { switch (Mask.HighModificationMask) { case TMask::None: Result = true; break; case TMask::Open: Result = HasModification && (Params->Modification < Mask.HighModification); break; case TMask::Close: Result = HasModification && (Params->Modification <= Mask.HighModification); break; } } if (Result) { switch (Mask.LowModificationMask) { case TMask::None: Result = true; break; case TMask::Open: Result = HasModification && (Params->Modification > Mask.LowModification); break; case TMask::Close: Result = HasModification && (Params->Modification >= Mask.LowModification); break; } } } ++it; } if (!Result && Directory && !IsUnixRootPath(Path) && Recurse) { UnicodeString ParentFileName = UnixExtractFileName(Path); UnicodeString ParentPath = UnixExcludeTrailingBackslash(::UnixExtractFilePath(Path)); // Pass Params down or not? // Currently it includes Size/Time only, what is not used for directories. // So it depends of future use. Possibly we should make a copy // and pass on only relevant fields. Result = MatchesMasks(ParentFileName, true, ParentPath, Params, Masks, Recurse); } return Result; }
//--------------------------------------------------------------------------- void __fastcall TCopyDialog::AdjustTransferControls() { if (FFileList && FFileList->Count) { if (!FToRemote && !FMove && FLAGSET(FOutputOptions, cooRemoteTransfer)) { UnicodeString Label; if (FFileList->Count == 1) { UnicodeString FileName; if (!FToRemote) FileName = UnixExtractFileName(FFileList->Strings[0]); else FileName = ExtractFileName(FFileList->Strings[0]); Label = FMTLOAD(REMOTE_COPY_FILE, (FileName)); } else { Label = FMTLOAD(REMOTE_COPY_FILES, (FFileList->Count)); } DirectoryLabel->Caption = Label; } else { UnicodeString TransferStr = LoadStr(RemotePaths() ? COPY_COPY_TOREMOTE : COPY_COPY_TOLOCAL); // currently the copy dialog is shown when downloading to temp folder // only for drag&drop downloads, for we dare to display d&d specific prompt UnicodeString DirectionStr = LoadStr(((FOptions & coTemp) != 0) ? COPY_TODROP : (RemotePaths() ? COPY_TOREMOTE : COPY_TOLOCAL)); if (FFileList->Count == 1) { UnicodeString FileName; if (!FToRemote) FileName = UnixExtractFileName(FFileList->Strings[0]); else FileName = ExtractFileName(FFileList->Strings[0]); DirectoryLabel->Caption = FMTLOAD((FMove ? MOVE_FILE : COPY_FILE), (TransferStr, FileName, DirectionStr)); } else { DirectoryLabel->Caption = FMTLOAD((FMove ? MOVE_FILES : COPY_FILES), (TransferStr, FFileList->Count, DirectionStr)); } } } TImage * Image; if (!FMove) { if (!FToRemote && FLAGSET(FOutputOptions, cooRemoteTransfer)) { Caption = LoadStr(REMOTE_COPY_TITLE); Image = CopyImage; } else { if (RemotePaths()) { Caption = LoadStr(COPY_COPY_TOREMOTE_CAPTION); Image = CopyUploadImage; } else { Caption = LoadStr(COPY_COPY_TOLOCAL_CAPTION); Image = CopyDownloadImage; } } } else { if (!FToRemote && FLAGSET(FOutputOptions, cooRemoteTransfer)) { Caption = LoadStr(COPY_MOVE_CAPTION); Image = MoveImage; } else { if (RemotePaths()) { Caption = LoadStr(COPY_MOVE_TOREMOTE_CAPTION); Image = MoveUploadImage; } else { Caption = LoadStr(COPY_MOVE_TOLOCAL_CAPTION); Image = MoveDownloadImage; } } } CopyImage->Visible = (Image == CopyImage) || (Image == NULL); MoveImage->Visible = (Image == MoveImage); CopyUploadImage->Visible = (Image == CopyUploadImage); CopyDownloadImage->Visible = (Image == CopyDownloadImage); MoveUploadImage->Visible = (Image == MoveUploadImage); MoveDownloadImage->Visible = (Image == MoveDownloadImage); bool RemoteTransfer = FLAGSET(FOutputOptions, cooRemoteTransfer); assert(FLAGSET(FOptions, coAllowRemoteTransfer) || !RemoteTransfer); EnableControl(TransferSettingsButton, !RemoteTransfer); EnableControl(CopyParamGroup, !RemoteTransfer); }