File Rights Question

Linux specific forum
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

File Rights Question

Post by swhite »

Hi

When I create a file using the OpenFile() function it appears that the file is created in Linux as readonly. I am using OpenSuse 43.2. So I am wondering how to fix this. If I use the SetFileAttributes() with #PB_FileSystem_ReadAll and
#PB_FileSystem_WriteAll will that set the attributes so that anyone can read and write to the file.

Thanks,
Simon
Simon White
dCipher Computing
deeproot
Enthusiast
Enthusiast
Posts: 269
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: File Rights Question

Post by deeproot »

Surprised you are getting read-only! Or do you mean it is read-only for ANY user?

From OpenFile I get - read-write:User, read-only:Group, read-only:Any

Which is what I would expect. Checked on MX Linux and Manjaro, but I'd guess others to be the same.

Yes, you can change permissions with SetFileAttributes() as documented. But beware as permissions will be exactly what you specify, replacing the original settings. So using #PB_FileSystem_ReadAll only will remove read:User.

To keep existing permissions and add more, you want something like:

Code: Select all

myFileAttributes = GetFileAttributes("/home/userme/Test.txt")    
SetFileAttributes("/home/userme/Test.txt", myFileAttributes | #PB_FileSystem_ReadAll | #PB_FileSystem_WriteAll)
swhite
Enthusiast
Enthusiast
Posts: 726
Joined: Thu May 21, 2009 6:56 pm

Re: File Rights Question

Post by swhite »

Thanks for showing how the attributes should be set. The problem with readonly may have to do with some customization of my current Linux setup but knowing how to set the file attributes will enable me to handle the issue.

Thanks,
Simon
Simon White
dCipher Computing
Post Reply