Skip to content

Commit

Permalink
Some cygwin/mingw don't know about SHGetKnownFolderPath
Browse files Browse the repository at this point in the history
You can check if you have it with
nm -a /usr/i686-w64-mingw32/sys-root/mingw/lib/libshfolder.a | less
Workaround by using older (MSVC deprecated) SHGetFolderPathW

Also force MY_DOCUMENTS_VAR as WCHAR, since it is used thru SetEnvironmentVariableW

Also add a few missing return
  • Loading branch information
nicolas-cellier-aka-nice committed Jul 26, 2016
1 parent dc3df9b commit 4f87bc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.win32x86/common/Makefile.tools
Expand Up @@ -63,7 +63,7 @@ LDFLAGS:= -mwindows $(BASELDFLAGS)
CONSOLELDFLAGS:= -mconsole $(BASELDFLAGS)
STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \
-lversion -lwininet -luser32 -lgdi32 -lpsapi -lkernel32 \
-ldsound -lsecur32
-ldsound -lsecur32 -lshfolder

#############################################################################
# Tools to use
Expand Down
2 changes: 1 addition & 1 deletion build.win64x64/common/Makefile.tools
Expand Up @@ -63,7 +63,7 @@ LDFLAGS:= -mwindows $(BASELDFLAGS)
CONSOLELDFLAGS:= -mconsole $(BASELDFLAGS)
STDLIBS:= -lddraw -ldinput -lopengl32 -lws2_32 -lcomdlg32 -lole32 -lwinmm \
-lversion -lwininet -luser32 -lgdi32 -lpsapi -lkernel32 \
-ldsound -lsecur32
-ldsound -lsecur32 -lshfolder

#############################################################################
# Tools to use
Expand Down
13 changes: 11 additions & 2 deletions platforms/win32/plugins/SecurityPlugin/sqWin32Security.c
Expand Up @@ -135,6 +135,7 @@ int ioCanSetFileTypeOfSize(char* pathString, int pathStringLength) {
/* disabling/querying */
int ioDisableFileAccess(void) {
allowFileAccess = 0;
return 0;
}

int ioHasFileAccess(void) {
Expand All @@ -158,6 +159,7 @@ sqInt ioCanWriteImage(void) {

sqInt ioDisableImageWrite(void) {
allowImageWrite = 0;
return 0;
}
/***************************************************************************/
/***************************************************************************/
Expand All @@ -180,6 +182,7 @@ int ioCanListenOnPort(void* s, int port) {

int ioDisableSocketAccess() {
allowSocketAccess = 0;
return 0;
}

int ioHasSocketAccess() {
Expand Down Expand Up @@ -219,10 +222,16 @@ int ioInitSecurity(void) {
}

#define MY_SQUEAK TEXT("\\My Squeak")
#define MY_DOCUMENTS_VAR TEXT("MYDOCUMENTS")
#define MY_DOCUMENTS_VAR L"MYDOCUMENTS"

#ifdef _MSC_VER
PWSTR documentsPath = NULL;
if (S_OK == SHGetKnownFolderPath(&FOLDERID_Documents, 0, NULL, &documentsPath)) {
if (S_OK == SHGetKnownFolderPath(&FOLDERID_Documents, 0, NULL, &documentsPath))
#else
WCHAR documentsPath[MAX_PATH];
if (S_OK == SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, documentsPath))
#endif
{
#if defined(UNICODE)
RECALLOC_OR_RESET(tUntrustedUserDirectory,
wcslen(documentsPath) + _tcslen(MY_SQUEAK) + 1 /* \0 */,
Expand Down

0 comments on commit 4f87bc4

Please sign in to comment.