Skip to content

Commit

Permalink
Win32 typo fixed. substitute_homedir now supports on Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
Alastair Robinson committed May 29, 2010
1 parent ac689ab commit 5472dff
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion stp_support/printerqueues_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void pqp_buildqueuelist(struct pqprivate *pp)
{
for ( dwItem = 0; dwItem < dwNumItems; dwItem++ )
{
fprintf(stderr,"Creating printer node for: %s\n",lpINfo[dwItem].pPrinterName);
fprintf(stderr,"Creating printer node for: %s\n",lpInfo[dwItem].pPrinterName);
printernode_create(pp,lpInfo[dwItem].pPrinterName);
}
}
Expand Down
33 changes: 27 additions & 6 deletions support/pathsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,36 @@ const char *get_homedir()
char *substitute_homedir(const char *path)
{
char *result=NULL;
const char *subst=NULL;
if(path)
{
if(path[0]=='~')
// First try to substitute a "$HOME_PICTURES" path. On Win32 this will be My Pictures.
// On UNIX we'll just use $HOME for now.
if(strncmp(path,"$HOME_PICTURES",15)==0)
{
path+=15;
#ifdef WIN32
static char pixdir[MAX_PATH]={0};
static bool init=false;
if(!init)
{
SHGetFolderPath(NULL,CSIDL_COMMON_PICTURES,NULL,SHGFP_TYPE(SHGFP_TYPE_CURRENT),pixdir);
}
subst=pixdir;
#else
subst=get_homedir();
#endif
}
else if(path[0]=='~')
{
++path;

subst=get_homedir();
}
else if(strncmp(path,"$HOME",5)==0)
{
path+=5;

subst=get_homedir();
}
else // No substitution to be done...
return(strdup(path));

Expand All @@ -57,11 +79,10 @@ char *substitute_homedir(const char *path)

// If we get this far, then we need to substitute - and path now points
// to the beginning of the path proper...
const char *hd=get_homedir();

result=(char *)malloc(strlen(path)+strlen(hd)+2);
result=(char *)malloc(strlen(path)+strlen(subst)+2);

sprintf(result,"%s%c%s",hd,SEARCHPATH_SEPARATOR,path);
sprintf(result,"%s%c%s",subst,SEARCHPATH_SEPARATOR,path);
}
return(result);
}
Expand Down

0 comments on commit 5472dff

Please sign in to comment.