Delete more than 1 file at the same time?
Blitz3D Forums/Blitz3D Programming/Delete more than 1 file at the same time?
| ||
Hi all. I need this code fixed so it detects any files/folders inside a chosen directory, and delete whatever files/folders that are in there that SHOULDN'T ALREADY be in there. |
| ||
Does anybody know how to do this? |
| ||
Just build a log file of the file/directory listing when you scan the folder. After that filter through the log and remove any files you don't want in the directory using blitz's own DeleteFile() command. |
| ||
I'd like to throw out a warning that this is really, really bad practice and would recommend against doing it about as strongly as I can. When people create extra files, it's because they want them for some reason; maybe they've modified something and kept a backup of the original, maybe they've posted notes to themselves to keep track of what the different files do, maybe they've added other files because they wanted to store similar things in the same place. Deleting people's files because you don't know what they are is the surest way to get yourself fired/sued/expelled/whatever, and an absolute guarantee that your product will not sell. On the flipside, if these are files that your program has created, you should never need to run this routine as you will have been keeping a list of where you were writing the data. |
| ||
Here-Here, Yasha. Nicely said. |
| ||
yes, but this is my engine, and i dont want them ADDING files to my directory. I want to keep the directory normal |
| ||
What you do on your own PC is your business, but why should you prevent someone else from putting their files in a folder on their computer? whether or not it's smart to add files is irrelevant, blowing them away would still be questionable. |
| ||
no. i dont mean prevent people from putting their files in a folder. i mean prevent them from putting files in the MAIN DIRECTORY of my project. |
| ||
i dont want them ADDING files to my directory Except that on another person's PC it is not *your* directory. |
| ||
Sorry for the double or triple post. the forum is acting up on me. |
| ||
Hey. it's my engine, and if I don't want people to add files to my ENGINE's directory, then I'll do it. No offense, but it's not YOUR engine. I never FORCED you to write anything. |
| ||
ive got a habbit of creating "new text document.txt" in random folders, where ever i happen to be in explorer if i need to jot something down, and say for example i wanted ot make a reminder about which flags or textures to use and i slapped it in your engine folder on my pc, your extra code will say "names not down delete", yet it might be a relevant to me in the use of your program file in my life ive never encountered a program that cleans up after itself exept on uninstalation and thats shakey at best it also stifles user modifications, eg the media directory is under the controll of this delete list that means you cant add your own sprite sheets to that directory as they will be deleted as an end user that would p**s me off if i want to stick my music folders in windows instead of my documents/my music i can and will, no one at microsoft cares so long as none of the files carry the same name as a valid program so why do you? |
| ||
Yep, i'm sure it could be against some law, or rule, blocking people from putting files in a certain directory. Maybe not though... Hmmm, anyway, i personally, wouldn't trust a game or app, that blocked me putting files on my own hard disc, in certain places. You could have a repair option though, that replaces the files, if any are moved. |
| ||
Hey. it's my engine, and if I don't want people to add files to my ENGINE's directory, then I'll do it. No offense, but it's not YOUR engine Indeed. It will be YOUR engine which gets classified as a VIRUS by all the sites which report on such things. Deleting other people's files without asking first is just about guaranteed to get your program blacklisted with all the MALWARE sites. |
| ||
It's not that I'm blocking you from putting files on your own hard disk. It's blocking you from putting files in my engine directory. |
| ||
It's not that I'm blocking you from putting files on your own hard disk. It's blocking you from putting files in my enging directory. ...on my own hard disk. |
| ||
blocking you from putting files in my engine directory. What's the reasoning behind this might i ask? |
| ||
Well. If someone were to say put a virus in the folder, and send the engine to someone else, that someone else would get the virus as well. i want to stop this. |
| ||
If someone were to say put a virus in the folder, and send the engine to someone else, that someone else would get the virus as well. i want to stop this. How are you going to stop it? Your program isn't running. I put a virus there. I zip it up. I send it to someone. Then I run your engine, and it deletes all my files. But the virus has already been sent. Are you going to add in some functionality to your engine so that it automatically reads my email address book, hacks everyone's account and looks to see if I sent them any emails which might contain virus infected versions of your engine? |
| ||
Simple. I will tell them what files and folders should be included in there. |
| ||
Then why not just TELL them not to add random stuff to the folder, instead of blowing someone elses files away from their own drive with a double-barreled shotgun? As Gabriel pointed out, your original goal (preventing a virus from coming along with the program) can't be prevented by this measure anyway. |
| ||
well i still want it to do that, i don't care how accurate it is, i just want it to contain my original files for the game. nothing more, nothing less. |
| ||
Problem you have though. Say someone, who doesn't know that much about computers, decides to download their digital camera images to that folder. The engine is then run, and it deletes their images. You have absolutely no right to be doing this, morally anyway. Your deleting someone elses data/information. Essentially, your engine will be classed as a virus. |
| ||
essentially then, they shouldnt have done that then. ill add a warning about it in the installer, but thats it. |
| ||
essentially then, they shouldnt have done that then They can do whatever you wish with their hard disc. They paid the money for it. YOU however, cannot go about deleting files, blindly, that don't belong to the engine. Your writing malware, doing such, and no-one will touch your engine. I really don't see why this is such an issue? You distribute the installer to people. It installs the files they need to run the engine. You don't copy a folder once it's been installed, and pass it along to someone else. |
| ||
What about detecting the presence of non authorized files contained in the folder and displaying an error message when running the program? In fact is bad practice deleting other people's information without permission. Mind you don't get in trouble with legal issues. Just display an error message: "This program won't run, due to...." |
| ||
If it makes you feel better, unless someone walks him through creating the code line-by-line he probably won't be able to manage to do it, anyway. |
| ||
Well. If someone were to say put a virus in the folder, and send the engine to someone else, that someone else would get the virus as well. i want to stop this. Do some reading on viruses. Strange files appearing in a folder is the least of your worries. I agree with everyone else, if I used an engine that deleted files off my hard disk i would shout it as malware. (It might even border on "deliberate criminal damage"). |
| ||
Ok, then can u at LEAST get it to name what file it is that is bugging the system and shut down the game because of it then? |
| ||
Ok, then can u at LEAST get it to name what file it is that is bugging the system and shut down the game because of it then? since when did a user added file like "my brothers car.jpg" added to a game folder ever cause it to hang? answer never changing a game file can however, but thats not the issue how exactly would a file like "my brothers car.jpg" cause your or anyones program to spaz out? |
| ||
since its MY game, and thats just the way i want it. |
| ||
You can't name a file, that is bugging the system. If someone puts a file inside your directory, and doesn't overwrite any of your files, then it shouldn't cause any problems. I repeat, you can't install your engine and have it delete a users files. That is classed as a virus/malware. No-one will touch your software after that, and it could open up legal issues for you. |
| ||
no. i dont want to delete anything now. i just want to detect it, and close the game now if theres anything there. |
| ||
which will peturb end users just as much games crashing for no reason doesnt get gamers looking into the issue, just uninstalling it as a lost cause even with a "rouge file <filename> detected" error, not everyone will read it and just go oh this program crashed click ok to quit |
| ||
Look here this might help: http://www.blitzbasic.com/codearcs/codearcs.php?code=2593 To be fair to Rez, there's little harm in an application keeping its 'own' ddirectories clean of unnecessary files. Unless the program is designed with the possibility that there may be etxtra files/folders prresent within its root directory or subdirs thereof, there may be crashes. |