Jump to content
Sign in to follow this  
LWC

Defeating Qt's QDir::homePath()

Recommended Posts

LWC

The Qt open source Kapow punch clock program uses QDir::homePath() to locate its data file:

main.cpp (from Kapow's source code):

QString path = QDir::homePath() + "/Application Data/GottCode/Kapow/";

So I hoped to portabilize it by making AutoIt use:

EnvSet("USERPROFILE", "a local path")

Alas, Kapow ignored it. I therefore looked at Qt's documentation:

QString QDir::homePath () [static]

Returns the absolute path of the user's home directory.

Under Windows this function will return the directory of the current user's profile. Typically, this is:

C:/Documents and Settings/Username

If the directory of the current user's profile does not exist or cannot be retrieved, the following alternatives will be checked (in the given order) until an existing and available path is found:

1. The path specified by the USERPROFILE environment variable.

...

Can AutoIt somehow make Kapow think that this folder "does not exist or cannot be retrieved" and therefore use %HOMEPATH% instead?

If not, is there a Qt expert in here that wishes to update Kapow's source code (the author blogged and twitted that he went AWOL) to accept a "/data=[path]" command line parameter?

P.S.

Kapow does have a portable mode, but it's hardcoded for one path ("..kapowdata") which is a problem in a multi-user environment.

Share this post


Link to post
Share on other sites
ProgAndy

If you need it only for Windows Vista +, then you could use the portable mode and a symlink (command: mklink /d)

You could also try the EnvSet("HOMEPATH", ...) and then Run(...)

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
LWC

Thanks. However:

I also need it for XP. But the symlink wouldn't work for multiple users anyway.

As for the other suggestion:

Alas, Kapow ignored it. I therefore looked at Qt's documentation:

Edited by LWC

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×