How to tell a junction from a directory?

Just starting out? Need help? Post your questions and find answers here.
pthien
Enthusiast
Enthusiast
Posts: 150
Joined: Sun Jun 29, 2003 9:39 pm

How to tell a junction from a directory?

Post by pthien »

I have a program that looks at every file on a hard drive. On Vista or 7 machines it gets stuck with junctions, I think. I think I get stuck in a loop when I encounter junctions because I think they are directories and keep following them deeper and deeper.

Any idea how to avoid this? Is there a test to see if a directory entry is a junction?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to tell a junction from a directory?

Post by IdeasVacuum »

Before parsing the drive, make a list of the junction points. Your code can then check the list to avoid them.

Junction points are specifically Win2000/XP - Vista and Win7 are using the more advanced 'Symbolic links'. There's a smorgasbord Wiki about it:
http://en.wikipedia.org/wiki/NTFS_junction_point
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
em_uk
Enthusiast
Enthusiast
Posts: 366
Joined: Sun Aug 08, 2010 3:32 pm
Location: Manchester UK

Re: How to tell a junction from a directory?

Post by em_uk »

The problem he is coming up against is testing whether the folder is a junction/symbolic link.
----

R Tape loading error, 0:1
pthien
Enthusiast
Enthusiast
Posts: 150
Joined: Sun Jun 29, 2003 9:39 pm

Re: How to tell a junction from a directory?

Post by pthien »

Okay, wait. Here is the problem:

me <= dumb.

The problem I was having wasn't getting caught in junctions, it was the fact that this particular hard drive I was working on had at least a dozen "Temporary Internet Files" folders with hundreds of thousands of files. Once you have more than about 10k files in a folder, NTFS has performance issues.

So once I found that and removed all that crap, my app worked as expected.

I guess I would still like to know how PB handles junctions and symbolic links. Does it ignore these?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to tell a junction from a directory?

Post by IdeasVacuum »

I do not know if PB can handle junctions as anything other than a real folder. In the Wiki, a system command is given for listing them.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
jpd
Enthusiast
Enthusiast
Posts: 167
Joined: Fri May 21, 2004 3:31 pm

Re: How to tell a junction from a directory?

Post by jpd »

Hi pthien,

here a symbolic link... :-) that handle junctions and symbolic links

viewtopic.php?f=12&t=37028&hilit=reparse

Best
jpd
PB 5.10 Windows 7 x64 SP1
User avatar
Blood
Enthusiast
Enthusiast
Posts: 161
Joined: Tue Dec 08, 2009 8:34 pm
Location: United Kingdom

Re: How to tell a junction from a directory?

Post by Blood »

What is a junction?
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
User avatar
luis
Addict
Addict
Posts: 3895
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: How to tell a junction from a directory?

Post by luis »

Blood wrote:What is a junction?
http://en.wikipedia.org/wiki/NTFS_junction_point
"Have you tried turning it off and on again ?"
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to tell a junction from a directory?

Post by IdeasVacuum »

A junction is less confusing than a roundabout for American friends visiting the UK.............
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Zach
Addict
Addict
Posts: 1677
Joined: Sun Dec 12, 2010 12:36 am
Location: Somewhere in the midwest
Contact:

Re: How to tell a junction from a directory?

Post by Zach »

We have plenty of roundabouts (we call them traffic circles). I don't know why people find them so damn hard to figure out though, especially with all the signs posted and lane markers + arrows on the road.

But still, idiots go in using one lane, and switch to another halfway through, enter the circle when traffic is coming around in the proper lane (NOT the exit lane), and no one can seem to tell which lane they are supposed to be in.


It really pisses me off. I'm going to die going through one of them one day :x
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: How to tell a junction from a directory?

Post by RASHAD »

Egypt my love
User avatar
Blood
Enthusiast
Enthusiast
Posts: 161
Joined: Tue Dec 08, 2009 8:34 pm
Location: United Kingdom

Re: How to tell a junction from a directory?

Post by Blood »

luis wrote:
Blood wrote:What is a junction?
http://en.wikipedia.org/wiki/NTFS_junction_point
Thanks! Looks like microsoft's attempt at recreating a symbolic link and failing badly! lol! When will microsoft learn. he he,... :mrgreen:
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
User avatar
skywalk
Addict
Addict
Posts: 4242
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: How to tell a junction from a directory?

Post by skywalk »

The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to tell a junction from a directory?

Post by IdeasVacuum »

:mrgreen: I like the Kitt advert too :oops:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply