[Python-Dev] zipfile.py - detect if zipinfo is a dir (fwd)

Skip Montanaro skip@pobox.com (Skip Montanaro)
Tue, 20 Mar 2001 09:19:54 -0600 (CST)


--sKyh7lSXYH
Content-Type: text/plain; charset=us-ascii
Content-Description: message body text
Content-Transfer-Encoding: 7bit

Not sure why I received this note.  I am passing it along to Jim Ahlstrom
and python-dev.

Skip


--sKyh7lSXYH
Content-Type: message/rfc822
Content-Description: forwarded message
Content-Transfer-Encoding: 7bit

Return-Path: <nobody@sourceforge.net>
Received: from dolly2.pobox.com (spamsvr.pobox.com [208.210.124.100])
	by manatee.mojam.com (8.11.0/8.11.0) with ESMTP id f2KEcvl01634
	for <skip@manatee.mojam.com>; Tue, 20 Mar 2001 08:38:57 -0600
Received: from dolly2 (localhost.localdomain [127.0.0.1])
	by dolly2.pobox.com (Postfix) with ESMTP id 8FD1025E99
	for <skip@manatee.mojam.com>; Tue, 20 Mar 2001 09:38:57 -0500 (EST)
Received: from potrero.mojam.com (ns2.mojam.com [207.20.37.91])
	by dolly2.pobox.com (Postfix) with ESMTP id 9EC1925EAC
	for <skip@pobox.com>; Tue, 20 Mar 2001 09:38:56 -0500 (EST)
Received: from usw-sf-netmisc.sourceforge.net (usw-sf-sshgate.sourceforge.net [216.136.171.253])
	by potrero.mojam.com (8.9.3/8.9.3) with ESMTP id GAA31338
	for <skip@mojam.com>; Tue, 20 Mar 2001 06:38:56 -0800
Received: from usw-sf-web2-b.sourceforge.net
	([10.3.1.6] helo=usw-sf-web2.sourceforge.net ident=mail)
	by usw-sf-netmisc.sourceforge.net with esmtp (Exim 3.22 #1 (Debian))
	id 14fNHk-000169-00
	for <skip@mojam.com>; Tue, 20 Mar 2001 06:38:56 -0800
Received: from nobody by usw-sf-web2.sourceforge.net with local (Exim 3.22 #1 (Debian))
	id 14fNIF-0002rT-00
	for <skip@mojam.com>; Tue, 20 Mar 2001 06:39:27 -0800
Message-Id: <E14fNIF-0002rT-00@usw-sf-web2.sourceforge.net>
From: Stephane Matamontero <dev1.gemodek@t-online.de>
Sender: nobody <nobody@usw-pr-web.sourceforge.net>
To: skip@mojam.com
Subject: zipfile.py - detect if zipinfo is a dir 
Date: Tue, 20 Mar 2001 06:39:27 -0800

Hi,

I am just working with the zipfile.py module and found out
a way to check if a zipinfo object is a dir:
I created 2 testzipfiles on Win2000 and Linux with info-zip.

I checked on Python 2.0 on Win2000 the following code
in a file called testview.py (my file)
The constants were taken from io.h of MSVC 6.0, the 
isdirzipinfo() function which accepts a zipinfo object
works at least under Win2000/Linux.

Perhaps you can integrate the code in a future release.

Bye

 Stephane

-------------------------- code follows ----------------

#/* File attribute constants for _findfirst() */

_A_NORMAL= 0x00   # /* Normal file - No read/write 
restrictions */
_A_RDONLY= 0x01   # /* Read only file */
_A_HIDDEN= 0x02   # /* Hidden file */
_A_SYSTEM= 0x04   # /* System file */
_A_SUBDIR= 0x10   # /* Subdirectory */
_A_ARCH=   0x20   # /* Archive file */

def isdirzipinfo(zi):
    isdir=((zi.external_attr & 0xff) & _A_SUBDIR) !=0
    return isdir




--sKyh7lSXYH--