[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] Longfilename support functions?



Hi,

On Wed, Jun 07, 2000 at 03:00:03PM +0200, Stanislav Opichal wrote:
> > > > > You could use Fxattr() (with "follow links" flag on) on the
> > > file. If dev
> > > > > and index are identical to an already opened group's file,
> > > don't open it
> > > > > again. This will not only work for different cases in filenames on
> > > > > filesystems not regarding case, but also for symbolic links.
> > >
> > > Will this work with filesystems like TOS/VFAT (and both on MiNT and
> Magic)
> > > that don't record a file index?
> >
> > This will not work for filesystems where Fxattr exists, but the file index
> > is not filled properly. AFAIK, only TOSFS under MiNT would be affected
> > (maybe WINDOWS-FS under MagiCPC as well).
> 
> So, again, how should I do a "unique" file detection running in any OS and
> on any FS???

Find out if Fxattr() if available always fills out the field st_name in
the "correct" for case-preserving file-systems.  I think it is legal to
assume that if Fxattr is not available, then only case-insensitive
file-systems are supported.  But if Fxattr returns the real case, then the
following should work:

First "normalize" the path name either with realpath() from a recent
MiNTLib (like I suggested before) or write your own routine for filename
normalization.  If the normalized filenames match you have a duplicate, if
not there is still the possibility of a hard link.  To detect a hard link
it is legal to compare the indices because if the file system supports
hard links then it also records a real file index.  This is bomb-proof
if Fxattr behaves like I assume (but remember that this is - at least
under MiNT - a filesystem-dependent and not a kernel-dependent feature).

Another possibility: Hash the file contents and only remember the
checksum.  This will lose if somebody changed the file contents behind
your back but maybe this is really an interesting feature.  In QED I often
miss the possibility to open a file twice (in order to compare my modified
version with the original file).

That leads me to a new idea, read "Hash filenames for index" ...

Ciao

Guido
-- 
http://www.stud.uni-saarland.de/
Send your spam to president@whitehouse.gov and your replies to
mailto:guido at freemint dot de