os.path.islink()

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Egor Bolonev

    #1

    os.path.islink()

    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\åÇÏÒ\M y
    Documents\Scrip ts\Antiloop\''' ')
    outputs
    False

    far file manager said 'C:\Documents and Settings\åÇÏÒ\M y
    Documents\Scrip ts\Antiloop\' is link

    how to detect ntfs links?

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

    def get_all_files(p ath):
    if len(path) > 0:
    if path[-1] == ':':
    path=path+'\\'
    try:
    for i in os.listdir(path ):
    j = os.path.join(pa th, 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
    ==============
  • Peter Maas

    #2
    Re: os.path.islink( )

    Egor Bolonev schrieb:[color=blue]
    > far file manager said 'C:\Documents and Settings\Его р\My
    > Documents\Scrip ts\Antiloop\' is link
    >
    > how to detect ntfs links?[/color]

    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.

    --
    -------------------------------------------------------------------
    Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
    E-mail 'cGV0ZXIubWFhc0 BtcGx1c3IuZGU=\ n'.decode('base 64')
    -------------------------------------------------------------------

    Comment

    • Egor Bolonev

      #3
      Re: os.path.islink( )

      On Wed, 08 Dec 2004 10:23:13 +0100, Peter Maas <peter@somewher e.com> wrote:
      [color=blue]
      > Egor Bolonev schrieb:[color=green]
      >> far file manager said 'C:\Documents and Settings\åÇÏÒ\M y
      >> Documents\Scrip ts\Antiloop\' is link
      >> how to detect ntfs links?[/color]
      >
      > 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.[/color]

      gui folder link is a .lnk file

      Comment

      • Egor Bolonev

        #4
        Re: os.path.islink( )

        On Wed, 08 Dec 2004 20:29:27 +1000, Egor Bolonev <ebolonev@mail. ru> wrote:
        [color=blue]
        > gui folder link is a .lnk file[/color]

        i want to detect "<JUNCTION> 's"

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

        óÏÄÅÒÖÉÍÏÅ ÐÁÐËÉ C:\Documents and Settings\åÇÏÒ\M y 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 ÂÁÊÔ Ó×ÏÂÏÄÎÏ
        =============== =============== ==============

        Comment

        • Erik Max Francis

          #5
          Re: os.path.islink( )

          Egor Bolonev wrote:
          [color=blue]
          > gui folder link is a .lnk file[/color]

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

          --
          Erik Max Francis && max@alcyone.com && http://www.alcyone.com/max/
          San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
          I am an island / A little freak of melancholy
          -- Lamya

          Comment

          • Tim G

            #6
            Re: os.path.islink( )

            You may well be able to do it with the win32file module
            functions: GetFileAttribut esEx or GetFileInformat ionByHandle
            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

            Comment

            • JanC

              #7
              Re: os.path.islink( )

              Peter Maas schreef:
              [color=blue]
              > Egor Bolonev schrieb:
              >[color=green]
              >> how to detect ntfs links?[/color]
              >
              > There are no ntfs links.[/color]

              You're wrong, NTFS supports symlinks for directories and hard links for
              files:

              <http://www.sysinternal s.com/ntw2k/source/misc.shtml#junc tion>
              <http://shell-shocked.org/article.php?id= 284>


              --
              JanC

              "Be strict when sending and tolerant when receiving."
              RFC 1958 - Architectural Principles of the Internet - section 3.9

              Comment

              • Peter Maas

                #8
                Re: os.path.islink( )

                JanC schrieb:[color=blue][color=green]
                >>There are no ntfs links.[/color]
                >
                >
                > You're wrong, NTFS supports symlinks for directories and hard links for
                > files:
                >
                > <http://www.sysinternal s.com/ntw2k/source/misc.shtml#junc tion>
                > <http://shell-shocked.org/article.php?id= 284>[/color]

                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 :)

                --
                -------------------------------------------------------------------
                Peter Maas, M+R Infosysteme, D-52070 Aachen, Tel +49-241-93878-0
                E-mail 'cGV0ZXIubWFhc0 BtcGx1c3IuZGU=\ n'.decode('base 64')
                -------------------------------------------------------------------

                Comment

                • JanC

                  #9
                  Re: os.path.islink( )

                  Peter Maas schreef:
                  [color=blue]
                  > 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 :)[/color]

                  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... ;-)


                  --
                  JanC

                  "Be strict when sending and tolerant when receiving."
                  RFC 1958 - Architectural Principles of the Internet - section 3.9

                  Comment

                  Working...