HTCondor Project List Archives



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

Re: [Condor-devel] same_file util function?



On 4/15/05, Colin Stolley <stolley@xxxxxxxxxxx> wrote:
> 
> >I want to use it for recursively handling LOCAL_CONFIG_FILE, and to
> >use it to avoid cycles. I'd rather check to see if they're the same file
> >instead of doing a strcmp (or stricmp) on the filename, since that's not
> >particularly great.
> >
> >On unix I'd probably just look at the file and check it's device and
> >inode number, which is probably Good Enough(tm), but I have no idea what
> >I'd do on Win32.
> >
> >
> I'd hazard a guess that you could get the UNC paths and volume serial
> numbers and compare those. I may be forgetting some corner cases that
> Matt already thought of though.
> 
> See GetFileInformationByHandle() and WNetGetUniversalName() if you want.


That may well be GoodEnough however multiple unc roots can exist for
the same file, I do not know which one the WNetGetUniversalName()
returns or even if it is consistent :(

One somewhat hacky approach would be, when opening the file for
reading specify Share.None. (pretty sure this locks it even to the
same process)

Then when you hit a recursive definition you will be stopped (and do a
check to see if the filenames are the same even if not the
directories.

Obviously false positive if someone else has an open handle on the file...

Matt