This website uses cookies. By browsing this website, you consent to the use of cookies. Learn more.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
- Flexera Software Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Windows file compression
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
mary_v
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 20, 2010
04:44 AM
Windows file compression
How am i able to detect if a file is compressed via windows file compression?
I know there exists an attribute on ntfs file systems but am not able to retrieve this piece of information via GetFileInfo in custom actions.
Any ideas how to achieve this?
mary
I know there exists an attribute on ntfs file systems but am not able to retrieve this piece of information via GetFileInfo in custom actions.
Any ideas how to achieve this?
mary
10 Replies
mary_v
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 21, 2010
03:05 AM
Re: Windows file compression
well - usually i want to execute functions only if necessary...
my situation is as follows:
while updating sql databases (alter tables etc), sometimes they are compressed and my updates fails - i want to check actually BEFORE updating wether the databases are compressed.
then i would have to stop the sql server which maybe shuts down other apps ...
mary
my situation is as follows:
while updating sql databases (alter tables etc), sometimes they are compressed and my updates fails - i want to check actually BEFORE updating wether the databases are compressed.
then i would have to stop the sql server which maybe shuts down other apps ...
mary
MrTree
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 21, 2010
07:51 AM
Re: Windows file compression
sure this is not sexy, but I don't know an IS function that shows you the status of the file.
The comapct.exe included in Windows works fine for such operations, it doesn't create errors if the file is not compacted.
LaunchAppAndWait(WINSYSDIR ^ "compact.exe", "/U /I "+TARGETDIR ^ "SQLDB.MDF", WAIT|LAAW_OPTION_HIDDEN);
helps me to prevent errors with compacted SQL DBs.
If you have to check the file status before you use compact.exe you may be use a Windows dll function.
Like this:
------------------------------------------------------------------------------
prototype int Kernel32.GetFileAttributes(string);
export prototype BOOL IsFileCompressed(string);
function BOOL IsFileCompressed(filename)
int attributes, nResult;
begin
nResult = UseDLL(WINSYSDIR ^ "Kernel32.dll");
if(nResult != 0) then
MessageBox("Unable to load " + WINSYSDIR ^ "Kernel32.dll.", SEVERE);
exit;
endif;
attributes = GetFileAttributes(filename);
UnUseDLL(WINSYSDIR ^ "Kernel32.dll");
return (attributes & 0x800) == 0x800;
end;
------------------------------------------------------------------------------
and call:
if(IsFileCompressed("C:\\Temp\\test.txt")) then
//decompress file
endif;
The comapct.exe included in Windows works fine for such operations, it doesn't create errors if the file is not compacted.
LaunchAppAndWait(WINSYSDIR ^ "compact.exe", "/U /I "+TARGETDIR ^ "SQLDB.MDF", WAIT|LAAW_OPTION_HIDDEN);
helps me to prevent errors with compacted SQL DBs.
If you have to check the file status before you use compact.exe you may be use a Windows dll function.
Like this:
------------------------------------------------------------------------------
prototype int Kernel32.GetFileAttributes(string);
export prototype BOOL IsFileCompressed(string);
function BOOL IsFileCompressed(filename)
int attributes, nResult;
begin
nResult = UseDLL(WINSYSDIR ^ "Kernel32.dll");
if(nResult != 0) then
MessageBox("Unable to load " + WINSYSDIR ^ "Kernel32.dll.", SEVERE);
exit;
endif;
attributes = GetFileAttributes(filename);
UnUseDLL(WINSYSDIR ^ "Kernel32.dll");
return (attributes & 0x800) == 0x800;
end;
------------------------------------------------------------------------------
and call:
if(IsFileCompressed("C:\\Temp\\test.txt")) then
//decompress file
endif;
Highlighted
mary_v
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 21, 2010
11:45 AM
Re: Windows file compression
thanks for your reply - my approach is quite similar
as a workaround i also thought about using compact in combination with findstr to get the result in only one line and then parse this line to extract the number of compressed files.
but i would do this only if i can't use the GetFileAttributeEx function in kernel32.dll
Any idea how to call it or should i try your little example first?
i must confess - i'll give it a try after the weekend ;)
mary
as a workaround i also thought about using compact in combination with findstr to get the result in only one line and then parse this line to extract the number of compressed files.
but i would do this only if i can't use the GetFileAttributeEx function in kernel32.dll
Any idea how to call it or should i try your little example first?
i must confess - i'll give it a try after the weekend ;)
mary
mary_v
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
May 28, 2010
07:58 AM
Re: Windows file compression
@MrTree:
thanks for your brief example - obviously i didn't read any further last week. :o
It does exactly what i want!
thanks again :rolleyes:
mary
thanks for your brief example - obviously i didn't read any further last week. :o
It does exactly what i want!
thanks again :rolleyes:
mary
MrTree
Pilgrim
- Mark as New
- Subscribe
- Mute
- Permalink
- Email to a Friend
- Report Inappropriate Content
Jun 08, 2010
09:48 AM
Re: Windows file compression
mary_v wrote:
... just to make everything right:
i don't have to load and unload kernel32.dll, right?!
mary
that's right, cause every Windows Programm even InstallShield needs/loads kernel32.dll.