Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try storing a file that's name begins with a period in some folder and then setting the file's hidden flag.</p> <p>a good place to put the hidden file would be an obscurely named file in the base of the users folder (~/), there are many obscure hidden files there so it is hard to know which one's you can and can't delete. example path: <em>~/.xdarwinprofile</em> or something equally official sounding.</p> <p>here is some code that should work to hide the file:</p> <pre><code>#include &lt;assert.h&gt; #include &lt;stdio.h&gt; #include &lt;stddef.h&gt; #include &lt;string.h&gt; #include &lt;sys/attr.h&gt; #include &lt;sys/errno.h&gt; #include &lt;unistd.h&gt; #include &lt;sys/vnode.h&gt; typedef struct attrlist attrlist_t; struct FInfoAttrBuf { u_int32_t length; fsobj_type_t objType; union { char rawBytes[32]; struct { FileInfo info; ExtendedFileInfo extInfo; } file; struct { FolderInfo info; ExtendedFolderInfo extInfo; } folder; } finderInfo; }; typedef struct FInfoAttrBuf FInfoAttrBuf; - (int)SetFileInvisibility:(NSString *)filePath state:(BOOL)isInvisible) { attrlist_t attrList; FInfoAttrBuf attrBuf; char *path = [filePath cStringUsingEncoding: NSUTF8StringEncoding]; memset(&amp;attrList, 0, sizeof(attrList)); attrList.bitmapcount = ATTR_BIT_MAP_COUNT; attrList.commonattr = ATTR_CMN_OBJTYPE | ATTR_CMN_FNDRINFO; int err = getattrlist(path, &amp;attrList, &amp;attrBuf, sizeof(attrBuf), 0); if (err != 0) return errno; // attrBuf.objType = (VREG | VDIR), inconsequential for invisibility UInt16 flags = CFSwapInt16BigToHost(attrBuf.finderInfo.file.info.finderFlags); if (isInvisible) flags |= kIsInvisible; else flags &amp;= (~kIsInvisible); attrBuf.finderInfo.file.info.finderFlags = CFSwapInt16HostToBig(flags); attrList.commonattr = ATTR_CMN_FNDRINFO; err = setattrlist(path, &amp;attrList, attrBuf.finderInfo.rawBytes, sizeof(attrBuf.finderInfo.rawBytes), 0); return err; } </code></pre> <p>I modified this code from the answer to this question, you may find more helpful information there: <a href="https://stackoverflow.com/questions/2958991/how-to-make-a-file-invisible-in-finder-using-objective-c">How to make a file invisible in Finder using objective-c</a></p> <p>I have not tested this code but it should work. In fact, it is possible the code is unnecessary and just saving the file with a dot in front of the filename will work.</p> <p>If you have administrator privileges you can execute a sudo chmod on the file and set it to read only if you want, but you shouldn't make your app ask the user for their password. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload