Internal directory
-
@Andre
the QAFE subclass would not solve the problem, as it only works with Qt classes, but not with the external library that takes the const char pointer - that is not aware of the RAM disk.The problem in its current presentation is unsolvable. As long as your library behaves kind of "external" to Qt, you will have to pass it a const char pointer. That points to a file that must be readable by the user running the process. So any other process run by the same user can access the file too.
And I agree with fluca1978, you either over estimate the problem or - if security is of such a big concern - saving it somewhere is the error in the first place.
Don't waste your time in the file mapping approach. It maps existing files into memory. You will have to save to the file beforehand.
-
[quote author="Volker" date="1323695271"]@Andre
the QAFE subclass would not solve the problem, as it only works with Qt classes, but not with the external library that takes the const char pointer - that is not aware of the RAM disk.
[/quote]
Right, I missed that comment. In that case, the suggestion I gave for Linux is also not going to work. You will need to solve this as the OS level, if possible, but I am not aware of process-private ram-disc implementations.I agree with Fluca1978: why is it so important for you that you cannot use temporary files on the normal file system that are potentialy visible to the user (and other users) of the system?
-
I believe that the real problem is about leaving this files around the system for a while, so I will search for another solution like making the file hidden, place it into random destinations (to avoid the user to understand where the file is going to be saved), and so on.
By the way, the best solution is to have the library to work with a stream, if possible. -
I would not just save the file in random places. A determined user will find them anyway (the OS can tell you what files are used by what process). More and more platforms will constrict applications' writing permissions to certain designated directories. It is a good idea to make your application well-behaved, and prevent spreading temporary files all over the system. Who cleans them up if your application (or the system as a whole) crashes?
I agree that the library accepting streams instead of files is best. Otherwise, you might considder encrypting the file before storing it (and having the lib able to decrypt again).
-
[quote author="Andre" date="1323702149"]I would not just save the file in random places. A determined user will find them anyway (the OS can tell you what files are used by what process). [/quote]
Right. I was thinking about a directory tree, let say localstorage populated with random directories which contain random named files, so that it is quite difficult for a user that does not know how to use lsof (or similar) to understand where the file is. Of course, to get a possibility to clean up everything, there must be a common ancestor. But this is a kind of desperate-poor-developer solution!
-
Qt5 will have QTemporaryDir - maybe you should look into that area? I think the code is already in the repository.
-
[quote author="Andre" date="1323721023"]Well, as you only need a single file (or just a few files, right?), you can probably just use [[doc:QTemporaryFile]].[/quote]
Unfortunately, QTemporaryFile has a valid path name only as long as it's open. As soon as you close it, the path name is reset/invalid. I had problems using that together with an external library that takes const char pointers for file paths too (GraphicsMagick in that case).