Recent

Author Topic: FileExists not run correctly to symlink  (Read 2576 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
FileExists not run correctly to symlink
« on: February 08, 2019, 02:41:57 pm »
Hi guys, I have a little problem. I have a program that creates symbolic links on windows using the "mklink \ j destination source" command. If I do a FileExists on the destination after it has been created it does not return true to me. Why? How do I know if a symlink exists? Thank you
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

ASerge

  • Hero Member
  • *****
  • Posts: 2222
Re: FileExists not run correctly to symlink
« Reply #1 on: February 08, 2019, 03:00:09 pm »
I have a program that creates symbolic links on windows using the "mklink \ j destination source" command. If I do a FileExists on the destination after it has been created it does not return true to me. Why? How do I know if a symlink exists?
Details, please. mklink / j make the junction for the DIRECTORY. Not file! Have you tested the existence of a file in this directory or are you using FileExists to check the existence of a directory?

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: FileExists not run correctly to symlink
« Reply #2 on: February 08, 2019, 03:03:55 pm »
I want to know if there is a junction. Are you coming?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

ASerge

  • Hero Member
  • *****
  • Posts: 2222
Re: FileExists not run correctly to symlink
« Reply #3 on: February 08, 2019, 04:38:29 pm »
I want to know if there is a junction. Are you coming?
So the question is quite different? How determine that a directory is a junction?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: FileExists not run correctly to symlink
« Reply #4 on: February 08, 2019, 07:09:49 pm »
Fixed in trunk afaik (revisions 39668,39669,39671,39672), fileexists has now a followlink parameter

Quote
r39668 svenbarth 2018-08-24 17:33:09 +0200 (Fri, 24 Aug 2018)
+ add Delphi compatible FollowLink parameter (default is True) to FileExists and DirectoryExists; support for it is up to each target
r39669 svenbarth 2018-08-24 17:33:45 +0200 (Fri, 24 Aug 2018)
+ add Delphi-compatible FileGetSymLinkTarget functions to all platforms (currently returns False on all platforms); this also includes TSymLinkRec variants for both RawByteString and UnicodeString
r39671 svenbarth 2018-08-24 17:34:04 +0200 (Fri, 24 Aug 2018)
+ implement FileGetSymLinkTarget() based on patch by Serge Anvarov in Mantis 0032370
r39672 svenbarth 2018-08-24 17:34:09 +0200 (Fri, 24 Aug 2018)
* improve DirectoryExists() and FileExists() based on patch by Serge Anvarov in Mantis 0032370 so that they also support files/directories that aren't accessible (e.g. the page file) as well as FollowLink = False

Afaik they are not merged because it is initial and the per target implementations still have to be done.

xinyiman

  • Hero Member
  • *****
  • Posts: 2256
    • Lazarus and Free Pascal italian community
Re: FileExists not run correctly to symlink
« Reply #5 on: February 12, 2019, 08:50:12 am »
Thank you very much
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

 

TinyPortal © 2005-2018