g_rename() problem on Windows (and suggested remedy)



Hi there - I've been using Glib for Windows programming for over a year and am very pleased with it.  I'm still on the version I first downloaded (2.24) but I've no particular objection to upgrading if this problem's already been fixed....

The problem itself is that 'g_rename()' only works properly (in the Windows version) if there are no open handles to the file being renamed.  On Linux, I think a file can be renamed at any time - even if some process already has it open.   A handle is a handle and shouldn't care about what the file is actually called.

AFAICT the problem on Windows is caused by the fact that g_open() uses _wopen() for opening the file.  Perhaps a better choice would have been CreateFile() because it allows files to be opened with permission for "shared deletion and shared renaming".  This would in theory allow g_rename() to work the same on Windows as on Linux.

Of course, g_open(), g_rename() and numerous other functions would need to be re-written because the file handles created by CreateFile aren't compatible with those created by _wopen() AFAIK.  However, I don't think it would be massively complicated.

I just wondered if the above approach has already been considered and/or rejected for some reason?  Or if it's already been done in a later version, in which case I'll upgrade.  Thanks.

John


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