Windows binary saga
Lubomir I. Ivanov
neolit123 at gmail.com
Fri Sep 25 15:52:35 PDT 2015
On 26 September 2015 at 00:47, Dirk Hohndel <dirk at hohndel.org> wrote:
> On Fri, Sep 25, 2015 at 02:01:54PM -0700, Dirk Hohndel wrote:
>> On Fri, Sep 25, 2015 at 12:31:37PM -0700, Dirk Hohndel wrote:
>> >
>> >
>> > > On Sep 25, 2015, at 10:23, Salvador Cuñat <salvador.cunat at gmail.com> wrote:
>> > >
>> > > Good evening.
>> > >
>> > > I can also confirm Sander's issues in Win10 with 4.4.97-74.
>> > >
>> > > - git clones remote repo fine
>> > > - changes are also saved in local repo
>> > > - local and remote are never synchronized
>> >
>> > I can reproduce this and have started debugging it. No clear idea what's going on. Right now I'm getting confusing errors that show up only when testing on Windows.
>>
>> OK, here are the two errors that I can see but that I don't quite know how
>> to fix, yet.
>>
>> a) when we set the proxy variable to "" in order to disable the proxy,
>> that works fine on Linux and Mac but causes us to get an "The parameter is
>> incorrect" error on Windows. So I need to somehow remove that parameter or
>> something. I'm working on that.
>> In a weird twist on the past, if you have set a proxy (which I had for all
>> my tests in the past because the machine on which I run these tests in a
>> VM is usually on my corporate network either because I'm in the office or
>> on a VPN), then things work - which is why I was never able to reproduce
>> this.
>
> OK, this one I have figured out. Need to clean up my fix and push but this
> is coming.
>
>> b) on Windows 10 the renaming of local git cache directory fails. I tried
>> both QFile::rename and QDir::rename. Both fail. I'll try to figure out why
>> but this is also an issue that needs to be addressed.
>
> Still no idea. Lubomir?
>
my best bet is that something has obtained an exclusive lock (e.g.
ERROR_SHARING_VIOLATION).
careful with the code bellow - make sure you have C:\test and/or play
on another drive!
include <windows.h> in the Subsurface file to be tested and use
TestRename() to obtain an error code.
------------------------------------------------------
#include <windows.h>
#include <stdio.h>
int TestRename(const char *folder1, const char *folder2)
{
// check if the folder exists
BOOL exists = FALSE;
DWORD attrib = GetFileAttributes(folder1);
if (attrib != INVALID_FILE_ATTRIBUTES && attrib & FILE_ATTRIBUTE_DIRECTORY)
exists = TRUE;
if (!exists) {
printf("folder not found or path is not a folder: %s\n", folder1);
return EXIT_FAILURE;
} else {
printf("folder found: %s\n", folder1);
}
// list of error codes:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx
DWORD errorCode;
// if this fails something has already obatained (more) exclusive
access to the folder
HANDLE h = CreateFile(folder1, GENERIC_WRITE, FILE_SHARE_WRITE |
FILE_SHARE_DELETE, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
if (h == INVALID_HANDLE_VALUE) {
errorCode = GetLastError();
printf("cannot obtain exclusive write access for folder:
%u\n", (unsigned int)errorCode );
return EXIT_FAILURE;
} else {
puts("exclusive write access obtained...closing handle!");
CloseHandle(h);
// attempt to rename
BOOL result = MoveFile(folder1, folder2);
if (!result) {
errorCode = GetLastError();
printf("rename failed: %u\n", (unsigned int)errorCode);
return EXIT_FAILURE;
}
printf("folder rename success: %s ---> %s\n", folder1, folder2);
// rename back
MoveFile(folder2, folder1);
printf("ranaming back: %s ---> %s\n", folder2, folder1);
}
return EXIT_SUCCESS;
}
int main(void)
{
// !!!CAREFUL!!!
const char *folder1 = "C:\\test"; // the folder to test
const char *folder2 = "C:\\test1"; // test rename folder -> folder2
return TestRename(folder1, folder2);
}
------------------------------------------------------
lubomir
--
More information about the subsurface
mailing list