Page 1 of 1

File Rights Question

Posted: Thu Dec 14, 2017 1:45 am
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

Re: File Rights Question

Posted: Fri Dec 15, 2017 1:48 pm
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)

Re: File Rights Question

Posted: Mon Dec 18, 2017 3:28 pm
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