Menu

issue with zip fopen/CloseHandle

2022-09-29
2022-11-20
  • E.Naumovich

    E.Naumovich - 2022-09-29

    Hi,
    looks like zip does not close file if it was open using handle from fopen on Windows. Probably it should be fopen/fclose pair, not fopen/CloseHandle.
    It is near line 2532 in zip.cpp file.
    Regards.

     
  • Alexandr Belyak

    Alexandr Belyak - 2022-10-05

    Hi,
    I apologize for the long silence, I had problems accessing the site.
    Why did you decide that zip does not close file if it was open using handle from fopen on Windows?
    I tried such a simple test:

    CWorkbook book( "Incognito" );
    ...
    FILE * f = fopen( "Test.xlsx", "w" );
    if( f == NULL )
    {
        std::cout << "The book saving has been failed" << std::endl;
        return 0;
    }
    book.Save( f, true );
    std::cout << "The book has been saved successfully" << std::endl;
    while( true )
        ;
    

    When the program is in an infinite loop, the file "Test.xlsx" looks closed. I can open it in Excel or delete it.
    Tested on Windows 10 Pro 21H1 with MinGW 7.3.0 32-bit for C++.

     
  • E.Naumovich

    E.Naumovich - 2022-10-07

    Hi,
    in my case it looked like this: I am using software which produced xlsx reports. During one session it might be generated something like 5-10 files. They might be opened in Excel, but cannot be saved because "someone else also opened them". After I close software, this problem disappears. If I'm using "book.Save( f, false )" and closing reports separately, by fclose, it also do not appear.
    I'm tested it with Win10 Pro 21H1, gcc 12.1 MinGW_w64 v10 UCRT 32bit (https://winlibs.com/).
    OS-related difference is that I saved reports on network drive.

     
  • Alexandr Belyak

    Alexandr Belyak - 2022-10-26

    Hi,
    Sorry for the long silence for various reasons.
    Perhaps is the problem related to antivirus software or similar security software?
    Just in case, I redesigned the library to call the fclose function directly. Please check if possible.

     
    • E.Naumovich

      E.Naumovich - 2022-11-17

      Hi,
      I tried new version, very briefly. It looks like that this problem fixed. Thanks!
      I also suggest to add Scratch to CMake. Practically there are no reasons to keep it separately.

       
      • Alexandr Belyak

        Alexandr Belyak - 2022-11-20

        Hi,
        Done :-) Thanks for your help!

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.