On macos I get "-2" if I check a folder with FileSize() which is actually a symlink to another directory. I suppose it is similar under Windows.
How I can check if a folder is a real folder or a symlink?
Check if a folder is a symlink
Re: Check if a folder is a symlink
ChatGPT has helped me successfully:

Code: Select all
ImportC ""
lstat(path.p-utf8, *buf)
EndImport
Structure stat
st_dev.q
st_mode.l
st_nlink.l
st_ino.q
st_uid.l
st_gid.l
st_rdev.q
st_atimespec.q[2]
st_mtimespec.q[2]
st_ctimespec.q[2]
st_birthtimespec.q[2]
st_size.q
st_blocks.q
st_blksize.l
st_flags.l
st_gen.l
st_lspare.l
st_qspare.q[2]
EndStructure
#S_IFMT = $F000
#S_IFLNK = $A000
Procedure IsSymlink(Path$)
Protected statbuf.stat
If lstat(Path$, @statbuf) = 0
If (statbuf\st_mode & #S_IFMT) = #S_IFLNK
ProcedureReturn #True
EndIf
EndIf
ProcedureReturn #False
EndProcedure
; Beispiel:
Define Pfad$ = "/Users/lebostein/Documents/Test"
If IsSymlink(Pfad$)
Debug Pfad$ + " is Symlink."
Else
Debug Pfad$ + " no Symlink."
EndIf
Re: Check if a folder is a symlink
This is what I get with the ChatGPT code you posted:

Re: Check if a folder is a symlink
For me it works
- Mindphazer
- Enthusiast
- Posts: 456
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: Check if a folder is a symlink
Barry, the code is for MacOS (and probably Linux)
It doesn't work on Windows
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
Re: Check if a folder is a symlink
Oh, I see.
Re: Check if a folder is a symlink
But it seems only work if I use the x64 version of PB. With PB arm64 version it dont work correctly...