Skip Menu |

This queue is for tickets about the Win32-File CPAN distribution.

Report information
The Basics
Id: 47574
Status: open
Priority: 0/
Queue: Win32-File

People
Owner: Nobody in particular
Requestors: xrmb-ml01 [...] gmx.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.06
Fixed in: 0.06



I'm using active state perl 5.10.1004, and when I try to use SetAttributes to set the compress flag I get a true return value (indicating ok?), but the file is not compressed.
CC: libwin32 [...] perl.org
Subject: Re: [rt.cpan.org #47574]
Date: Sun, 05 Jul 2009 07:52:10 -0700
To: bug-Win32-File [...] rt.cpan.org
From: Bill Luebkert <dbecoll [...] roadrunner.com>
xrmb via RT wrote: Show quoted text
> Sat Jul 04 22:31:27 2009: Request 47574 was acted upon. > Transaction: Ticket created by xrmb > Queue: Win32-File > Subject: (No subject given) > Broken in: 0.06 > Severity: Critical > Owner: Nobody > Requestors: xrmb-ml01@gmx.net > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=47574 > > > > I'm using active state perl 5.10.1004, and when I try to use > SetAttributes to set the compress flag I get a true return value > (indicating ok?), but the file is not compressed.
I'd call it a lack of documentation - Set doesn't allow COMPRESS. Note 'Remarks' section of manual page: ---------------------------------------------------------------------------------------------- The SetFileAttributes function sets a file's attributes. BOOL SetFileAttributes ( LPCTSTR lpFileName, // address of filename DWORD dwFileAttributes // address of attributes to set ); Parameters lpFileName Points to a string that specifies the name of the file whose attributes are to be set. Windows 95: This string must not exceed MAX_PATH characters. Windows NT: There is a default string size limit for paths of MAX_PATH characters. This limit is related to how the SetFileAttributes function parses paths. An application can transcend this limit and send in paths longer than MAX_PATH characters by calling the wide (W) version of SetFileAttributes and prepending "\\?\" to the path. The "\\?\" tells the function to turn off path parsing; it lets paths longer than MAX_PATH be used with SetFileAttributesW. This also works with UNC names. The "\\?\" is ignored as part of the path. For example, "\\?\C:\myworld\private" is seen as "C:\myworld\private", and "\\?\UNC\bill_g_1\hotstuff\coolapps" is seen as "\\bill_g_1\hotstuff\coolapps". dwFileAttributes Specifies the file attributes to set for the file. This parameter can be a combination of the following values. However, all other values override FILE_ATTRIBUTE_NORMAL. Value Meaning FILE_ATTRIBUTE_ARCHIVE The file is an archive file. Applications use this value to mark files for backup or removal. FILE_ATTRIBUTE_NORMAL The file has no other attributes set. This value is valid only if used alone. FILE_ATTRIBUTE_HIDDEN The file is hidden. It is not included in an ordinary directory listing. FILE_ATTRIBUTE_READONLY The file is read-only. Applications can read the file but cannot write to it or delete it. FILE_ATTRIBUTE_SYSTEM The file is part of the operating system or is used exclusively by it. FILE_ATTRIBUTE_TEMPORARY The file is being used for temporary storage. File systems attempt to keep all of the data in memory for quicker access rather than flushing the data back to mass storage. A temporary file should be deleted by the application as soon as it is no longer needed. Return Value If the function succeeds, the return value is TRUE. If the function fails, the return value is FALSE. To get extended error information, call GetLastError. Remarks You cannot use the SetFileAttribute function to set a file's compression state. Setting FILE_ATTRIBUTE_COMPRESSED in the dwFileAttributes parameter does nothing. Use the DeviceIoControl function and the FSCTL_SET_COMPRESSION operation to set a file's compression state. ----------------------------------------------------------------------------------------------
Subject: Re: [rt.cpan.org #47574]
Date: Mon, 6 Jul 2009 18:21:37 +1000
To: <bug-Win32-File [...] rt.cpan.org>, <libwin32 [...] perl.org>
From: "Sisyphus" <sisyphus1 [...] optusnet.com.au>
Show quoted text
----- Original Message ----- From: "xrmb via RT" <bug-Win32-File@rt.cpan.org>
> I'm using active state perl 5.10.1004, and when I try to use > SetAttributes to set the compress flag I get a true return value > (indicating ok?), but the file is not compressed.
Win32::File::SetAttributes() calls the Windows API function SetFileAttributesA(), and that function is not capable of enacting compression of the file or of setting the compression attributes flag. This is documented at http://msdn.microsoft.com/en-us/library/aa365535(VS.85).aspx and should probably be documented in the Win32::File pod as well. (I think it's the lack of documentation in the Win32::File pod that's the bug.) The constant COMPRESSED, exported by Win32::File is really only of use with Win32::File::GetAttributes(). The same applies to DIRECTORY. Although SetAttributes returns true, I think you should find (by using GetAttributes) that the 'compressed' attribute was *not*, in fact, set. Seems odd that SetAttributes() returns true when trying (and failing) to set COMPRESSED and DIRECTORY attributes .... it does so simply because that's what FileSetAttributesA() returns. Cheers, Rob
CC: <libwin32 [...] perl.org>
Subject: RE: [rt.cpan.org #47574]
Date: Mon, 6 Jul 2009 12:07:20 -0700
To: "'Bill Luebkert'" <dbecoll [...] roadrunner.com>, <bug-Win32-File [...] rt.cpan.org>
From: "Jan Dubois" <jand [...] activestate.com>
On Sun, 05 Jul 2009, Bill Luebkert wrote: Show quoted text
> > I'm using active state perl 5.10.1004, and when I try to use > > SetAttributes to set the compress flag I get a true return value > > (indicating ok?), but the file is not compressed.
> > I'd call it a lack of documentation - Set doesn't allow COMPRESS.
The SetFileAttributes() function in Windows indeed doesn't support it, but that doesn't mean that the Win32::SetFileAttributes() one can't. We could just implement it behind the scenes and have it work transparently instead of expecting the user to learn about and use another module to do this. The question then becomes: what is the complete set of missing functionality and can we implement it all using the existing interface? For example, setting the COMPRESSED attribute on a directory will not automatically compress all files stored in it. It will only cause *new* files added to the directory to be compressed. Therefore, would we also need an interface to actually compress/uncompress a whole directory tree? If yes, does this belong into Win32::File, and how should the interface look like? Cheers, -Jan
From: xrmb-ml01 [...] gmx.net
For me as the end-user it doesn't matter what is done. I could survive with an updated documentation saying you cant set the compress attribute, and I keep my system("compact /C ...") in there. For me as a developer and perl lover I'd like to have it working... but if its only for me, dont bother there are more important things in life :)