Delete more than 1 file at the same time?

Blitz3D Forums/Blitz3D Programming/Delete more than 1 file at the same time?

Guy Fawkes(Posted 2009) [#1]
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.




Guy Fawkes(Posted 2009) [#2]
Does anybody know how to do this?


SabataRH(Posted 2009) [#3]
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.


Yasha(Posted 2009) [#4]
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.


Kryzon(Posted 2009) [#5]
Here-Here, Yasha. Nicely said.


Guy Fawkes(Posted 2009) [#6]
yes, but this is my engine, and i dont want them ADDING files to my directory. I want to keep the directory normal


xlsior(Posted 2009) [#7]
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.


Guy Fawkes(Posted 2009) [#8]
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.


Matty(Posted 2009) [#9]
i dont want them ADDING files to my directory


Except that on another person's PC it is not *your* directory.


Guy Fawkes(Posted 2009) [#10]
Sorry for the double or triple post. the forum is acting up on me.


Guy Fawkes(Posted 2009) [#11]
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.


Ginger Tea(Posted 2009) [#12]
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?


Ross C(Posted 2009) [#13]
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.


Gabriel(Posted 2009) [#14]
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.


Guy Fawkes(Posted 2009) [#15]
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.


xlsior(Posted 2009) [#16]
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.


SabataRH(Posted 2009) [#17]
blocking you from putting files in my engine directory.



What's the reasoning behind this might i ask?


Guy Fawkes(Posted 2009) [#18]
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.


Gabriel(Posted 2009) [#19]
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?


Guy Fawkes(Posted 2009) [#20]
Simple. I will tell them what files and folders should be included in there.


xlsior(Posted 2009) [#21]
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.


Guy Fawkes(Posted 2009) [#22]
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.


Ross C(Posted 2009) [#23]
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.


Guy Fawkes(Posted 2009) [#24]
essentially then, they shouldnt have done that then. ill add a warning about it in the installer, but thats it.


Ross C(Posted 2009) [#25]

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.


RGF(Posted 2010) [#26]
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...."


LineOf7s(Posted 2010) [#27]
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.


D4NM4N(Posted 2010) [#28]
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").


Guy Fawkes(Posted 2010) [#29]
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?


Ginger Tea(Posted 2010) [#30]
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?


Guy Fawkes(Posted 2010) [#31]
since its MY game, and thats just the way i want it.


Ross C(Posted 2010) [#32]
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.


Guy Fawkes(Posted 2010) [#33]
no. i dont want to delete anything now. i just want to detect it, and close the game now if theres anything there.


Ginger Tea(Posted 2010) [#34]
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


_PJ_(Posted 2010) [#35]
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.