Recent

Author Topic: Finding folders whose path is greater than 260 chars using FPC 2.6.4?  (Read 3276 times)

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Linked in general theory to this (http://forum.lazarus.freepascal.org/index.php?topic=26488.0) but different as it relates to finding and reading files...

The Windows MAX_PATH limit of 260 characters for folders and filenames is causing a problem with a program I have made that searches for files. It works fine for all files except the ones that are in folders that are greater than 260 chars.

Though it is true that there aren't many software tools that can create folders and files longer than that depth, there are some. However, if the user then eeds to use "normal" windows tools to access those files, they either don't detect them or they generate errors.

In my case, my colleagues are using my program to copy data across our network and benefiting from the hash CRC checks it does. However, lets say there are 10K files in FolderA, we're finding it might only be copying 9,990 to the destination folder. It turns out the 10 missing files are files that, in Folder A, are in folders longer than 260 characters.

My program uses the TFileSearcher type which in turns uses FindFirst and FindNext compiled using Lazarus 1.4.0 and FPC 2.6.4 - my stable programming environment.

I gather FPC v3 uses unicode aware versions of most of the functions like FindFirstW etc that can detect files in paths of lengths of 32K characters, but I don't especially want to code a program using yet another version of the language because I'll end up getting muddled up and compiling some programs with one version and others with another version etc.

So my question is how can I ensure files are FOUND if they live in folders whose path is greater than 260 chars using the FPC 2.6.4 instances of TFileSearcher?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #1 on: September 17, 2015, 06:02:52 pm »
You could try to patch the RTL yourself, but I guess that will be harder and less safe than moving to 3.0

Gizmo

  • Hero Member
  • *****
  • Posts: 831
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #2 on: September 17, 2015, 06:12:57 pm »
I seem to recall reading somewhere that 2.6.4 and 3.0 can be installed independantly of each other on the same computer. Is that right? If so, I could use FPC 3.0 for this one project and 2.6.4 for the others I guess.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #3 on: September 17, 2015, 06:17:19 pm »
Not with the same lazarus. You can have multiple lazaruses though if you always start (start)lazarus with the --pcp=  setting, e.g. using a batchfile.


Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #4 on: September 17, 2015, 08:52:32 pm »
Not with the same lazarus.

Sorry?
I have 2.6.4 and 3.0.0rc1 installed and i can simply switch compiler in Lazarus options.
It will rebuild the entire LCL (and many components) upon build, so it's not very convenient to switch all of the time.

Bart

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11459
  • FPC developer.
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #5 on: September 17, 2015, 08:55:37 pm »
Not with the same lazarus.

Sorry?
I have 2.6.4 and 3.0.0rc1 installed and i can simply switch compiler in Lazarus options.
It will rebuild the entire LCL (and many components) upon build, so it's not very convenient to switch all of the time.

Yes, forgot about that, the version numbers in the output dirs make it more robust. Still, it is not the healthiest of situations.

gafe

  • New Member
  • *
  • Posts: 22
Re: Finding folders whose path is greater than 260 chars using FPC 2.6.4?
« Reply #6 on: September 17, 2015, 09:51:56 pm »
(on mobile) maybe trying this:
http://stackoverflow.com/a/1880480

 

TinyPortal © 2005-2018