Mercurial > dwindows
comparison win/dw.c @ 1381:3ba4853d5b78
Initial attempt at dw_app_dir() for OS/2, Windows and Mac...
This function will return the best attempt at determining the application data directory for the current platform. The executable directory on OS/2 or Windows. The application bundle directory on Mac. The "share" folder at the same level as the binary (or /usr/local/share if that can't be determined) plus the binary name on Unix.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 25 Nov 2011 17:36:59 +0000 |
parents | cc66b6d4b74e |
children | 156e32814c83 |
comparison
equal
deleted
inserted
replaced
1380:cc66b6d4b74e | 1381:3ba4853d5b78 |
---|---|
141 * the contents of the image to so it can be loaded by the Win32 API | 141 * the contents of the image to so it can be loaded by the Win32 API |
142 * We use _tempnam() which uses TMP env variable by default. It can be passed | 142 * We use _tempnam() which uses TMP env variable by default. It can be passed |
143 * an alternate temporary directory if TMP is not set, so we get the value | 143 * an alternate temporary directory if TMP is not set, so we get the value |
144 * of TEMP and store it here. | 144 * of TEMP and store it here. |
145 */ | 145 */ |
146 static char _dw_alternate_temp_dir[MAX_PATH+1]; | 146 static char _dw_alternate_temp_dir[MAX_PATH+1] = {0}; |
147 static char _dw_exec_dir[MAX_PATH+1] = {0}; | |
147 | 148 |
148 int main(int argc, char *argv[]); | 149 int main(int argc, char *argv[]); |
149 | 150 |
150 #define ICON_INDEX_LIMIT 200 | 151 #define ICON_INDEX_LIMIT 200 |
151 HICON lookup[200]; | 152 HICON lookup[200]; |
3647 char *alttmpdir; | 3648 char *alttmpdir; |
3648 #ifdef GDIPLUS | 3649 #ifdef GDIPLUS |
3649 struct GdiplusStartupInput si; | 3650 struct GdiplusStartupInput si; |
3650 #endif | 3651 #endif |
3651 | 3652 |
3653 /* Setup the private data directory */ | |
3654 if(argc > 0 && argv[0]) | |
3655 { | |
3656 char *pos = strrchr(argv[0], '\\'); | |
3657 | |
3658 /* Just to be safe try the unix style */ | |
3659 if(!pos) | |
3660 pos = strrchr(argv[0], '/'); | |
3661 | |
3662 if(pos) | |
3663 strncpy(_dw_exec_dir, argv[0], (size_t)(pos - argv[0])); | |
3664 } | |
3665 /* If that failed... just get the current directory */ | |
3666 if(!_dw_exec_dir[0]) | |
3667 GetCurrentDirectory(MAX_PATH, _dw_exec_dir); | |
3668 | |
3652 /* Initialize our thread local storage */ | 3669 /* Initialize our thread local storage */ |
3653 _foreground = TlsAlloc(); | 3670 _foreground = TlsAlloc(); |
3654 _background = TlsAlloc(); | 3671 _background = TlsAlloc(); |
3655 _hPen = TlsAlloc(); | 3672 _hPen = TlsAlloc(); |
3656 _hBrush = TlsAlloc(); | 3673 _hBrush = TlsAlloc(); |
10712 } | 10729 } |
10713 return _user_dir; | 10730 return _user_dir; |
10714 } | 10731 } |
10715 | 10732 |
10716 /* | 10733 /* |
10734 * Returns a pointer to a static buffer which containes the | |
10735 * private application data directory. | |
10736 */ | |
10737 char *dw_app_dir(void) | |
10738 { | |
10739 return _dw_exec_dir; | |
10740 } | |
10741 | |
10742 /* | |
10717 * Call a function from the window (widget)'s context. | 10743 * Call a function from the window (widget)'s context. |
10718 * Parameters: | 10744 * Parameters: |
10719 * handle: Window handle of the widget. | 10745 * handle: Window handle of the widget. |
10720 * function: Function pointer to be called. | 10746 * function: Function pointer to be called. |
10721 * data: Pointer to the data to be passed to the function. | 10747 * data: Pointer to the data to be passed to the function. |