FIX: Compilation error, revert GetFilesInDir() from DCOSUtils into OSUtils

This commit is contained in:
rich2014 2026-05-31 10:28:45 +08:00
commit c0e020f675
5 changed files with 86 additions and 87 deletions

View file

@ -27,8 +27,7 @@ unit DCOSUtils;
interface
uses
SysUtils, Classes, DynLibs, DCClassesUtf8, DCBasicTypes, DCConvertEncoding,
ShellCtrls
SysUtils, Classes, DynLibs, DCClassesUtf8, DCBasicTypes, DCConvertEncoding
{$IFDEF UNIX}
, BaseUnix, DCUnix
{$ENDIF}
@ -333,9 +332,6 @@ procedure SetLastOSError(LastError: Integer);
function GetTickCountEx: UInt64;
procedure GetFilesInDir(const ABaseDir: String; const AObjectTypes: TObjectTypes;
const AFileSortType: TFileSortType; AResult: TStringList );
implementation
uses
@ -2154,77 +2150,6 @@ begin
end;
end;
function FilesSortAlphabet(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result:= CompareFilenames(List[Index1], List[Index2]);
end;
function FilesSortFoldersFirst(List: TStringList; Index1, Index2: Integer): Integer;
var
Attr1, Attr2: IntPtr;
begin
Attr1:= IntPtr(List.Objects[Index1]);
Attr2:= IntPtr(List.Objects[Index2]);
if (Attr1 and faDirectory <> 0) and (Attr2 and faDirectory <> 0) then
Result:= CompareFilenames(List[Index1], List[Index2])
else begin
if (Attr1 and faDirectory <> 0) then
Result:= -1
else begin
Result:= 1;
end;
end;
end;
procedure GetFilesInDir(const ABaseDir: String; const AObjectTypes: TObjectTypes;
const AFileSortType: TFileSortType; AResult: TStringList );
var
ExcludeAttr: Integer;
SearchRec: TSearchRec;
{$IF DEFINED(MSWINDOWS)}
ErrMode : LongWord;
{$ENDIF}
begin
{$IF DEFINED(MSWINDOWS)}
ErrMode:= SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOALIGNMENTFAULTEXCEPT or SEM_NOGPFAULTERRORBOX or SEM_NOOPENFILEERRORBOX);
try
{$ENDIF}
if FindFirst(ABaseDir + AllFilesMask, faAnyFile, SearchRec) = 0 then
begin
ExcludeAttr:= 0;
if not (otHidden in AObjectTypes) then
ExcludeAttr:= ExcludeAttr or faHidden;
if not (otFolders in AObjectTypes) then
ExcludeAttr:= ExcludeAttr or faDirectory;
repeat
if (SearchRec.Attr and ExcludeAttr <> 0) then
Continue;
if (SearchRec.Name = '.') or (SearchRec.Name = '..')then
Continue;
if (SearchRec.Attr and faDirectory = 0) and not (otNonFolders in AObjectTypes) then
Continue;
AResult.AddObject(SearchRec.Name, TObject(IntPtr(SearchRec.Attr)));
until FindNext(SearchRec) <> 0;
if AResult.Count > 0 then
begin
case AFileSortType of
fstAlphabet: AResult.CustomSort(@FilesSortAlphabet);
fstFoldersFirst: AResult.CustomSort(@FilesSortFoldersFirst);
end;
end;
end;
SysUtils.FindClose(SearchRec);
{$IF DEFINED(MSWINDOWS)}
finally
SetErrorMode(ErrMode);
end;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
initialization
if QueryPerformanceFrequency(@PerformanceFrequency) then

View file

@ -92,17 +92,14 @@ end"/>
</Item13>
</Files>
<CompatibilityMode Value="True"/>
<RequiredPkgs Count="3">
<RequiredPkgs Count="2">
<Item1>
<PackageName Value="LCLBase"/>
</Item1>
<Item2>
<PackageName Value="FCL"/>
<MinVersion Major="1" Valid="True"/>
</Item2>
<Item3>
</Item1>
<Item2>
<PackageName Value="LazUtils"/>
</Item3>
</Item2>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>

View file

@ -114,7 +114,7 @@ implementation
uses
LazUTF8, fMain, LCLType, LCLVersion, uGlobs, uLng, uHotkeyManager,
DCOSUtils, DCStrUtils;
uOSUtils, DCStrUtils;
const
HotkeysCategory = 'Copy/Move Dialog';

View file

