os.path.islink()

E

Egor Bolonev

hi all

i want my program to ignore ntfs links, but os.path.islink() isnt work as
i expect

print os.path.islink('''C:\Documents and Settings\åÇÏÒ\My
Documents\Scripts\Antiloop\'''')
outputs
False

far file manager said 'C:\Documents and Settings\åÇÏÒ\My
Documents\Scripts\Antiloop\' is link

how to detect ntfs links?

=program======
import os, os.path

def get_all_files(path):
if len(path) > 0:
if path[-1] == ':':
path=path+'\\'
try:
for i in os.listdir(path):
j = os.path.join(path, i)
if os.path.isdir(j) and not os.path.islink(j):
for ii in get_all_files(j):
yield ii
else:
yield j
except:pass

for i in get_all_files('c:'):
print i
==============
 
P

Peter Maas

Egor said:
far file manager said 'C:\Documents and Settings\Егор\My
Documents\Scripts\Antiloop\' is link

how to detect ntfs links?

There are no ntfs links. What appears as a link on GUI level is
nothing but a plain file with special content, so that
os.path.islink() tells the truth. Windows "links" are a special
Windows feature (shortcuts) and must be detected via Win32 api
calls or by searching for content characteristics of shortcuts.
 
E

Egor Bolonev

There are no ntfs links. What appears as a link on GUI level is
nothing but a plain file with special content, so that
os.path.islink() tells the truth. Windows "links" are a special
Windows feature (shortcuts) and must be detected via Win32 api
calls or by searching for content characteristics of shortcuts.

gui folder link is a .lnk file
 
E

Egor Bolonev

gui folder link is a .lnk file

i want to detect "<JUNCTION>'s"

============================================
C:\Documents and Settings\åÇÏÒ\My Documents>dir
ôÏÍ × ÕÓÔÒÏÊÓÔ×Å C ÎÅ ÉÍÅÅÔ ÍÅÔËÉ.
óÅÒÉÊÎÙÊ ÎÏÍÅÒ ÔÏÍÁ: 386D-F630

óÏÄÅÒÖÉÍÏÅ ÐÁÐËÉ C:\Documents and Settings\åÇÏÒ\My Documents

08.12.2004 20:39 <DIR> .
08.12.2004 20:39 <DIR> ..
08.12.2004 20:39 <JUNCTION> Antiloop
06.12.2004 20:47 <DIR> My eBooks
02.12.2004 22:50 <DIR> My Music
06.12.2004 23:34 <DIR> My Pictures
06.12.2004 23:56 <DIR> My Videos
08.12.2004 20:23 <DIR> Scripts
04.12.2004 16:23 <DIR> upload
16.11.2004 21:14 <DIR> Virtual CD v6
16.11.2004 21:15 <DIR> Virtual CDs
08.12.2004 20:36 <DIR> [temp]
04.12.2004 20:11 <DIR> ìÉÞÎÏÅ
06.12.2004 22:51 <DIR> îÏ×ÁÑ ÐÁÐËÁ
0 ÆÁÊÌÏ× 0 ÂÁÊÔ
14 ÐÁÐÏË 8š970š833š920 ÂÁÊÔ Ó×ÏÂÏÄÎÏ
============================================
 
E

Erik Max Francis

Egor said:
gui folder link is a .lnk file

What he's telling you is that Windows doesn't implement symbolic links.
os.path.islink does not detect what you think it does.
 
T

Tim G

You may well be able to do it with the win32file module
functions: GetFileAttributesEx or GetFileInformationByHandle
It's not my area of expertise, but usually a bit of poking around
in msdn.microsoft.com yields some results, as does Googling
around for other people (often VB or Delphi-based) who have
done the same thing.

TJG
 
J

JanC

Peter Maas schreef:
Thanks for the update and my apologies to Egor. I was using Win2k for
two years and never saw a link, neither at system nor at application
locations. How nasty of Microsoft to add this feature so silently :)

IIRC this is something they had to add for the US government (probably
something to do with posix compliancy?), but that they don't want people
to use... ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top