Kepping Directory Permissions

T

Tracy Tripp

I'm working on a program that takes files by path and moves them into
new locations, and then back again if the user intends. Everything is
great so far except I cannot figure out how to keep directory
permissions. File permissions are no problem, but when I try and put
a directory's permissions back, I, the user, lose all access to that
directory. When I give myself permission again, all my files have
kept their permissions. Here are some functions I am working with:

I have a File object that keeps the files original path, its new path
and permissions. When an instance is made of this object, it uses:
dirPath = os.path.dirname(filePath) to get the the files parent
directory. I get the directories permissions with this data calling
os.stat(dirPath)[0] and saving this value into an integer essentially.
When it comes time to move the file, I use os.renames() to put the
file into its new location, copy its permission's over and copy its
directories permissions over. It works for the file, but not for the
directories. Any ideas on how to save a directories permissions when
moved using renames()? Thank you.

-Tracy Tripp
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top