[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

inode number in windows XP

asit

1/25/2008 12:29:00 PM

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.
2 Answers

Steven D'Aprano

1/25/2008 12:43:00 PM

0

On Fri, 25 Jan 2008 04:28:43 -0800, asit wrote:

> why this program shows ambiguous behavior ??


You should read this page, it will help you solve your problem:

http://catb.org/~esr/faqs/smart-ques...



--
Steven

Gabriel Genellina

1/25/2008 5:50:00 PM

0

On 25 ene, 10:28, asit <lipu...@gmail.com> 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-fil...
"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