Deleting file which V has open

Use this forum to ask any questions and to submit bug reports

Moderator: vuser

vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Deleting file which V has open

Post by vefatica »

Apparently, other apps are allowed to delete a file while V has it opened. Is that by design?

- Vince
FileViewer
Site Admin
Posts: 287
Joined: Fri Apr 30, 2010 5:50 pm

Re: Deleting file which V has open

Post by FileViewer »

Apparently, other apps are allowed to delete a file while V has it opened. Is that by design?
Yes. As V is a viewer only, it does not lock the file while it is viewing it.

If it did, files would not be able to be modified while V was viewing them. This would be a problem when viewing some log files,
as locking the file would disable the log file from being updated.

And there is no option in V to lock the file while you are viewing it.

Charles.
vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Re: Deleting file which V has open

Post by vefatica »

FileViewer wrote: And there is no option in V to lock the file while you are viewing it.
Is it possible to keep V from watching the file and reloading it if there are changes?

- Vince
vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Re: Deleting file which V has open

Post by vefatica »

Can't you open it with FILE_SHARE_READ | FILE_SHARE_WRITE and not FILE_SHARE_DELETE?

- Vince
ron
Posts: 2
Joined: Thu May 20, 2010 6:00 pm

Re: Deleting file which V has open

Post by ron »

Not quite, but you can have it prompt you before the file is reloaded. Clicking OK is the only option on the prompt so it's always reloaded eventually.
vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Re: Deleting file which V has open

Post by vefatica »

ron wrote:Not quite, but you can have it prompt you before the file is reloaded. Clicking OK is the only option on the prompt so it's always reloaded eventually.
Not much of a prompt, eh! That's silly. What if I don't want it reloaded? What of I don't even want it watched? Charles mentioned log files. How can you look at a log file without continually dismissing that "prompt".

Odd ... if, while viewing a file you turn on File\Tail ... then turn it off ... you can thereafter freely write to the file or even delete it without V knowing about it.
FileViewer
Site Admin
Posts: 287
Joined: Fri Apr 30, 2010 5:50 pm

Re: Deleting file which V has open

Post by FileViewer »

Is it possible to keep V from watching the file and reloading it if there are changes?
As Ron said, no.
Not much of a prompt, eh! That's silly. What if I don't want it reloaded?
You don't have an option. The file you are viewing has changed. The data you were previously viewing no longer exists (or has been modified).
V must reload the file in order to display it correctly. The prompt is only there to inform you that the file has changed.
How can you look at a log file without continually dismissing that "prompt".
You do not get the reload prompt if the file being viewed has simply been appended to (as in log files). You only get
it if any part of the file that was originally opened has been modified.
Can't you open it with FILE_SHARE_READ | FILE_SHARE_WRITE and not FILE_SHARE_DELETE?
Opening the file with FILE_SHARE_DELETE will not stop the file from being deleted as the file is not open
while V is viewing it. V only opens the file to read what it needs to display and then closes it.

I could very easily stop the file being deleted while V was viewing it - but I don't want to lock it in any way, as this can cause problems.
For example, I might want to view temporary files created by my DVD authoring program while it was authoring a DVD. If I was viewing such a file
when the program wanted to delete it, the authoring would probably fail.

BTW: I assume you asked the original question because you don't want a file that is being viewed to be deleted. Is that right?

Did you accidentally delete a file that was being viewed? Or was it deleted by another program?

Charles.
vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Re: Deleting file which V has open

Post by vefatica »

Apparently not so. If I "ECHO foo > foo.txt", then "v foo.txt", then go back to the command prompt and "ECHO foo >> foo.txt" (appending to it) then as soon as V gets the foreground, it either updates automatically of after the announcement (depending to my preferences). I don't want that to happen (optionally, of course).

I actually wanted to delete the file (a temporary one). I really don't care about allowing deletion or not. I just don't like V's behavior when the file is deleted or changed (even appended). V's behavior when the file is deleted is rather humorous.

And there should certainly be an option not to watch/update files if that's what the user wants.
FileViewer
Site Admin
Posts: 287
Joined: Fri Apr 30, 2010 5:50 pm

Re: Deleting file which V has open

Post by FileViewer »

Apparently not so. If I "ECHO foo > foo.txt", then "v foo.txt", then go back to the command prompt and "ECHO foo >> foo.txt" (appending to it) then as soon as V gets the foreground, it either updates automatically of after the announcement (depending to my preferences).
You are right. If you switch back to V and it notices that the file has changed, it will always update it (and optionally display the reload message).
I don't want that to happen (optionally, of course)
Unfortunately, this is not possible.

V does not load the entire file into memory to display it - it always displays the file as it is on the disk. If the file changes then the data
that V displays must also change.

Of course, in the case of data being appended to the file, V could choose to ignore the appended data. If this is what you want, I can
look at adding an option to do that.

Charles.
vefatica
Posts: 10
Joined: Wed May 19, 2010 7:15 pm

Re: Deleting file which V has open

Post by vefatica »

> Of course, in the case of data being appended to the file, V could choose to ignore the appended data.
> If this is what you want, I can look at adding an option to do that.

That would be just a drop in the bucket. Don't do that for me. I want it to ignore the file if I so choose (let it have a manual "reload" option). If simply looking at a (small) file as it was when it was read is impossible, that would seem a lack of functionality.

What's up with turning "tail" on/off? That seems to get rid of the monitoring (a bug?). Apparently the ability to turn it off is already there.
Post Reply