KTemporaryFile::createLocalFile()

Matthew Woehlke mw_triad at users.sourceforge.net
Thu Jul 5 16:59:32 BST 2007


Dominik Haumann wrote:
> Hi,
> 
> QTemporaryFile has static functions
>   QTemporaryFile * createLocalFile ( QFile & file )
>   QTemporaryFile * createLocalFile ( const QString & fileName )
> 
> We have the following scenario in Kate:
>  1. somehow get a (temporary) file that is not deleted
>  2. run a diff programm and write the data to this file
>  3. call KRun::runUrl() to open kompare to show the diff
>  4. as kompare has the option X-KDE-HasTempFileOption it will remove
>     the file on application exit
> 
> The code to solve (1) right now looks like this:
> 
>   KTemporaryFile tmpfile;
>   tmpfile.setAutoRemove(false);
>   tmpfile.open();
>   QString fileName = tmpfile.fileName();
>   tmpfile.close();
> 
> K/QTemporaryFile does not provide this functionality directly, the attached patch adds 
>   QString KTemporaryFile::createLocalFile()
> with the above implementation.
> 
> Do we want that / ok to commit?
> If so, do I have to wait for a monday or what are the terms right now?

Current terms are (AFAIK) to wait a week for feedback, except of course 
you already have two objections to the patch.

What is wrong with this doing this?
1. open file
2. run diff program that outputs to stdout
3. in your process, read stdout from (2) and write to the file in (1)
4. tmpfile.fileName();
5. run Kompare, passing to it (4)
6. when done with Kompare, close the file

Of course, plumbing everything together with pipes would be better still.

-- 
Matthew
Disadvantage: Bad Puns [-5]
You constantly utter puns so egregious as to cause mental distress to 
anyone hearing them. This can, however, be used to distract enemies.





More information about the kde-core-devel mailing list