-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexternalghostscript.h
75 lines (67 loc) · 1.58 KB
/
externalghostscript.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef EXTERNALGHOSTSCRIPT_H
#define EXTERNALGHOSTSCRIPT_H
#include "dirtreewalker.h"
#include "searchpath.h"
#include "debug.h"
#include "externalprog.h"
#include "util.h"
#ifdef WIN32
#include <w32api.h>
#define _WIN32_IE IE5
#define _WIN32_WINNT Windows2000
#include <shlobj.h>
#endif
class ExternalGhostScript : public ExternalProgram
{
public:
ExternalGhostScript() : ExternalProgram()
{
SetDefaultPath();
}
virtual ~ExternalGhostScript()
{
}
virtual void SetDefaultPath()
{
#ifdef WIN32
// FIXME - Need to scan user's homedir if Ghostscript's not found in Program Files
static char programfiles[MAX_PATH]={0};
SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES,NULL,SHGFP_TYPE(SHGFP_TYPE_CURRENT),programfiles);
Debug[TRACE] << "Program Files path: " << programfiles << std::endl;
// Hunt for a Ghostscript Installation...
DirTreeWalker dtw(programfiles);
DirTreeWalker *w;
while((w=dtw.NextDirectory()))
{
if(MatchBaseName("gs",w->Directory())==0)
{
std::string gspath=FindParent(w->Directory(),"gswin32");
if(gspath.size())
{
Debug[TRACE] << "Adding " << gspath << " to search path" << std::endl;
AddPath(gspath.c_str());
}
}
}
args[0]="gswin32.exe";
Debug[TRACE] << "args[0] is now: " << args[0] << std::endl;
#else
AddPath("/usr/bin:/usr/local/bin");
args[0]="gs";
Debug[TRACE] << "args[0] is now: " << args[0] << std::endl;
#endif
Debug[TRACE] << GetPaths() << std::endl;
}
bool CheckPath()
{
char *path=SearchPaths(args[0].c_str());
if(path)
{
free(path);
return(true);
}
return(false);
}
protected:
};
#endif