Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adir() and symlinks

Status
Not open for further replies.

JackTheC

Programmer
Feb 25, 2002
325
NL
Hi Guys,

I want to do a drive search for specific files using a recursive Adir() call.
But the 'D' parameter for directories also selects so called symlinks made with the DOS-command MKLINK /D.
In fact symlinks are aliases for an other real folder.
To prevent double results I need to skip symlinkd folders. But how to determine in VFP if a folder is real or a symlinkd alias?

The DOS Dir command shows <DIR> or <SYMLINKD> so the DOS prompt can determine the difference. But I don't want a recursive call with Dos Dir commands. VFP's Adir() is blazing fast.

 
OK, I just found an alternative Dir checker in VBscript. I'll try calling this from VFP. E.g.

Code:
Const FA_REPARSE_POINT = &h400

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("F:\my movies")

If (f.Attributes And FA_REPARSE_POINT) = FA_REPARSE_POINT Then
  msgbox "symlink"
Else
  msgbox "normal"
End If
 
Jack,
Did you try setting the Attribute -S using ADIR? I belive that will ignore anything that's not an actual DIR...


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Ooops, I'm thinking DOS... negative attributes aren't accepted.

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
I think this will be the translation in VFP:

Code:
[in main.prg]
fso = CreateObject("Scripting.FileSystemObject")
.
.
.
* Example:
thisfolder="f:\my movies"
if issym(thisfolder)
	* real folder
else
	* symlink folder
endif


PROCEDURE ISSYM
lparameter folderchk

fda=fso.GetFolder(folderchk)

if bitand(fda.Attributes,1024)=1024 
  return .f.
else
  return .t.
endif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top