Open a gz file using Minizip Library - gzip

I'm trying to open a gz file with Minizip library (built on zlib).
Here is the code:
......
......
unzFile uf = unzOpen("MyFile.gz");
......
But Visual Studio 2013 crashes with this message:
Debug Assertion Failed!
file open.c
line 98
Expression: ("Invalid file open mode",0)
What could it mean?

A .gz file is a single file that's been compressed.
A .zip file is a compressed archive; i.e. a hierarchical structure of compressed files.
tl;dr minizip doesn't support .gz files as it's not a .zip file.

Related

How to add icons in PyQt5 app in flatpak?

I have small PyQt5 app: https://github.com/taunoe/tauno-serial-plotter
I got all the functionality to work on flatpak but icons are a problem. Tried different things, but i have no clue how to make them showup.
(base) taunoerik#pop-os:~/Documents/MyGitHub/tauno-serial-plotter$ flatpak run
org.flatpak.Tauno-serial-plotter /app/bin/python3
Gtk-Message: 15:15:29.163: Failed to load module "appmenu-gtk-module"
Gtk-Message: 15:15:29.199: Failed to load module "canberra-gtk-module"
Gtk-Message: 15:15:29.199: Failed to load module "canberra-gtk-module"
Qt: Session management error: None of the authentication protocols specified are supported
qt.svg: Cannot open file '/home/taunoerik/img/tauno-plotter.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/tauno-plotter.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/arrow_down.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/arrow_down.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/arrow_down.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/arrow_down.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/plus.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/plus.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/minus.svg', because: No such file or directory
qt.svg: Cannot open file '/home/taunoerik/img/minus.svg', because: No such file or directory
File names should be absolute. Like:
filename = os.path.join(os.path.dirname(__file__), 'icons/file.svg')
Note relative like this: filename = './icons/file.svg'

Compression is not working in ZLib library

I want to zip a already existing file in a directory, I am calling deflate method
int def(FILE *source, FILE *dest, int level) of ZLib library and I'm getting zipped file (making a file with .zip extension), but the problem is when I'm trying to unzip it by double clicking, I'm getting corrupted file though the return value is Z_OK.
PS: want to compress file not data. Any Help???
zlib does not produce the zip format. You would need to generate your own zip headers and trailers around the deflate compressed data produced by zlib.

Rename files without extension with AutoHotkey

I am trying to add .pdf to the filename of files without extension in a folder.
It is possible to rename for example txt files to pdf using the following command:
FileMove, %SourceFolder%\*.txt, %SourceFolder%\*.pdf
Also, I can add .pdf to all files by:
FileMove, %SourceFolder%\*, %SourceFolder%\*.pdf
But I only want to target only the files without extension. How to do this?
Example
As suggested by kasper and MCL
SetWorkingDir %A_ScriptDir%
Loop, files\*
{
if !StrLen(A_LoopFileExt) ; if no file extension
{
FileMove,%A_LoopFileFullPath%,%A_LoopFileFullPath%.pdf ;rename file
}
}
see [Loop, FilePattern]
see [FileMove]
#kasper, You can use windows command prompt to rename the file as well as change the extension.
Just navigate to the file directory and use command
ren abc.txt abc.pdf
Here abc.txt is old file and abc.pdf is pdf of abc.txt.

How should you write the prep stage when the source file is a .gz?

The setup macro cannot handle a .gz file. I think I should extract the source .gz file without deleting it (decompressing with gzip deletes the file normally), and then manually cd into the uncompressed directory.
I am wondering if this is a good solution.
You cannot extract a directory from just a .gz file. That would be a .tar.gz file. The extraction of a .tar.gz file does not normally delete the .tar.gz file.

Apache Config Mime Types: xlsx files are being interpreted as zip files on download, why?

Background: For some reason, whenever a user tries to open an xslx (excel 2007) file from our intranet using MSIE, the file download dialog interprets it as a "zip" file.
Admittedly, xslx files really are zip files, but we don't want that behavior. Just open in Excel, please.
Question:
Firefox, OTOH, opens the files normally. Is it possible that the fault is my apache configs? or is this a client-browser-only issue?
You must add some new MIME-TYPES on the web-server-side.
See the comment-thread on this windowsnerd.com page (from 2009):
Add this to a .htaccess file and throw it on your site: AddType
application/vnd.openxmlformats .docx .pptx .xlsx .xltx . xltm .dotx
.potx .ppsx
Should fix many of the problems.
Alternatively, you can add this to the mime.types file located in the config directory of your Apache web server
application/vnd.ms-word.document.macroEnabled.12 .docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12 potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.ms-excel.template.macroEnabled.12 xltm
http://www.webdeveloper.com/forum/showthread.php?t=162526
The reason is IE's strange MIME sniffing behaviour: http://msdn.microsoft.com/en-us/library/ms775147.aspx. It basically tries to determine to the file type of a file by looking into its contents, somehow like Linux's file tool.