Unreliable File Deletion
John Balgenorth
sundown.pacifier at icloud.com
Tue Mar 30 06:21:27 EDT 2021
I have only read this one entry your subject so I may not be of any help
but LiveCode is written using C++ and here is a link with some info
about temporary files;
https://en.cppreference.com/w/cpp/io/c/tmpfile
The above link mentions,
If the program closes the file, e.g. by executing std::fclose, the file is automatically deleted.
It seemed to me you were interested in deleting a temporary file and it is
possible the ability to delete a temporary file is not built in and won’t be
nor is it a bug. If I remember correctly the proper way would be to do
a flush on the file instead of deleting it. That deletes everything in the
file and you do not bother deleting it because it is deleted automatically
when your program closes and after it is flushed the memory used will
not be an issue either because it is cleared.
JB
> On Mar 30, 2021, at 3:02 AM, R.H. via use-livecode <use-livecode at lists.runrev.com> wrote:
>
> Referring Date: 2021-03-29 09:04:04 +0100
> From: Mark Waddingham <mark at livecode.com>
> Subject: Re: Unreliable File Deletion
> Message-ID: <c42ce48e9618e0acffe4042e6d532c7f at livecode.com>
>
> Environment: Windows 10, 64bit
> LC: Version 9.6.1
>
> Dear Mark, Richard and all
>
> Thank you for your replies ))).
>
> Your comments are -- of course -- right, but I made a mistake in posting
> something that was incorrectly typed.
>
> Your wrote:
>> ll cases of people reporting bugs with 'delete file' on Windows that I
>> have seen fall into one of two cases:
>> 1) The path they give to 'delete file' is wrong.
>> 2) The file they are trying to delete is open by the app, or by another
> app.
>
> I am using URL ("binfile:"&<filepath>) to read and write from and to the
> file.
> For deleting I was and I am using and always have been using "delete file
> <pathname>".
>
> Unfortunately, I stated this incorrectly when retyping it to compose it as
> part of my message as I changed the original statement here and there, but
> it is not in the actual statement. This is my mistake to post it as such
> and I apologize.
>
> The file is in a writeable/readable location. It is neither protected, nor
> is it used by any other service/app.
>
> On my system (Windows 10) asking for specialfolderpath("resources") result
> in the following path: "C:/Users/Roland/Documents/LC-Recent/LSP_App". This
> is so because I put it there.
>
> It is in the DOCUMENTS folder and therefore should not give problems.
> But the same problem with deleting appears also when using
> specialfolderpath("documents").
>
> At other times, it worked! It is not something that is very transparent for
> now.
>
> Since on the Desktop and in any such user directory I can delete files
> without assigning Admin rigths, the problem should not be a system problem.
> I can also issue a shell command, as I posted, to delete and it works well
> without problems. This at least is my fallback in case LC does not delete
> my temporary file/s. So, actually, I use my function and do not care as it
> solves what it needs to solve (just replace the wrong "delete file
> (binfile.." part and put "delete file <tPathname>").
>
> I know that other apps can use files and then it will be possible to delete
> such files for good reasons. But that is not the case here.
>
> I can investigate other possibilities, but nevertheless, it should work in
> such directory. If I find the time to check out the error also looking at
> the system message, I will do and post if there is anything that makes it
> more clear.
>
> Thanks Richard for posting your additional error investigation. I will
> check it out later as currently I am in a rush job.
>
> Your posting:
>> delete file tFile
>> if the result is not empty then
>> answer the result &" ("& sysError() &")"
>> end if
>
> Regards to everyone here
> Roland
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list