diff options
Diffstat (limited to 'UCoreWorkers.pas')
| -rw-r--r-- | UCoreWorkers.pas | 298 |
1 files changed, 177 insertions, 121 deletions
diff --git a/UCoreWorkers.pas b/UCoreWorkers.pas index 3fb394a..00b0672 100644 --- a/UCoreWorkers.pas +++ b/UCoreWorkers.pas @@ -85,8 +85,8 @@ type TVFSCallbackThread = class(TThread) // Dialogs FCancelMessage: string; FShowCancelMessage, - FDialogShowDirDelete, FDialogShowOverwrite, FDialogShowNewDir, FDialogShowMsgBox: boolean; - FDialogResultDirDelete, FDialogResultOverwrite, FDialogResultNewDir: integer; + FDialogShowDirDelete, FDialogShowOverwrite, FDialogShowNewDir, FDialogShowMsgBox, FDialogShowInaccessible: boolean; + FDialogResultDirDelete, FDialogResultOverwrite, FDialogResultNewDir, FDialogResultInaccessible: integer; FProgress1Pos, FProgress2Pos, FProgress1Max, FProgress2Max: Int64; FProgress1Text, FProgress2Text, FLabel1Text, FLabel2Text: string; @@ -102,6 +102,8 @@ type TVFSCallbackThread = class(TThread) FOverwriteSourceItem, FOverwriteDestItem: PDataItem; FOverwriteSourceFile, FOverwriteDestFile, FOverwriteRenameStr: string; + FInaccessiblePaths: TStringList; + FNewDirCaption, FNewDirLabel, FNewDirEdit: string; FMsgBoxText: string; @@ -117,6 +119,7 @@ type TVFSCallbackThread = class(TThread) procedure UpdateCaption2(const CaptionText: string); function ShowDirDeleteDialog(ButtonsType: TFDirDeleteButtonSet; const Title, FileName: string; Error: PGError): integer; function ShowOverwriteDialog(ShowAppend: boolean; SourceItem, DestItem: PDataItem; const SourceFile, DestFile: string; var RenameStr: string): integer; + function ShowInaccessibleDialog(InaccessiblePaths: TStringList): integer; function ShowNewDirDialog(Caption, LabelCaption, Edit: string): integer; function ShowMessageBox(const Text: string; Buttons: TMessageButtons; Style: TMessageStyle; Default, Escape: TMessageButton): TMessageButton; @@ -167,7 +170,7 @@ type TVFSCallbackThread = class(TThread) constructor Create; destructor Destroy; override; - procedure PrepareJobFilesFromPanel(AList: TList; DoNotRecurse: boolean); + procedure PrepareJobFilesFromPanel(AList: TList; InaccessiblePaths: TStringList; DoNotRecurse: boolean); end; @@ -411,6 +414,7 @@ begin FDialogShowOverwrite := False; FDialogShowNewDir := False; FDialogShowMsgBox := False; + FDialogShowInaccessible := False; ErrorHappened := False; FGUIChanged := False; FCopyProgressFunc := nil; @@ -526,6 +530,16 @@ begin RenameStr := FOverwriteRenameStr; end; +function TWorkerThread.ShowInaccessibleDialog(InaccessiblePaths: TStringList): integer; +begin + FDialogResultInaccessible := 0; + FInaccessiblePaths := InaccessiblePaths; + FDialogShowInaccessible := True; + FCallbackLockEvent.ResetEvent; + FCallbackLockEvent.WaitFor(INFINITE); + Result := FDialogResultInaccessible; +end; + function TWorkerThread.ShowNewDirDialog(Caption, LabelCaption, Edit: string): integer; begin FNewDirCaption := Caption; @@ -552,7 +566,7 @@ end; (********************************************************************************************************************************) -procedure TWorkerThread.PrepareJobFilesFromPanel(AList: TList; DoNotRecurse: boolean); +procedure TWorkerThread.PrepareJobFilesFromPanel(AList: TList; InaccessiblePaths: TStringList; DoNotRecurse: boolean); var i: longint; CurrPath: string; InputFiles: TStringList; @@ -569,7 +583,7 @@ begin if (InputFiles.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then InputFiles.Add(CurrPath + String(SelectedItem^.FName)); - FillDirFiles(AEngine, AList, InputFiles, DoNotRecurse, True); + FillDirFiles(AEngine, AList, InputFiles, DoNotRecurse, True, InaccessiblePaths); InputFiles.Free; end; @@ -737,6 +751,12 @@ begin b := True; end; + if FDialogShowInaccessible then begin + FDialogResultInaccessible := ShowInaccessiblePathsDialog(ParentDialogForm.FWidget, FInaccessiblePaths); + FDialogShowInaccessible := False; + b := True; + end; + if FDialogShowNewDir then begin AFNewDir := nil; try @@ -831,6 +851,7 @@ var SkipAll: boolean; var i: longint; AList: TList; + InaccessiblePaths: TStringList; CurrPath: string; Fr: Single; Response: integer; @@ -838,13 +859,16 @@ var i: longint; begin SkipAll := False; AList := TList.Create; + InaccessiblePaths := TStringList.Create; CurrPath := IncludeTrailingPathDelimiter(AEngine.Path); - PrepareJobFilesFromPanel(AList, False); + PrepareJobFilesFromPanel(AList, InaccessiblePaths, False); // * TODO: catch the error if not AEngine.ChangeDir(CurrPath, nil) then DebugMsg(['*** WARNING: Cannot change to the origin location, strange behaviour might occur.']); libc_chdir('/'); + // * TODO: show warning about inaccessible paths before deletion starts? + SetProgress1Params(AList.Count); CommitGUIUpdate; DeleteAll := False; @@ -889,6 +913,7 @@ begin for i := AList.Count - 1 downto 0 do FreeDataItem(PDataItemSL(AList[i])); AList.Clear; AList.Free; + InaccessiblePaths.Free; // * TODO: catch the error if not AEngine.ChangeDir(CurrPath, nil) then DebugMsg(['*** WARNING: Cannot change to the origin location, strange behaviour might occur.']); @@ -1363,7 +1388,7 @@ var DefResponse: integer; // Global variables for this function // Can be called only once, otherwise sorting will fail and extract errors may appear // TODO: make this universal // TODO: this is complete mess, make it more clear - procedure HandleProcessPattern(AList: TList; CurrPath, FullPath, ParamFileName: string; ParamDir, Ren: boolean); + procedure HandleProcessPattern(AList: TList; InaccessiblePaths: TStringList; CurrPath, FullPath, ParamFileName: string; ParamDir, Ren: boolean); var s, s2: string; b, CaseInsensitiveRename: boolean; Info: PDataItemSL; @@ -1390,7 +1415,9 @@ var DefResponse: integer; // Global variables for this function then begin Info := GetFileInfoSL(SrcEngine, FullPath); if Info = nil then begin + InaccessiblePaths.Add(FullPath); DebugMsg(['$$$ Copy: Something went wrong while building the filelist...']); + // TODO: ? ErrorHappened := True; end else begin Info^.ADestination := strdup(PChar(s)); @@ -1399,17 +1426,19 @@ var DefResponse: integer; // Global variables for this function end; end else InputFiles.Add(FullPath); end; - FillDirFiles(SrcEngine, AList, InputFiles, False, True); + FillDirFiles(SrcEngine, AList, InputFiles, False, True, InaccessiblePaths); InputFiles.Free; end; var i: longint; List: TList; + InaccessiblePaths: TStringList; CurrPath, SaveDestPath, SaveSrcPath, s: string; StartPassed: boolean; + SkipInaccessible: boolean; begin List := TList.Create; - List.Clear; + InaccessiblePaths := TStringList.Create; ErrorHappened := False; SaveSrcPath := ''; CurrPath := IncludeTrailingPathDelimiter(SrcEngine.Path); @@ -1419,36 +1448,36 @@ begin // Prepare list of files to copy if JobType = WORKER_JOB_EXTRACT_TO_TEMP then begin - if not ExtractFromVFSAll then HandleProcessPattern(List, CurrPath, ExtractFile, ExtractFileName(ExtractFile), False, False) + if not ExtractFromVFSAll then HandleProcessPattern(List, InaccessiblePaths, CurrPath, ExtractFile, ExtractFileName(ExtractFile), False, False) else begin SaveSrcPath := IncludeTrailingPathDelimiter(SrcEngine.Path); SrcEngine.SetPath('/'); CurrPath := '/'; - HandleProcessPattern(List, '/', '/', '', True, False); + HandleProcessPattern(List, InaccessiblePaths, '/', '/', '', True, False); end; end else if QuickRenameDataItem <> nil then begin // Quick-Rename with QuickRenameDataItem^ do - HandleProcessPattern(List, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), True); + HandleProcessPattern(List, InaccessiblePaths, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), True); end else begin // Not Quick-Rename if JobType <> WORKER_JOB_EXTRACT_TO_TEMP then begin if DataList.Count > 0 then for i := 0 to DataList.Count - 1 do with PDataItem(DataList[i])^ do if (not UpDir) and Selected - then HandleProcessPattern(List, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), JobType = WORKER_JOB_MOVE); + then HandleProcessPattern(List, InaccessiblePaths, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), JobType = WORKER_JOB_MOVE); if (List.Count = 0) and Assigned(SelectedItem) and (not SelectedItem^.UpDir) then with SelectedItem^ do - HandleProcessPattern(List, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), JobType = WORKER_JOB_MOVE); + HandleProcessPattern(List, InaccessiblePaths, CurrPath, CurrPath + String(FName), String(FName), IsDir and (not IsLnk), JobType = WORKER_JOB_MOVE); end else begin // Extract from VFS mode DebugMsg(['CopyFilesWorker: Should not be reached']); if (not ExtractFromVFSAll) and Assigned(SelectedItem) - then HandleProcessPattern(List, CurrPath, CurrPath + String(SelectedItem^.FName), String(SelectedItem^.FName), SelectedItem^.IsDir and (not SelectedItem^.IsLnk), JobType = WORKER_JOB_MOVE) + then HandleProcessPattern(List, InaccessiblePaths, CurrPath, CurrPath + String(SelectedItem^.FName), String(SelectedItem^.FName), SelectedItem^.IsDir and (not SelectedItem^.IsLnk), JobType = WORKER_JOB_MOVE) else begin SaveSrcPath := IncludeTrailingPathDelimiter(SrcEngine.Path); SrcEngine.SetPath('/'); CurrPath := '/'; - HandleProcessPattern(List, '/', '/', '', True, False); + HandleProcessPattern(List, InaccessiblePaths, '/', '/', '', True, False); end; end; end; @@ -1457,79 +1486,85 @@ begin if SrcEngine.ChangeDir(CurrPath) <> 0 then DebugMsg(['*** WARNING: Cannot change to the origin location, strange behaviour may occur.']); } DebugWriteListSL(List); - __chdir('/'); - // Compute total size of files to copy - FTotalSize := 0; - FTotalDone := 0; - if List.Count > 0 then - for i := 0 to List.Count - 1 do - if PDataItemSL(List[i])^.Stage1 and (PDataItemSL(List[i])^.DataItem^.Size > 0) and (not PDataItemSL(List[i])^.DataItem^.IsDir) and (not PDataItemSL(List[i])^.DataItem^.IsLnk) - then Inc(FTotalSize, PDataItemSL(List[i])^.DataItem^.Size); - SrcEngine.BlockSize := ComputeBlockSize(FTotalSize); - DestEngine.BlockSize := ComputeBlockSize(FTotalSize); - - // Prepare the Progress window - SetProgress2Params(FTotalSize + Ord(FTotalSize = 0)); - UpdateProgress1(0, '0%'); - UpdateProgress2(0, '0%'); - CommitGUIUpdate; - - DefResponse := 0; - SkipAll := False; - FCopySkipAllErrors := False; + SkipInaccessible := False; + if InaccessiblePaths.Count > 0 then + SkipInaccessible := ShowInaccessibleDialog(InaccessiblePaths) <> 1; + + if not SkipInaccessible then begin + __chdir('/'); + // Compute total size of files to copy + FTotalSize := 0; + FTotalDone := 0; + if List.Count > 0 then + for i := 0 to List.Count - 1 do + if PDataItemSL(List[i])^.Stage1 and (PDataItemSL(List[i])^.DataItem^.Size > 0) and (not PDataItemSL(List[i])^.DataItem^.IsDir) and (not PDataItemSL(List[i])^.DataItem^.IsLnk) + then Inc(FTotalSize, PDataItemSL(List[i])^.DataItem^.Size); + SrcEngine.BlockSize := ComputeBlockSize(FTotalSize); + DestEngine.BlockSize := ComputeBlockSize(FTotalSize); + + // Prepare the Progress window + SetProgress2Params(FTotalSize + Ord(FTotalSize = 0)); + UpdateProgress1(0, '0%'); + UpdateProgress2(0, '0%'); + CommitGUIUpdate; - if List.Count > 0 then begin - StartPassed := True; - if SrcEngine is TVFSEngine then - StartPassed := StartPassed and (SrcEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); - if DestEngine is TVFSEngine then - StartPassed := StartPassed and (DestEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); - - if StartPassed then - for i := 0 to List.Count - 1 do begin - if Assigned(PDataItemSL(List[i])^.ADestination) - then s := string(PDataItemSL(List[i])^.ADestination) - else - begin - s := ProcessPattern(DestEngine, CopyTargetPath, CurrPath, Copy(PDataItemSL(List[i])^.DataItem^.FName, Length(CurrPath) + 1, Length(PDataItemSL(List[i])^.DataItem^.FName) - Length(CurrPath)), - PDataItemSL(List[i])^.DataItem^.IsDir and (not PDataItemSL(List[i])^.DataItem^.IsLnk)); -// DebugMsg(['s2 = ', Copy(PDataItemSL(List[i])^.AName, Length(CurrPath) + 1, Length(PDataItemSL(List[i])^.AName) - Length(CurrPath)), ', s = ', s]); - end; + DefResponse := 0; + SkipAll := False; + FCopySkipAllErrors := False; + + if List.Count > 0 then begin + StartPassed := True; + if SrcEngine is TVFSEngine then + StartPassed := StartPassed and (SrcEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); + if DestEngine is TVFSEngine then + StartPassed := StartPassed and (DestEngine as TVFSEngine).StartCopyOperation(@vfs_ask_question_callback, @vfs_ask_password_callback, @vfs_copy_progress_callback, Self); + + if StartPassed then + for i := 0 to List.Count - 1 do begin + if Assigned(PDataItemSL(List[i])^.ADestination) + then s := string(PDataItemSL(List[i])^.ADestination) + else + begin + s := ProcessPattern(DestEngine, CopyTargetPath, CurrPath, Copy(PDataItemSL(List[i])^.DataItem^.FName, Length(CurrPath) + 1, Length(PDataItemSL(List[i])^.DataItem^.FName) - Length(CurrPath)), + PDataItemSL(List[i])^.DataItem^.IsDir and (not PDataItemSL(List[i])^.DataItem^.IsLnk)); +// DebugMsg(['s2 = ', Copy(PDataItemSL(List[i])^.AName, Length(CurrPath) + 1, Length(PDataItemSL(List[i])^.AName) - Length(CurrPath)), ', s = ', s]); + end; - if not (SrcEngine is TVFSEngine) then UpdateCaption1(Format(LANGFromS, [string(PDataItemSL(List[i])^.DataItem^.FDisplayName)])) else - if (SrcEngine as TVFSEngine).ArchiveMode then UpdateCaption1(Format(LANGFromS, [Format(ConstFullPathFormatStr, [(SrcEngine as TVFSEngine).ArchivePath, string(PDataItemSL(List[i])^.DataItem^.FDisplayName)])])) - else UpdateCaption1(Format(LANGFromS, [GetURIPrefix((SrcEngine as TVFSEngine).GetPathURI) + StrToUTF8(string(PDataItemSL(List[i])^.DataItem^.FDisplayName))])); - if not (DestEngine is TVFSEngine) then UpdateCaption2(Format(LANGToS, [StrToUTF8(s)])) else - if (DestEngine as TVFSEngine).ArchiveMode then UpdateCaption2(Format(LANGToS, [Format(ConstFullPathFormatStr, [(DestEngine as TVFSEngine).ArchivePath, StrToUTF8(s)])])) - else UpdateCaption2(Format(LANGToS, [GetURIPrefix((DestEngine as TVFSEngine).GetPathURI) + StrToUTF8(s)])); - CommitGUIUpdate; - if TwoSameFiles(s, string(PDataItemSL(List[i])^.DataItem^.FName), (JobType in [WORKER_JOB_COPY, WORKER_JOB_EXTRACT_TO_TEMP])) and (not PDataItemSL(List[i])^.DataItem^.IsDir) then begin - FCancelMessage := LANGCannotCopyFileToItself; - FShowCancelMessage := True; - ErrorHappened := True; - Break; - end; + if not (SrcEngine is TVFSEngine) then UpdateCaption1(Format(LANGFromS, [string(PDataItemSL(List[i])^.DataItem^.FDisplayName)])) else + if (SrcEngine as TVFSEngine).ArchiveMode then UpdateCaption1(Format(LANGFromS, [Format(ConstFullPathFormatStr, [(SrcEngine as TVFSEngine).ArchivePath, string(PDataItemSL(List[i])^.DataItem^.FDisplayName)])])) + else UpdateCaption1(Format(LANGFromS, [GetURIPrefix((SrcEngine as TVFSEngine).GetPathURI) + StrToUTF8(string(PDataItemSL(List[i])^.DataItem^.FDisplayName))])); + if not (DestEngine is TVFSEngine) then UpdateCaption2(Format(LANGToS, [StrToUTF8(s)])) else + if (DestEngine as TVFSEngine).ArchiveMode then UpdateCaption2(Format(LANGToS, [Format(ConstFullPathFormatStr, [(DestEngine as TVFSEngine).ArchivePath, StrToUTF8(s)])])) + else UpdateCaption2(Format(LANGToS, [GetURIPrefix((DestEngine as TVFSEngine).GetPathURI) + StrToUTF8(s)])); + CommitGUIUpdate; + if TwoSameFiles(s, string(PDataItemSL(List[i])^.DataItem^.FName), (JobType in [WORKER_JOB_COPY, WORKER_JOB_EXTRACT_TO_TEMP])) and (not PDataItemSL(List[i])^.DataItem^.IsDir) then begin + FCancelMessage := LANGCannotCopyFileToItself; + FShowCancelMessage := True; + ErrorHappened := True; + Break; + end; // * FIXME: why the hell we had something like this here?? -// if s <> string(PDataItemSL(List[i])^.DataItem^.FName) then - if not HandleCopy(List[i], s) then begin +// if s <> string(PDataItemSL(List[i])^.DataItem^.FName) then + if not HandleCopy(List[i], s) then begin + ErrorHappened := True; + Break; + end; + if (not PDataItemSL(List[i])^.DataItem^.IsDir) and (not PDataItemSL(List[i])^.DataItem^.IsLnk) + then Inc(FTotalDone, PDataItemSL(List[i])^.DataItem^.Size); + if FCancelled then begin + FCancelMessage := LANGUserCancelled; + FShowCancelMessage := True; ErrorHappened := True; Break; end; - if (not PDataItemSL(List[i])^.DataItem^.IsDir) and (not PDataItemSL(List[i])^.DataItem^.IsLnk) - then Inc(FTotalDone, PDataItemSL(List[i])^.DataItem^.Size); - if FCancelled then begin - FCancelMessage := LANGUserCancelled; - FShowCancelMessage := True; - ErrorHappened := True; - Break; end; - end; - // We need to ensure these to be called in case of error - if SrcEngine is TVFSEngine then - (SrcEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); - if DestEngine is TVFSEngine then - (DestEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); + // We need to ensure these to be called in case of error + if SrcEngine is TVFSEngine then + (SrcEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); + if DestEngine is TVFSEngine then + (DestEngine as TVFSEngine).StopCopyOperation(@vfs_copy_progress_callback, Self); + end; end; // Free the objects @@ -1537,6 +1572,7 @@ begin for i := List.Count - 1 downto 0 do FreeDataItem(PDataItemSL(List[i])); List.Clear; List.Free; + InaccessiblePaths.Free; // * TODO: check error if not DestEngine.ChangeDir(SaveDestPath, nil) then DebugMsg(['*** WARNING: Cannot change to the origin location, strange behaviour might occur.']); @@ -1992,38 +2028,48 @@ var SkipAll: boolean; var i: longint; AList: TList; + InaccessiblePaths: TStringList; Fr: Single; + SkipInaccessible: boolean; begin SkipAll := False; AList := TList.Create; - PrepareJobFilesFromPanel(AList, ChmodRecurseType < 0); - libc_chdir('/'); - SetProgress1Params(AList.Count); - UpdateProgress1(0, '0 %'); - CommitGUIUpdate; + InaccessiblePaths := TStringList.Create; + PrepareJobFilesFromPanel(AList, InaccessiblePaths, ChmodRecurseType < 0); -// DebugWriteListSL(AList); + SkipInaccessible := False; + if InaccessiblePaths.Count > 0 then + SkipInaccessible := ShowInaccessibleDialog(InaccessiblePaths) <> 1; - if AList.Count = 1 then Fr := 1 else Fr := 100 / (AList.Count - 1); - if AList.Count > 0 then - for i := 0 to AList.Count - 1 do begin - if FCancelled then begin - FCancelMessage := LANGUserCancelled; - FShowCancelMessage := True; - Break; - end; - // Process chmod - if not HandleChmod(AList[i]) then Break; - UpdateProgress1(i, Format('%d%%', [Round(Fr * i)])); - UpdateCaption1(PDataItemSL(AList[i])^.DataItem^.FDisplayName); - CommitGUIUpdate; - end; + if not SkipInaccessible then begin + libc_chdir('/'); + SetProgress1Params(AList.Count); + UpdateProgress1(0, '0 %'); + CommitGUIUpdate; + +// DebugWriteListSL(AList); + if AList.Count = 1 then Fr := 1 else Fr := 100 / (AList.Count - 1); + if AList.Count > 0 then + for i := 0 to AList.Count - 1 do begin + if FCancelled then begin + FCancelMessage := LANGUserCancelled; + FShowCancelMessage := True; + Break; + end; + // Process chmod + if not HandleChmod(AList[i]) then Break; + UpdateProgress1(i, Format('%d%%', [Round(Fr * i)])); + UpdateCaption1(PDataItemSL(AList[i])^.DataItem^.FDisplayName); + CommitGUIUpdate; + end; + end; // Free the objects if AList.Count > 0 then for i := AList.Count - 1 downto 0 do FreeDataItem(PDataItemSL(AList[i])); AList.Clear; AList.Free; + InaccessiblePaths.Free; end; @@ -2068,38 +2114,48 @@ var SkipAll: boolean; var i: longint; AList: TList; + InaccessiblePaths: TStringList; Fr: Single; + SkipInaccessible: boolean; begin SkipAll := False; AList := TList.Create; - PrepareJobFilesFromPanel(AList, not ChownRecursive); - libc_chdir('/'); - SetProgress1Params(AList.Count); - UpdateProgress1(0, '0 %'); - CommitGUIUpdate; + InaccessiblePaths := TStringList.Create; + PrepareJobFilesFromPanel(AList, InaccessiblePaths, not ChownRecursive); -// DebugWriteListSL(AList); + SkipInaccessible := False; + if InaccessiblePaths.Count > 0 then + SkipInaccessible := ShowInaccessibleDialog(InaccessiblePaths) <> 1; - if AList.Count = 1 then Fr := 1 else Fr := 100 / (AList.Count - 1); - if AList.Count > 0 then - for i := 0 to AList.Count - 1 do begin - if FCancelled then begin - FCancelMessage := LANGUserCancelled; - FShowCancelMessage := True; - Break; - end; - // Process chmod - if not HandleChown(AList[i]) then Break; - UpdateProgress1(i, Format('%d%%', [Round(Fr * i)])); - UpdateCaption1(PDataItemSL(AList[i])^.DataItem^.FDisplayName); - CommitGUIUpdate; - end; + if not SkipInaccessible then begin + libc_chdir('/'); + SetProgress1Params(AList.Count); + UpdateProgress1(0, '0 %'); + CommitGUIUpdate; + +// DebugWriteListSL(AList); + if AList.Count = 1 then Fr := 1 else Fr := 100 / (AList.Count - 1); + if AList.Count > 0 then + for i := 0 to AList.Count - 1 do begin + if FCancelled then begin + FCancelMessage := LANGUserCancelled; + FShowCancelMessage := True; + Break; + end; + // Process chmod + if not HandleChown(AList[i]) then Break; + UpdateProgress1(i, Format('%d%%', [Round(Fr * i)])); + UpdateCaption1(PDataItemSL(AList[i])^.DataItem^.FDisplayName); + CommitGUIUpdate; + end; + end; // Free the objects if AList.Count > 0 then for i := AList.Count - 1 downto 0 do FreeDataItem(PDataItemSL(AList[i])); AList.Clear; AList.Free; + InaccessiblePaths.Free; end; |
