fileUtils module
- fileUtils.FaultTolerantFile(name)
Used to write out files in a more fault tolerant way. A temporary file is used, and replaces the file
name' when the context manager scope ends and the the context manager __exit__ is called. This means writing out the complete file can be performed with less concern of corrupting the original file if the process is interrupted by windows shutting down. `name
must be unicode.- Usage:
- with FaultTolerantFile(“myFile.txt”) as f:
f.write(“This is a test”)
This creates a temporary file, and the writes actually happen on this temp file. At the end of the
with
block, whenf
goes out of context the temporary file is closed and, this temporary file replaces “myFile.txt”
- fileUtils._suspendWow64RedirectionForFileInfoRetrieval(func)
This decorator checks if the file provided as a
filePath
is placed in a system32 directory, and if for the current system system32 redirects 32-bit processes such as NVDA to a different syswow64 directory disables redirection for the duration of the function call. This is necessary when fetching file version info since NVDA is a 32-bit application and without redirection disabled we would either access a wrong file or not be able to access it at all.
- fileUtils.getFileVersionInfo(name, *attributes)
Gets the specified file version info attributes from the provided file.