inode number in windows XP

Discussion in 'Python' started by asit, Jan 25, 2008.

  1. asit

    asit Guest

    why this program shows ambiguous behavior ??

    import os
    import stat
    import time
    #import types

    file_name=raw_input("Enter file name : ")
    print file_name, "information"
    st=os.stat(file_name)
    print "mode", "=>", oct(stat.S_IMODE(st[stat.ST_MODE]))

    print "type","=>",
    if stat.S_ISDIR(st[stat.ST_MODE]):
    print "DIReCTORY"
    elif stat.S_ISREG(st[stat.ST_MODE]):
    print "REGULAR"
    elif stat.S_ISLINK(st[stat.ST_MODE]):
    print "LINK"

    print "file size", "=>",st[stat.ST_SIZE]
    print "inode number", "=>",st[stat.ST_INO]
    print "device inode resides on", "=>",st[stat.ST_DEV]
    print "number of links to this inode", "=>",st[stat.ST_NLINK]
    print "last accessed", "=>", time.ctime(st[stat.ST_ATIME])
    print "last modified", "=>", time.ctime(st[stat.ST_MTIME])
    print "inode changed", "=>", time.ctime(st[stat.ST_CTIME])



    i ran this program in Winows XP SP2 in python 2.5.
     
    asit, Jan 25, 2008
    #1
    1. Advertising

  2. Steven D'Aprano, Jan 25, 2008
    #2
    1. Advertising

  3. On 25 ene, 10:28, asit <> wrote:

    > why this program shows ambiguous behavior ??
    >
    > st=os.stat(file_name)
    > print "file size", "=>",st[stat.ST_SIZE]
    > print "inode number", "=>",st[stat.ST_INO]
    > print "device inode resides on", "=>",st[stat.ST_DEV]
    > print "number of links to this inode", "=>",st[stat.ST_NLINK]
    >
    > i ran this program in Winows XP SP2 in python 2.5.


    Using my recently repaired crystal ball, I see that you don't get what
    you expect for some of those fields. All files sharing the same inode,
    by example.
    The usual file systems used by Windows aren't built around the inode
    concept, they're different, so there is no "inode number" to report,
    among other things. From http://docs.python.org/lib/os-file-dir.html
    "On Windows, some items are filled with dummy values". Don't rely on
    anything but st_mode, st_size, and st_[cma]time, and perhaps a few
    more for fstat.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Jan 25, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jan Stap
    Replies:
    16
    Views:
    549
    E. Robert Tisdale
    Nov 12, 2003
  2. removing file by inode

    , Mar 23, 2006, in forum: Python
    Replies:
    5
    Views:
    589
    Arne Ludwig
    Mar 23, 2006
  3. kerb
    Replies:
    4
    Views:
    354
  4. open file by inode?

    , May 28, 2006, in forum: Perl Misc
    Replies:
    6
    Views:
    336
  5. Replies:
    4
    Views:
    273
    Nobody
    Jan 31, 2013
Loading...

Share This Page