Discussion:
File locking
Jean-Luc Arnaud
2017-05-18 16:04:43 UTC
Permalink
Hi all,

Is there a way, with a Xojo, Shell or MBS command, to lock a file in
order to make it not writable, read-only?

I know some Shell commands on Mac modifying authorizations, but I'm
loocking for a kind of "Lock" in Macintosh File Info or "Read Only" in
Win file properties.

Thanks for your help.
--
Jean-Luc Arnaud


_______________________________________________

Xojo forum:

https://forum.xojo.com/
Marnaud
2017-05-19 05:09:05 UTC
Permalink
Post by Jean-Luc Arnaud
Hi all,
Is there a way, with a Xojo, Shell or MBS command, to lock a file in order to make it not writable, read-only?
I know some Shell commands on Mac modifying authorizations, but I’m loocking for a kind of "Lock" in Macintosh File Info or "Read Only" in Win file properties.
Hello Jean-Luc,

Are you not simply looking for the Locked property of a folderitem?
_______________________________________________

Xojo forum:

https://forum.xojo.com/
Jean-Luc Arnaud
2017-05-19 10:48:52 UTC
Permalink
Hi Arnaud,

Yes ... and no!

I not only need to know if a file is locked, I need to be able to
lock/unlock it.

Jean-Luc Arnaud
Post by Marnaud
Post by Jean-Luc Arnaud
Hi all,
Is there a way, with a Xojo, Shell or MBS command, to lock a file in order to make it not writable, read-only?
I know some Shell commands on Mac modifying authorizations, but I’m loocking for a kind of "Lock" in Macintosh File Info or "Read Only" in Win file properties.
Hello Jean-Luc,
Are you not simply looking for the Locked property of a folderitem?
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xo
vaughnsc .
2017-05-19 11:04:34 UTC
Permalink
On my first coffee but, assuming folderitem.locked is a read-only property
(I'm not 100% sure about that): couldn't you use a shell/path to 'chmod'
(or equivalent) the file permissions?
Post by Jean-Luc Arnaud
Hi Arnaud,
Yes ... and no!
I not only need to know if a file is locked, I need to be able to
lock/unlock it.
Jean-Luc Arnaud
Post by Jean-Luc Arnaud
Hi all,
Post by Jean-Luc Arnaud
Is there a way, with a Xojo, Shell or MBS command, to lock a file in
order to make it not writable, read-only?
I know some Shell commands on Mac modifying authorizations, but I’m
loocking for a kind of "Lock" in Macintosh File Info or "Read Only" in Win
file properties.
Hello Jean-Luc,
Are you not simply looking for the Locked property of a folderitem?
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_____________________________________
Jean-Luc Arnaud
2017-05-19 12:34:30 UTC
Permalink
Thanks, Vaughn.
Post by vaughnsc .
couldn't you use a shell/path to 'chmod'
(or equivalent) the file permissions?
Yes, sure. I was hoping not to have to code this way. No matter...
For Windows, 'attrib' does the job.

Jean-Luc Arnaud


_______________________________________________

Xojo forum:

https://for
Marnaud
2017-05-19 15:42:34 UTC
Permalink
Post by Jean-Luc Arnaud
Hi Arnaud,
Yes ... and no!
I not only need to know if a file is locked, I need to be able to lock/unlock it.
Hello Jean-Luc,

What’s wrong with setting the locked property?
_______________________________________________

Xojo forum:

https://forum.xojo.com/
Jean-Luc Arnaud
2017-05-19 16:58:18 UTC
Permalink
It's Read-Only, unless I'm wrong or we don't talk about the same property.

Jean-Luc Arnaud
Post by Marnaud
Post by Jean-Luc Arnaud
Hi Arnaud,
Yes ... and no!
I not only need to know if a file is locked, I need to be able to lock/unlock it.
Hello Jean-Luc,
What’s wrong with setting the locked property?
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xo
Marnaud
2017-05-20 13:07:30 UTC
Permalink
It’s Read-Only, unless I'm wrong or we don't talk about the same property.
It’s definitively working on my side.

Does this code compile for you?
dim f As FolderItem

f=SpecialFolder.UserHome.Child("SomeFile")

f.Locked=not f.Locked
Return True
_______________________________________________

Xojo forum:

https://forum.xojo.com/
Marnaud
2017-05-20 13:25:08 UTC
Permalink
Post by Marnaud
Does this code compile for you?
dim f As FolderItem
f=SpecialFolder.UserHome.Child("SomeFile")
f.Locked=not f.Locked
Return True
I mean, except the “return true”, of course.
If it compiles, then it’s not read-only on your side either.
_______________________________________________

Xojo forum:

https://forum.xojo.com/
Jean-Luc Arnaud
2017-05-22 07:45:29 UTC
Permalink
And you're right, of course, Locked is not a read-only property, but
actually a R/W one.

Jean-Luc Arnaud
Post by Marnaud
Post by Marnaud
Does this code compile for you?
dim f As FolderItem
f=SpecialFolder.UserHome.Child("SomeFile")
f.Locked=not f.Locked
Return True
I mean, except the “return true”, of course.
If it compiles, then it’s not read-only on your side either.
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum.xojo.com/

Jean-Luc Arnaud
2017-05-22 07:44:12 UTC
Permalink
Ok, Arnaud, we don't talk about the same property, I was thinking to
'IsWriteable'.

I didn't know 'Locked' and looked for 'IsLocked'! What a stupid guy!

Thanks for your code sample, I have to test that because a file may be
locked by itself or located on a locked volume.

Thanks again.

Jean-Luc Arnaud
Post by Marnaud
It’s Read-Only, unless I'm wrong or we don't talk about the same property.
It’s definitively working on my side.
Does this code compile for you?
dim f As FolderItem
f=SpecialFolder.UserHome.Child("SomeFile")
f.Locked=not f.Locked
Return True
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum.xojo.com/
Continue reading on narkive:
Loading...