Recent

Author Topic: FindAllFiles not working on Ubuntu Folders  (Read 6468 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14159
  • Probably until I exterminate Putin.
Re: FindAllFiles not working on Ubuntu Folders
« Reply #15 on: July 23, 2017, 09:41:00 pm »
Which FPC version are you using? 2.6.4? These two have a direct effect on your problem:
Changes 3.0.2:
"http://wiki.freepascal.org/User_Changes_3.0#SysUtils:_File_names_starting_with_a_period_are_not_considered_to_be_extensions"
and:

http://wiki.freepascal.org/User_Changes_3.0.2
"Implementation Changes
Unit changes
SysUtils
Old behaviour: faSymlink had the numerical value $40. This was wrong on windows, and not compatible with Delphi.
New behaviour: faSymlink has the numerical value $400. Correct on windows.
Reason for change: Wrong functionality and Delphi compatibility.
Remedy: If you are using the old numerical constant $40, simply use faSymlink instead."

Note symlinks are very important on Linux and much wider used than on windows. If you are indeed using fpc 2.6.4 upgrade asap.
« Last Edit: July 23, 2017, 09:51:00 pm by Thaddy »
Specialize a type, not a var.

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: FindAllFiles not working on Ubuntu Folders
« Reply #16 on: July 23, 2017, 09:58:41 pm »
I don't believe this because Gizmo's version is practically identical with the Lazarus version

Seeing is believing.

AND, "practically," is not actually. :)

Instead of harisplitting remarks, why don't you just respond to the idea with the different search masks?

Bart

  • Hero Member
  • *****
  • Posts: 5265
    • Bart en Mariska's Webstek
Re: FindAllFiles not working on Ubuntu Folders
« Reply #17 on: July 24, 2017, 12:47:11 am »
Here's my folder layout:

Code: [Select]
bart@simenon ~/LazarusProjecten/bugs/findallfiles/test $ ls -al -R
.:
totaal 12
drwxrwxr-x 3 bart bart 4096 jul 24 00:40 .
drwxrwxr-x 5 bart bart 4096 jul 24 00:38 ..
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 1
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 2
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 3
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 .4
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 .5
-rw-rw-r-- 1 bart bart    0 jul 24 00:39 .6
drwxrwxr-x 2 bart bart 4096 jul 24 00:40 .dir

./.dir:
totaal 8
drwxrwxr-x 2 bart bart 4096 jul 24 00:40 .
drwxrwxr-x 3 bart bart 4096 jul 24 00:40 ..
-rw-rw-r-- 1 bart bart    0 jul 24 00:40 7
-rw-rw-r-- 1 bart bart    0 jul 24 00:40 .8

In total 8 files (and 1 folder).

Here's my code
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   List: TStringList;
  4. begin
  5.   List := TStringList.Create;
  6.   FindAllFiles(List, '/home/bart/LazarusProjecten/bugs/findallfiles/test/', '*', True, faDirectory or faHidden);
  7.   List.Add(Format('Count = %d',[List.Count]));
  8.   Memo1.Lines.Assign(List);
  9.   List.Free;
  10. end;
  11.  

Here's the output

Code: [Select]
/home/bart/LazarusProjecten/bugs/findallfiles/test/.5
/home/bart/LazarusProjecten/bugs/findallfiles/test/.4
/home/bart/LazarusProjecten/bugs/findallfiles/test/1
/home/bart/LazarusProjecten/bugs/findallfiles/test/2
/home/bart/LazarusProjecten/bugs/findallfiles/test/.6
/home/bart/LazarusProjecten/bugs/findallfiles/test/3
/home/bart/LazarusProjecten/bugs/findallfiles/test/.dir/7
/home/bart/LazarusProjecten/bugs/findallfiles/test/.dir/.8
Count = 8

So, it finds all files, hidden or not, also in hidden subdirectories.

Bart

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: FindAllFiles not working on Ubuntu Folders
« Reply #18 on: July 24, 2017, 12:08:08 pm »
You guys have got me wondering as well. I seem to recall that this "enhancement" was made some time ago, long before v3.0 of FPC. So it may have been designed to fix an issue I had back in about 2012 or 2013. But I'm also not sure, now, how it works with the missing parameter either. But it's implemented in my code and my program, and, as the screenshots show, with avariety of hidden and unhidden files and folders, it does work as intended. This is from the code as seen here : https://github.com/tedsmith/quickhash/blob/master/unit2.pas#L1751

(preparing the screenshots, I just noticed a different bug re time taken, which I have now fixed!)

But that said, maybe the newer version of FindAllFiles works as needed anyway. I need to look at testing it as Bart has done and consider using the native FPC function now.

(Note: According to my comments I gave you credit, Bart (https://github.com/tedsmith/quickhash/blob/master/FindAllFilesEnhanced.pas#L2), for helping with this! So I dig some more and found the thread that triggered it all, for info : http://forum.lazarus-ide.org/index.php?topic=26705.0 )
« Last Edit: July 26, 2017, 02:45:23 pm by Gizmo »

 

TinyPortal © 2005-2018