Use of deleted files.

Another idiotic question:
Same senario, Windows Operating System.
We have an application uses files to load from pictures and sounds. The files are many.
When those files are loaded the application in EVERY FILE writes random values and delete them afterwards.
There is no way that those files restored or copied again in the specific location they were.
HOW MANY TIMES this application will work properly and why.

Again thanks in advance,

George Tokas.
LVL 16
George TokasAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenData Warehouse Architect / DBACommented:
Hi George,

Pardon the language gap, but are you wondering about the recoverability of the picture and sound files?

For the most part, it would depend on how may of the headers you've managed to clobber, and where they are.

If the file is a BMP, clobbering the color map at the start of the file is a good start, as long as several of the embedded headers get clobbered, too.

Depending on the O/S (and I'll need help here) it may be more effective to truncate() the file several times.  Assuming a 1MB file, truncate the file at 750KB.  Then again at 500KB.  Finally at 250KB.  Delete the last segment.  The segments will be returned to the "free pool" out of logical order.  Of course, the four segments may well be merged into contiguous available space, too.    Anyone out here know?

Good Luck,
George TokasAuthor Commented:
Hello again Kent and from this Q,
In an article on cryptography on bcbjournal I proposed:
1. Load the file in a buffer
2. fill the contents with random values,
3. save the file.
4. Repeat steps 1,2 and 3 at least 2 more times.
5 Finaly delete the file.

But this is not the issue here...
We are opening the file with fopen() and we read each position from the start and change it with a random value (fget(), fput() ) and then deleting the file.
There is no way that those files restored or copied again in the specific location they were.
HOW MANY TIMES this application will work properly and why.

George Tokas.
>> There is no way that those files restored or copied again in the specific location they were.

yes there is. If I have access to the original file, I can restore it in the same palce, same sectors, same everything, placing same datetime as the original file, blabla. it wil be in the same state as before you started your application.
but, I underline: you need the original file AND you need to know exactly where the file resided on the disk and what sectors it occupied.

BUT, the simplest way of achieving this is to make a disk sector by sectro copy/backup and restore it after operation :) of course, in this case everything gets restored, but my point is "there is a way" ;)

when it comes to virtual IT, nothing is impossible.

>>HOW MANY TIMES this application will work properly and why.

if we are talking about the same file, once. since the file gets deleted, the second time the program will not be able to load it and will fail.
if we are talking about any file, it can run forever, ifinite times, etc. depends again, on the input files.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

George TokasAuthor Commented:
Hello ciuly and thank you for answering.
>> There is no way that those files restored or copied again in the specific location they were.
I mean that the application we are discussing has no means to do such a thing you describe.
Of course are many ways but they are NOT described.
To propose a way and myself, inside a local network, if it is a shared folder - example a drive in Windows98 PC - then from another PC you can add whatever you like, wherever you like, and all the rest you are describing.
The fact is that none of the above is described as function.

>>BUT, the simplest way of achieving this is to make a disk sector by sectro copy/backup and restore it after operation :)
Check my previous post with a part from my article and tell me if after that will be easy....

Thanks for the support,
George Tokas.
>>BUT, the simplest way of achieving this is to make a disk sector by sectro copy/backup and restore it after operation :)
Check my previous post with a part from my article and tell me if after that will be easy....

of course. it doesn't matter what you do.

let me explain a little deeper:

step 1:
- make a disck sector by sector copy. (attention: *disk*. this is independent of operating system, file system, etc)
step 2
- run your program. do whatever you want. format the disk. recreate partitions, install inux. finally, zero out the disk etc.
step 3
- restore the disk by sector by sector copy

result: you will have the exact same disk contents as before step 2.

obviously, this behaviour is not present in your application or any other usual application since it requires direct AND exclusive disk access. but as I was saying, this is possible (there are a ton of porograms out there that already do this. one of the oldest is norton ghost)

now, if we are talking about a normal day-to-day application, your algorithm is too complicated.
a simpler algorithm will get you in the same position of not beeing able to recover a file content after deletion:

