-
File deleting & attributes
From
Nightfox@VERT/DIGDIST to
All on Thu Sep 3 20:50:42 2009
I'm working on a JavaScript script for Synchronet that involves extracting anãarchive into a temporary directory, and then it will recursively delete theãtemporary directory when it's done.ãMy BBS is running in Windows 2000, and it looks like if one of the extractedãfiles has the read-only attribute set, file_remove() doesn't remove it. I thenãstarted to look into how file attributes are represented in Synchronet'sãJavaScript model and if it's possible to change them. I noticed that the Fileãclass has a property called 'attributes', and there's also a function calledãfile_attrib(), which will give you a file's attributes. The attributes areãrepresented by a number, but the docs don't seem to say what that number meansãor if there are any variables anywhere that represent different fileãattributes. I checked sbbsdefs.js and didn't see any mention of file attributeãdefinitions in there.ããSo, my questions are:ã1. Is it possible to delete a file regardless of its attributes? And if so,ãhow?ã2. For File's attribute property and file_attrib()'s return value, what are theãattribute values that it can be checked against (or more precisely, where can Iãfind the list of attributes)?ã3. If you wanted to change a file's attributes, can that be done by opening itãwith the File class, changing its attributes property, and saving the file?ããEricãã---ã þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.comã
-
From
Nightfox@VERT/DIGDIST to
All on Thu Sep 3 21:31:26 2009
Re: File deleting & attributesã By: All to Nightfox on Thu Sep 03 2009 20:50:42ããAs a follow-up to my last message, if I want to recursively delete a temporaryãdirectory after extracting an archive into it, I thought of a simpler solution.ã If in Windows, I could have my script execute the "rd /s /q" command;ãotherwise assume *nix and use "rm -rf", as follows:ããfunction deltree(pDir)ã{ã if (/^WIN/.test(system.platform.toUpperCase()))ã system.exec("rd " + pDir + " /s /q");ã elseã system.exec("rm -rf " + pDir);ã}ããIt does what I want on Windows, but for *nix platforms, I could still see thereãbeing a problem removing the directory due to the directory's permissions. Butãif the script created the directory in the first place, would that be aãproblem?ããEricãã---ã þ Synchronet þ Digital Distortion BBS: digdist.bbsindex.comã
-
From
Digital Man@VERT to
Nightfox on Wed Sep 9 09:30:46 2009
Re: File deleting & attributesã By: Nightfox to All on Thu Sep 03 2009 08:50 pmãã > I'm working on a JavaScript script for Synchronet that involves extractingã > an archive into a temporary directory, and then it will recursively deleteã > the temporary directory when it's done.ã > My BBS is running in Windows 2000, and it looks like if one of theã > extracted files has the read-only attribute set, file_remove() doesn'tã > remove it. I then started to look into how file attributes are representedã > in Synchronet's JavaScript model and if it's possible to change them. Iã > noticed that the File class has a property called 'attributes', and there'sã > also a function called file_attrib(), which will give you a file'sã > attributes. The attributes are represented by a number, but the docs don'tã > seem to say what that number means or if there are any variables anywhereã > that represent different file attributes. I checked sbbsdefs.js and didn'tã > see any mention of file attribute definitions in there.ã >ã > So, my questions are:ã > 1. Is it possible to delete a file regardless of its attributes? And ifã > so, how?ããNo, you would have to change the attributes first. I would suggest modifyingãyour file extraction command line to strip any read-only attributes.ãã > 2. For File's attribute property and file_attrib()'s return value, what areã > the attribute values that it can be checked against (or more precisely,ã > where can I find the list of attributes)?ããThe attribute bit values are platform specific (e.g. different from Windows andãLinux). For example, on Windows:ãã#define _A_NORMAL 0x00 /* Normal file - No read/write restrictions */ã#define _A_RDONLY 0x01 /* Read only file */ã#define _A_HIDDEN 0x02 /* Hidden file */ã#define _A_SYSTEM 0x04 /* System file */ã#define _A_SUBDIR 0x10 /* Subdirectory */ã#define _A_ARCH 0x20 /* Archive file */ãã > 3. If you wanted to change a file's attributes, can that be done by openingã > it with the File class, changing its attributes property, and saving theã > file?ããYes, but no "saving" is necessary, just close the file.ãã digital manããSnapple "Real Fact" #35:ãElephants only sleep 2 hours a day.ã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã