Python Forum
Can ZipFile be used to extract hidden files?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can ZipFile be used to extract hidden files?
#1
I asked this question over on StackOverflow this morning, but don't seem to be having much luck in terms of Python help as most seem to think of it as something to do with my computer, so figured I might have more luck here.

I am creating a small utility that can be used to download and install updates for games that don't run through storefronts that automate the process. For the most part, it's been working perfectly!

As part of the testing, we've discovered that hidden files seem to confound the extraction process. It consistently results in this error:

Error:
PermissionError: [Errno 13] Permission denied: 'E:\path\hidden.txt'
I wasn't able to find much in the way of hidden files and Python interacting, but I did find this old question noting that Python itself is unable to handle hidden files in "standard" modes (like r, w, etc) due to how the underlying Win32 API is used. I tried using a similar solution for my code but had no luck. I dug a bit into the zipfile module itself to see what I could find and noticed this:

Quote:mode: The mode can be either read 'r', write 'w', exclusive create 'x', or append 'a'.

Am I right in thinking that this means there's no way to proceed from here using the zipfile module? In any case, any suggestions on how to proceed are certainly welcome!

The relevant section of code I'm using is as follows:

updateFile = zipfile.ZipFile(updateTarget, 'r')
        updateFile.extractall()
        updateFile.close()
And the full traceback is as follows:

Error:
Traceback (most recent call last): File "E:\Python 3.10\lib\threading.py", line 1009, in _bootstrap_inner self.run() File "E:\Python 3.10\lib\threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "E:\Git Repos\Prelude\main.py", line 74, in updateGame updateAction(config.patchArchive, 'patch') File "E:\Git Repos\Prelude\main.py", line 115, in updateAction if (errorHandling.localCheck(updateTarget) == False): File "E:\Git Repos\Prelude\errorHandling.py", line 26, in localCheck updateFile.extractall() File "E:\Python 3.10\lib\zipfile.py", line 1634, in extractall self._extract_member(zipinfo, path, pwd) File "E:\Python 3.10\lib\zipfile.py", line 1688, in _extract_member open(targetpath, "wb") as target: PermissionError: [Errno 13] Permission denied: 'E:\\Git Repos\\Prelude\\hidden.txt'
Using the above code results in that traceback. I've also tried the other three available modes in zipfile just to be thorough and nothing. Additionally, I've tried running it as an administrator and there are no file ownership issues. I did notice with some testing that if the file to be overwritten is not set as hidden, it will proceed fine, but the resultant file will not be hidden (even though the downloaded zip definitely has that file set to hidden). Ideally, the unzip process would proceed as normally and overwrite the hidden files. If that's not possible with zipfile, does anyone have recommendations on how to go about this?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using zipfile module - finding folders not files darter1010 2 282 Apr-06-2024, 07:22 AM
Last Post: Pedroski55
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 1,072 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  zipfile module error pseudo 3 777 Jun-30-2023, 03:52 PM
Last Post: Gribouillis
Question Need help for a python script to extract information from a list of files lephunghien 6 1,111 Jun-12-2023, 05:40 PM
Last Post: snippsat
  Copy only hidden files and folders with rsync Cannondale 2 1,021 Mar-04-2023, 02:48 PM
Last Post: Cannondale
  SQL Alchemy help to extract sql data into csv files mg24 1 1,793 Sep-30-2022, 04:43 PM
Last Post: Larz60+
  [Solved by deanhystad] Create a zip file using zipfile library DZ_Galaxy 2 1,177 Aug-17-2022, 04:57 PM
Last Post: DZ_Galaxy
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,098 Apr-27-2022, 12:44 PM
Last Post: hasiro
  Created zipfile without all the subfolder? korenron 3 3,788 Jun-23-2021, 12:44 PM
Last Post: korenron
  Create ZIP file not working using ZipFile? korenron 1 2,122 Jun-13-2021, 04:15 PM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020