PureBasic Forum
http://forums.purebasic.com/english/

File Rights Question
http://forums.purebasic.com/english/viewtopic.php?f=15&t=69778
Page 1 of 1

Author:  swhite [ Thu Dec 14, 2017 1:45 am ]
Post subject:  File Rights Question

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

Author:  deeproot [ Fri Dec 15, 2017 1:48 pm ]
Post subject:  Re: File Rights Question

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:
myFileAttributes = GetFileAttributes("/home/userme/Test.txt")   
SetFileAttributes("/home/userme/Test.txt", myFileAttributes | #PB_FileSystem_ReadAll | #PB_FileSystem_WriteAll)

Author:  swhite [ Mon Dec 18, 2017 3:28 pm ]
Post subject:  Re: File Rights Question

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

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/