Help me clean up this method

A

Ara.T.Howard

Ara.T.Howard wrote:



Generally speaking, File.stat on Windows is not reliable. Too many of that
Stat members are either meaningless or wrong. Revamping it is on my TODO
list for the win32-file package.

thanks daniel, some searching lead me to suspect this. seems like a severe
limitation since 'ino' is the only way to determine if a file is unique -
bummer. reading over the source leads me to think that the issue is simply a
casting bug - but that the information should be there for ruby (in the
inode). does this sound correct?

cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
A

Ara.T.Howard

Ara.T.Howard wrote:



For a good summary of the problems with calculating the size of a directory
(on Windows) see
http://blogs.msdn.com/oldnewthing/archive/2004/12/28/336219.aspx.

indeed.

we've got a script here (dirsum) that does essentially all the things outlined
- especially checking compressed files - for monitoring data volumes. the
problem is much trickier that one would assume.

cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
D

Daniel Berger

Ara.T.Howard said:
indeed.

we've got a script here (dirsum) that does essentially all the things outlined
- especially checking compressed files - for monitoring data volumes. the
problem is much trickier that one would assume.

By all means, please share. I'd be happy to add a Dir.size method to
win32-dir. :)

Regards,

Dan
 
D

Daniel Berger

Ara.T.Howard said:
hmmm. you are right. this seems to be a bug in ruby - amazing that no-one
has seen it before though? it looks like this might be in rb_uint2big but i'm
kinda guessing since i can't compile on windows myself and therefore can't
look at config.h - except in cygwin, which works. anyhow - the numbers spat
out in cygwin are huge - so i'm gussing the bug is here. perhaps someone out
there with a windows compiler tool-chain could examine?

so, just to re-state the bug: File::stat(anypath).ino is always zero under the
one click installer, but not under cygwin using the default or compiling by
hand.

cheers.

-a

Upon further review, this is not a bug. From the MSDN documentation on
the st_ino struct member:

"The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or
NTFS file systems."

See
http://msdn.microsoft.com/library/d...tat.2c_._wstat.2c_._stati64.2c_._wstati64.asp
for more details.

Regards,

Dan
 
A

Ara.T.Howard

Upon further review, this is not a bug. From the MSDN documentation on the
st_ino struct member:

"The inode, and therefore st_ino, has no meaning in the FAT, HPFS, or NTFS
file systems."

See
http://msdn.microsoft.com/library/d...tat.2c_._wstat.2c_._stati64.2c_._wstati64.asp
for more details.

thanks for that! any idea how to tell if a file is unique on that file system
then? eg, given a filename and it's stat - how can you show that it is not
some other file? nothing but File::expand_path(pathname)?

cheers.

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
N

nobu.nokada

Hi,

At Fri, 23 Sep 2005 07:01:39 +0900,
Ara.T.Howard wrote in [ruby-talk:157179]:
thanks for that! any idea how to tell if a file is unique on that file system
then? eg, given a filename and it's stat - how can you show that it is not
some other file? nothing but File::expand_path(pathname)?

eban has suggested File.identical? for that purpose.
 
A

Ara.T.Howard

eban has suggested File.identical? for that purpose.

that sounds great - but how would it be implemented on windows if there is no
unique field in the inode?

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
N

nobu.nokada

Hi,

At Fri, 23 Sep 2005 08:49:15 +0900,
Ara.T.Howard wrote in [ruby-talk:157186]:
that sounds great - but how would it be implemented on windows if there is no
unique field in the inode?

Of course, comparing expanded pathes ;)
 
A

Ara.T.Howard

Hi,

At Fri, 23 Sep 2005 08:49:15 +0900,
Ara.T.Howard wrote in [ruby-talk:157186]:
that sounds great - but how would it be implemented on windows if there is no
unique field in the inode?

Of course, comparing expanded pathes ;)

lol!

that's fine - but does that work with hard/soft links? i know next to nothing
about windows but remember something about it having something like hard links
and:

harp:~ > touch a
harp:~ > ln a b
harp:~ > ruby -e'p File::expand_path("b")'
"/home/ahoward/b"

so that's wouldn't work on unix - maybe it does on windows?

-a
--
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze. --Nagarjuna
===============================================================================
 
A

Austin Ziegler

Of course, comparing expanded pathes ;)

1. There is, at least on NTFS, a unique file identifier that is
somehow available. Don't ask me how right now, but I should be able to
find out in a few days (work-related stuff).

2. Files cannot be hardlinked on any Windows filesystem. Directories
can be hardlinked on NTFS5 systems.

-austin
 
S

Sean O'Halpin

1. There is, at least on NTFS, a unique file identifier that is
somehow available. Don't ask me how right now, but I should be able to
find out in a few days (work-related stuff).

The file's unique ID is assigned by the system and is stored in the
nFileIndexHigh and nFileIndexLow fields of BY_HANDLE_FILE_INFORMATION
(API call
is GetFileInformationByHandle())
(source: MSDN)
2. Files cannot be hardlinked on any Windows filesystem. Directories
can be hardlinked on NTFS5 systems.
Erm.. they can - use CreateHardLink() - but there is no shell support for t=
hem
(so that users won't delete real files by accident I guess).

Directories ~cannot~ be hard-linked (but apparently you can create
'junction points' - a
kind of soft link - though I've never used them myself).

Regards,
Sean
 
N

nobu.nokada

Hi,

At Fri, 23 Sep 2005 11:16:48 +0900,
Sean O'Halpin wrote in [ruby-talk:157221]:
The file's unique ID is assigned by the system and is stored in the
nFileIndexHigh and nFileIndexLow fields of BY_HANDLE_FILE_INFORMATION
(API call
is GetFileInformationByHandle())
(source: MSDN)

Thank you for the info. I've forgotton it. It will be used in
the case it is available.
Erm.. they can - use CreateHardLink() - but there is no shell support for them
(so that users won't delete real files by accident I guess).

Mswin32 and mingw32 version rubys support it.
Directories ~cannot~ be hard-linked (but apparently you can create
'junction points' - a
kind of soft link - though I've never used them myself).

Right. It wouldn't be identical to the original.
 

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
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top