in reply to Re: Re: Re: Re: unlink & rename in Win32
in thread unlink & rename in Win32

Seems pretty clear to me:

10:57:49 Perl Open E:\GMS\TESTMEMBER\GMS.LOG 10:57:49 Perl Open E:\GMS\TESTMEMBER\GMS.LOG 10:57:49 Perl Close E:\GMS\TESTMEMBER\GMS.LOG 10:58:10 Perl Rename E:\GMS\TESTMEMBER\GMS.LOG
You open GMS.LOG twice, only close it once, then try to rename it (when you still have it open at least once).

The default for C programs under Win32 is to allow "read" and "write" sharing but not "delete" sharing. And if a file is currently open w/o "delete" sharing having been requested, then no one (not even the process that has the file open) is allowed to delete or even rename the file.

So you need to find which of your two file handles you are failing to close before you rename the file.

FYI, Win32API::File has more information on Win32 file sharing and ways to open files while specifying different levels of file sharing.

Elsewhere you asked about the "archive" bit. If the archive bit is set, that means that a file has been modified since the last time it was archived. That is, modifying the contents of a file sets the archive bit and many "backup" programs clear the archive bit when they copy the file. Also, many backup programs can be told to only backup files who have the archive bit set (which is where this whole scheme becomes useful).

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
This is odd
by Flame (Deacon) on Dec 04, 2001 at 02:43 UTC
    This is kinda confusing, I tried spescifically closing the file before and it didn't work... but now... it does...

    I'm kinda confused there... mabey I just closed it wrong...


    -----BEGIN GEEK CODE BLOCK-----
    Version: 3.12
    GIT d- s:++ a--- C++++ UL P+++>++++ L+ E- W++>+++ N !o K- w+ O---- M-- V--
    PS PE Y- PGP t++(+++) 5(+++)++++ X R+@ tv+ b+++ DI+ D- G e->+++ h! r-- y-
    ------END GEEK CODE BLOCK------
    Translate

    "Weird things happen, get used to it."

    Flame ~ Lead Programmer: GMS