- open file
- replace the content with whatever you want (for example character 0)
- flush the disk
- resize the file to 0 bytes
- close the file

at this stage, if you want, you can delete it. the contents already cannot be recovered because:
1) the content was overritten
2) the filesystem doesn't know the original file size. it knows that the filesize is 0 :)

considering large files, you don't want to repeat a file-wide operation. doing it once cna be lengthy enough, dong it 2-3 times can kill one persons mind :P
George TokasAuthor Commented:
I am covered.
So considering all these except that there is a way of restoring, since it's never described,
HOW many times the application will work properly, and I mean displaying the result it suppose to display?

George Tokas.
I am not sure what you mean, but IF
- the application is supposed to display a picture
- that picture is begin "destroyed" with your presented algorithm
- that picture is beeing deleted

exactly once. as I said, after you deleted the file, that file cannot be used anymore. ANOTHER file yes, but not that same file.

same goes for any filetype.
Kent OlsenData Warehouse Architect / DBACommented:

Hi George,

If you WANT to ensure reusability, copy the files that will be modified to a backup folder.  After the application runs, replace the modified file by opening it for update, and copying the backup file over it.  Assuming that the file length hasn't change (it shouldn't) the file will be restored in the exact location that it currently occupies.

Of course, if the file has been deleted, all bets are off as the sectors/clusters are returned to the free chain in an order that doesn't guarantee that they will be reused in the same order.

>> HOW many times the application will work properly,

This part of yoiur question (which seems to tbe the core of the issue) is very unclear.  I have no idea what you need to know.  Please restate this part of the question with more complete detail.  If necessary, find someone who has more experience with English and have that person describe what it is that you need to know.  Thanks.

-- Dan
George TokasAuthor Commented:
Ok. Restating:
We have an applicatin that displays in the form some pictures (bitmaps) and plays lets say a sound.
The application loads the bitmaps and the sounds from CERTAIN FILES inside a CERTAIN DIRECTORY.
When the application starts and displays the form with the pictures and playing the sounds:
1. Writes random values to the content of EACH FILE and
2. Deletes the files.

The question is:
HOW MANY TIMES the picture and sound files can be used for the application to work properly...

There is no way the files to be restored or copied again.

George Tokas.
As I understand it...
To perform properly, the application must read the file, then scramble it.

Thus, each file will be able to be played just once.

The program will continue to work properly forever, but when functioning properly, it will be able to play each file just once.

That answer is so obvious that it makes me think that I still don't understand the question.
George TokasAuthor Commented:
Hi DanRollins,
I understand your puzzling....
You will have the answer for the reason of this idiotic question in the next 24H...
There is a "findings report" along with a "description" someone else made that I can't YET made them public...

George Tokas.
George TokasAuthor Commented:

There is no way to underline so I hope you understand that I'm greatfull...

George Tokas.
George TokasAuthor Commented:
Hello again and thanks everybody for the support...
I just went back from the court house and the verdict was NOT guilty....
Now that all is over I can describe you the reason for this IDIOTIC question....
I hope you read my trouble at: 
In the report the employee made describes a functionality that is the same as I described added only that the application is controlled by some other application...
There was NO description on how those deleted files restored in order the system to work properly again...

Even though we didn't met here under the best conditions - in my first question in C++ area you accused me for a hacker (or I understand it that way)- that DOESN'T mean that I'm not respecting you or have any bad oppinion...
In fact if I were in your shoes I maybe had posted the same way...

Same with the other question for you my friend for leaving your area of experties to support me...

I don't think that I had to add anything more my friend...:-)

Again thinks for the support...
I'm accepting all answers and if you ever need anything you know how to contact me...

George Tokas.
glad it's over in your favor :)

take care
George TokasAuthor Commented:
Thanks my friend....
But they maybe forgot that soon (after 30 days) will be my turn to expose their lies and manipulations...
I will update as soon as I can....

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.