PDA

View Full Version : Symlink or Shortcut to file for fake Extension



janton
16th March 2012, 12:32
Dear QT Developers,

I'm not really a developer but i try to help out our developer by looking for information.

Short explenation:
We use a API from a different program, with this API we open a File. This API respons on the extension type from that file.
In some cases we want to fool the program to make it think it's a different extension.
For example movie.mov we want to open movie.fake but infact it opens that movie.mov but the API thinks it opens movie.fake
We can not change the file extension because it's being extracted.

I though perhaps we can create a shortcut to that file with a different extension and try to open that! I tried in windows explorer by creating a shortcut, well it did open the file but still with the same extension (even that I changed extension from the shortcut)

Then i though about symlinking the file, so to test this i uses "mklink" in cmd/dos on windows.
mklink /h movie.fake movie.mov
This did work :-) but this only works on windows and needs administrator rights. :(


Perhaps there is a easier way to fool a program to open a file but giving it a fake/different extension?

janton
23rd March 2012, 17:22
I guess this is a bit specific and difficult to do.. still i continue to search for the answer!
If i have one i will report it here!

ChrisW67
26th March 2012, 22:38
The way to tackle this is to avoid relying on the API call that assumes the file extension means something. Work out what application you wish to open the file with, and launch that application passing the file name as an argument (which generally opens the document).