Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bongabonga

macrumors newbie
Original poster
Oct 3, 2007
12
0
New York
Is there any way in OSX to protect a folder from being deleted, while keeping it fully functional as a 'normal' folder?

Normal folder = one which I can copy to and from, delete individual files, rename, move wherever, etc...

(Sorry if the answer is obvious, I've spent a while searching and still haven't found a way to do this...)
 
Why not just lock the folder so it can't be deleted accidentally? You lock a folder by clicking Get Info and checking the Lock Folder box.
 
Why not just lock the folder so it can't be deleted accidentally? You lock a folder by clicking Get Info and checking the Lock Folder box.

If I lock the folder I can't write to it...

I want/need the folder to be fully usable (see above) :)
 
Thanks for that. The sticky might be what I need, I'm gonna read more about it.

Please correct me if I read the sticky info wrong, but because I have admin rights (this is my personal computer) I am the creator of the files, and would thus still be able to delete whatever files inside the folder and the folder itself, correct?

(edit: which is not what I want; I want the folder to be indestructible (at least without me authorizing something, which means no accidental plopping in the trash. The only reason why I'm doing this (and not every single folder on my computer) is that I use this folder a lot for all sorts of temp files...)
 
Firstly, I'm a total noob when it comes to using the Terminal. :) Whenever someone tells me to use this or that command, I always end up googling it to see if I find more info. I'm afraid that (A) I'll break something, and (B) I won't be able to fix it. Actually, I know B is a fact.

Secondly, an immutable folder behaves just like a locked folder (probably is exactly the same thing, I have no idea). Regardless, I can't seem to get it to work the way I want. A locked folder means I can't write to it without authenticating every single action, which is definitely not what I'm after: I want it to function just like any folder I'd create on my desktop, with the exception that the folder:
- can not be deleted
- can not even be dragged to the trash

That would prevent the trash from emptying all files inside the folder while leaving the folder itself.

Of course I can always use an alias, but I'm still curious if this is possible. Thanks for your help.
 
RTFMP

There are lots of options......

Can anyone else confirm that chflags uunlnk works? I cannot get this to work because when I use the short name it says that it is an invalid flag, and when I use the octal notation the operation silently fails.

Code:
$ chflags uunlnk test
chflags: invalid flag: uunlnk
$ chflags 20 test
$ rm test
 
Okay I did some more digging. What is dissapointing is that Mac OS X has not implemented the feature you are looking for. It's really sad, because it would have been very useful.

Just goes to show you how committed Mac OS X is to their open source :rolleyes:

more /usr/include/sys/stat.h
...
/*
* Definitions of flags stored in file flags word.
*
* Super-user and owner changeable flags.
*/
#define UF_SETTABLE 0x0000ffff /* mask of owner changeable flags */
#define UF_NODUMP 0x00000001 /* do not dump file */
#define UF_IMMUTABLE 0x00000002 /* file may not be changed */
#define UF_APPEND 0x00000004 /* writes to file may only append */
#define UF_OPAQUE 0x00000008 /* directory is opaque wrt. union */
/*
* The following bit is reserved for FreeBSD. It is not implemented
* in Mac OS X.
*/
/* #define UF_NOUNLINK 0x00000010 */ /* file may not be removed or renamed */
/* Bits 0x0020 through 0x4000 are currently undefined. */
#define UF_HIDDEN 0x00008000 /* hint that this item should not be */
/* displayed in a GUI */
/*
* Super-user changeable flags.
*/
#define SF_SETTABLE 0xffff0000 /* mask of superuser changeable flags */
#define SF_ARCHIVED 0x00010000 /* file is archived */
#define SF_IMMUTABLE 0x00020000 /* file may not be changed */
#define SF_APPEND 0x00040000 /* writes to file may only append */
/*
* The following two bits are reserved for FreeBSD. They are not
* implemented in Mac OS X.
*/
/* #define SF_NOUNLINK 0x00100000 */ /* file may not be removed or renamed */
/* #define SF_SNAPSHOT 0x00200000 */ /* snapshot inode */

/* NOTE: There is no SF_HIDDEN bit. */
 
Okay I did some more digging. What is dissapointing is that Mac OS X has not implemented the feature you are looking for. It's really sad, because it would have been very useful.

Just goes to show you how committed Mac OS X is to their open source :rolleyes:

True.

Just so you know, I did go through allt he chflag-info before I posted the noob-comment, heh.

Thanks again for all your help. This would indeed be a very handy feature, even as a (optional) default setting for important folders.
 
I'm going to try and do some more digging, find out what happened to that flag. I would like to know what happened to it, I think that there is some usefulness to it. I looked at my system (10.4.10) and there was no mention of it in my header file. It must have been moved somewhere.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.