@ -89,7 +89,7 @@ type
implementation
uses
LCLType, ShellCtrls, Graphics, uDCUtils, DCOSUtils, DCStrUtils, uKeyboard,
LCLType, ShellCtrls, Graphics, uOSUtils, uDCUtils, DCOSUtils, DCStrUtils, uKeyboard,
fMain, uFileSourceUtil, uGlobs, uPixMapManager, uLng, uFileFunctions,
uArchiveFileSource, uFileViewWithPanels, uVfsModule;

View file

@ -30,7 +30,8 @@ unit uOSUtils;
interface
uses
SysUtils, Classes, Process, LCLType, uDrive, DCBasicTypes, uFindEx
SysUtils, Classes, Process, LCLType, ShellCtrls,
uDrive, DCBasicTypes, uFindEx
{$IF DEFINED(UNIX)}
, DCFileAttributes
{$IFDEF DARWIN}
@ -185,10 +186,15 @@ function GetCurrentUserName : String;
}
function GetComputerNetName: String;
procedure GetFilesInDir(const ABaseDir: String; const AObjectTypes: TObjectTypes;
const AFileSortType: TFileSortType; AResult: TStringList );
implementation
uses
StrUtils, uFileProcs, FileUtil, uDCUtils, DCOSUtils, DCStrUtils, uGlobs, uLng,
StrUtils, uFileProcs, FileUtil, LazFileUtils,
uDCUtils, DCOSUtils, DCStrUtils, uGlobs, uLng,
fConfirmCommandLine, uLog, DCConvertEncoding, LazUTF8
{$IF DEFINED(MSWINDOWS)}
, Windows, Shlwapi, WinRT.Classes, uMyWindows, JwaWinNetWk,
@ -907,4 +913,75 @@ begin
end;
{$ENDIF}
function FilesSortAlphabet(List: TStringList; Index1, Index2: Integer): Integer;
begin
Result:= CompareFilenames(List[Index1], List[Index2]);
end;
function FilesSortFoldersFirst(List: TStringList; Index1, Index2: Integer): Integer;
var
Attr1, Attr2: IntPtr;
begin
Attr1:= IntPtr(List.Objects[Index1]);
Attr2:= IntPtr(List.Objects[Index2]);
if (Attr1 and faDirectory <> 0) and (Attr2 and faDirectory <> 0) then
Result:= CompareFilenames(List[Index1], List[Index2])
else begin
if (Attr1 and faDirectory <> 0) then
Result:= -1
else begin
Result:= 1;
end;
end;
end;
procedure GetFilesInDir(const ABaseDir: String; const AObjectTypes: TObjectTypes;
const AFileSortType: TFileSortType; AResult: TStringList );
var
ExcludeAttr: Integer;
SearchRec: TSearchRec;
{$IF DEFINED(MSWINDOWS)}
ErrMode : LongWord;
{$ENDIF}
begin
{$IF DEFINED(MSWINDOWS)}
ErrMode:= SetErrorMode(SEM_FAILCRITICALERRORS or SEM_NOALIGNMENTFAULTEXCEPT or SEM_NOGPFAULTERRORBOX or SEM_NOOPENFILEERRORBOX);
try
{$ENDIF}
if FindFirst(ABaseDir + AllFilesMask, faAnyFile, SearchRec) = 0 then
begin
ExcludeAttr:= 0;
if not (otHidden in AObjectTypes) then
ExcludeAttr:= ExcludeAttr or faHidden;
if not (otFolders in AObjectTypes) then
ExcludeAttr:= ExcludeAttr or faDirectory;
repeat
if (SearchRec.Attr and ExcludeAttr <> 0) then
Continue;
if (SearchRec.Name = '.') or (SearchRec.Name = '..')then
Continue;
if (SearchRec.Attr and faDirectory = 0) and not (otNonFolders in AObjectTypes) then
Continue;
AResult.AddObject(SearchRec.Name, TObject(IntPtr(SearchRec.Attr)));
until FindNext(SearchRec) <> 0;
if AResult.Count > 0 then
begin
case AFileSortType of
fstAlphabet: AResult.CustomSort(@FilesSortAlphabet);
fstFoldersFirst: AResult.CustomSort(@FilesSortFoldersFirst);
end;
end;
end;
SysUtils.FindClose(SearchRec);
{$IF DEFINED(MSWINDOWS)}
finally
SetErrorMode(ErrMode);
end;
{$ENDIF}
end;
end.