umask option for tarfile extract

Discussion in 'Python' started by Faik Uygur, Jun 15, 2006.

  1. Faik Uygur

    Faik Uygur Guest

    Hello,

    While extracting a tar file, is there a way to give an umask option for
    creating the non-existing upper directories of the file within the tar
    archive.

    The default behaviour is to create the directories with 0777 permission bits.

    Code taken from tarfile.py of python version 2.4.3:

    # Create all upper directories.
    upperdirs = os.path.dirname(targetpath)
    if upperdirs and not os.path.exists(upperdirs):
    ti = TarInfo()
    ti.name = upperdirs
    ti.type = DIRTYPE
    ti.mode = 0777
    ^^^^^^
    ti.mtime = tarinfo.mtime
    ti.uid = tarinfo.uid
    ti.gid = tarinfo.gid
    ti.uname = tarinfo.uname
    ti.gname = tarinfo.gname
    try:
    self._extract_member(ti, ti.name)
    except:
    pass

    Regards,
    - Faik
    Faik Uygur, Jun 15, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Daniel Berger

    umask vs umask

    Daniel Berger, Apr 13, 2008, in forum: Ruby
    Replies:
    8
    Views:
    127
    Heesob Park
    Apr 16, 2008
  2. Antoon Pardon

    3.2 can't extract tarfile produced by 2.7

    Antoon Pardon, Dec 26, 2012, in forum: Python
    Replies:
    0
    Views:
    143
    Antoon Pardon
    Dec 26, 2012
  3. Steven W. Orr
    Replies:
    0
    Views:
    154
    Steven W. Orr
    Dec 27, 2012
  4. Ian Kelly
    Replies:
    0
    Views:
    126
    Ian Kelly
    Dec 27, 2012
  5. Ian Kelly
    Replies:
    0
    Views:
    99
    Ian Kelly
    Dec 27, 2012
Loading...

Share This Page