Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:21:22+00:00 2026-06-14T16:21:22+00:00

I’m using this JEDI component to enumerate files but I can’t get it skip

  • 0

I’m using this JEDI component to enumerate files but I can’t get it skip over junctions. Is there a setting or modification to the code I can do to fix this?

I am not 100% sure of the relevant code in the jvsearchfiles.pas unit. But I think it is is here:

function TJvSearchFiles.EnumFiles(const ADirectoryName: string;
  Dirs: TStrings; const Search: Boolean): Boolean;
var
  Handle: THandle;
  Finished: Boolean;
  DirOK: Boolean;
begin
  DoBeginScanDir(ADirectoryName);

  { Always scan the full directory - ie use * as mask - this seems faster
    then first using a mask, and then scanning the directory for subdirs }
  Handle := FindFirstFile(PChar(ADirectoryName + '*'), FFindData);
  Result := Handle <> INVALID_HANDLE_VALUE;
  if not Result then
  begin
    Result := GetLastError in [ERROR_FILE_NOT_FOUND, ERROR_ACCESS_DENIED];;
    Exit;
  end;

  Finished := False;
  try
    while not Finished do
    begin
      // (p3) no need to bring in the Forms unit for this:
      if not IsConsole then
        DoProgress;
      { After DoProgress, the user can have called Abort,
        so check it }
      if FAborting then
      begin
        Result := False;
        Exit;
      end;

      with FFindData do
        { Is it a directory? }
        if (dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY > 0) then
        begin
          { Filter out '.' and '..'
            Other dir names can't begin with a '.' }

          {                         | Event | AddDir | SearchInDir
           -----------------------------------------------------------------
            doExcludeSubDirs        |
              True                  |   Y       N           N
              False                 |   N       N           N
            doIncludeSubDirs        |
              True                  |   Y       Y           Y
              False                 |   N       Y           Y
            doExcludeInvalidDirs    |
              True                  |   Y       Y           Y
              False                 |   N       Y           N
            doExcludeCompleteInvalidDirs |
              True                  |   Y       Y           Y
              False                 |   N       N           N
          }
          if not IsDotOrDotDot(cFileName) and
            ((soIncludeSystemHiddenDirs in Options) or not IsSystemAndHidden(FFindData)) then
            { Use case to prevent unnecessary calls to DoCheckDir }
            case DirOption of
              doExcludeSubDirs, doIncludeSubDirs:
                begin
                  if Search and (soSearchDirs in Options) and DoCheckDir then
                    DoFindDir(ADirectoryName);
                  if DirOption = doIncludeSubDirs then
                    Dirs.AddObject(cFileName, TObject(True))
                end;
              doExcludeInvalidDirs, doExcludeCompleteInvalidDirs:
                begin
                  DirOK := DoCheckDir;
                  if Search and (soSearchDirs in Options) and DirOK then
                    DoFindDir(ADirectoryName);

                  if (DirOption = doExcludeInvalidDirs) or DirOK then
                    Dirs.AddObject(cFileName, TObject(DirOK));
                end;
            end;
        end
        else
        if Search and (soSearchFiles in Options) and DoCheckFile then
          DoFindFile(ADirectoryName);

      if not FindNextFile(Handle, FFindData) then
      begin
        Finished := True;
        Result := GetLastError = ERROR_NO_MORE_FILES;
      end;
    end;
  finally
    Result := FindClose(Handle) and Result;
  end;
end;

This is the function given in the previous question but I was never able to get it to work.

function IsJunction(const FileName: string): Boolean;
const
  IO_REPARSE_TAG_MOUNT_POINT = $0A0000003;
var
  FindHandle: THandle;
  FindData: TWin32FindData;
begin
  Result := False;
  FindHandle := FindFirstFile(PChar(FileName), FindData);
  if FindHandle <> INVALID_HANDLE_VALUE then begin
    Result := ((FindData.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT)
                = FILE_ATTRIBUTE_REPARSE_POINT) and
                ((FindData.dwReserved0 and IO_REPARSE_TAG_MOUNT_POINT)
                = IO_REPARSE_TAG_MOUNT_POINT);
    winapi.windows.FindClose(FindHandle);
  end else
    RaiseLastOSError;
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:21:23+00:00Added an answer on June 14, 2026 at 4:21 pm

    The function you are looking at already has a point at which it skips directories:

    if not IsDotOrDotDot(cFileName) and
       ((soIncludeSystemHiddenDirs in Options) or not IsSystemAndHidden(FFindData)) then
    

    So you can simply extend this condition. However, I would not extend it by adding another and clause. I personally find if statements like this to be exceedingly opaque. I would introduce an explanatory variable:

    var
      SkipDirectory: Boolean;
    

    and then assign it like this:

    if IsDotOrDotDot(cFileName) then
      SkipDirectory := True
    else if IsSystemAndHidden(FFindData) and not (soIncludeSystemHiddenDirs in Options) then
      SkipDirectory := True
    else if IsJunction(FFindData) then
      SkipDirectory := True
    else
      SkipDirectory := False;
    
    if not SkipDirectory then
      ....
    

    And then you need to re-work your IsJunction to receive a TWin32FindData parameter:

    function IsJunction(const FindData: TWin32FindData): Boolean;
    const
      IO_REPARSE_TAG_MOUNT_POINT = $0A0000003;
    begin
      Result := ((FindData.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT)
                  = FILE_ATTRIBUTE_REPARSE_POINT) and
                  (FindData.dwReserved0 = IO_REPARSE_TAG_MOUNT_POINT);
    end;
    

    Although I’d probably re-write @Sertac’s if statement to break it up a bit more. But perhaps that’s just my personal preference.

    function FlagIsSet(Flags, Flag: DWORD): Boolean;
    begin
      Result := (Flags and Flag)<>0;
    end;
    
    function IsJunction(const FindData: TWin32FindData): Boolean;
    const
      IO_REPARSE_TAG_MOUNT_POINT = $0A0000003;
    begin
      Result := FlagIsSet(FindData.dwFileAttributes, FILE_ATTRIBUTE_REPARSE_POINT)
                and (FindData.dwReserved0=IO_REPARSE_TAG_MOUNT_POINT);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.