27 # define getenv _wgetenv
28 # define getcwd _wgetcwd
34 # include <Carbon/Carbon.h>
59 std::string * Utf8 =
new std::string[argc];
67 int intArgC = (int) argc;
70 for (i = 0; i < argc; ++i)
79 for (i = 0; i < argc; ++i)
100 char **ArgV =
new char * [argc];
103 for (i = 0; i < argc; i++)
105 if (Utf8[i] ==
"-sbwregister")
107 else if (Utf8[i] ==
"-sbwmodule")
111 ArgV[ArgC] = strdup(Utf8[i].c_str());
118 pPreParser->
parse(ArgC, ArgV);
150 std::vector< std::string >::const_iterator it = pPreParser->
get_non_options().begin();
151 std::vector< std::string >::const_iterator end = pPreParser->
get_non_options().end();
153 for (; it != end; ++it)
158 std::string CopasiDir;
163 if (CopasiDir.empty() && argc > 0)
198 setValue(
"WizardDir", CopasiDir +
"/Contents/Resources/doc/html");
200 setValue(
"DefaultConfigDir", CopasiDir +
"\\share\\copasi\\config");
201 setValue(
"ExampleDir", CopasiDir +
"\\share\\copasi\\examples");
202 setValue(
"WizardDir", CopasiDir +
"\\share\\copasi\\doc\\html");
203 #else // All Unix flavors have the same installation structure.
204 setValue(
"DefaultConfigDir", CopasiDir +
"/share/copasi/config");
205 setValue(
"ExampleDir", CopasiDir +
"/share/copasi/examples");
206 setValue(
"WizardDir", CopasiDir +
"/share/copasi/doc/html");
229 setValue(
"ImportSEDML", Options.ImportSEDML);
234 for (i = 0; i < ArgC; i++)
245 optionType::iterator begin =
mOptions.begin();
246 optionType::iterator end =
mOptions.end();
248 for (; begin != end; begin++)
pdelete(begin->second);
262 std::string CopasiDir;
270 DWORD PrgNameSize = 256;
274 while (!(Returned = GetModuleFileNameW(NULL, PrgName, PrgNameSize)) ||
275 PrgNameSize == Returned)
277 if (GetLastError() != ERROR_ALREADY_EXISTS)
305 CFBundleRef MainBundleRef = NULL;
306 MainBundleRef = CFBundleGetMainBundle();
308 if (MainBundleRef != NULL)
310 CFURLRef pluginRef = NULL;
311 pluginRef = CFBundleCopyBundleURL(MainBundleRef);
313 if (pluginRef != NULL)
315 CFStringRef macPath = NULL;
316 macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
320 CFIndex size = CFStringGetLength(macPath);
321 char* cString =
new char[size + 1];
322 CFStringGetCString(macPath, cString, size + 1, kCFStringEncodingUTF8);
343 size_t PWDSize = 256;
348 while (!(PWD = getcwd(NULL, PWDSize)))
350 if (errno != ERANGE)
break;
381 std::ostringstream error;
383 <<
" use --home HOME" << std::endl
384 <<
" or set the environment variable HOME" << std::endl
385 <<
" to point to your home directory" << std::endl;
395 std::string Temp, User, CreateCopasiDir, CreateUserDir;
405 if (User ==
"") User =
"CopasiUser";
420 CreateUserDir = CreateCopasiDir + CDirEntry::Separator + User;
426 Temp = CreateCopasiDir;
432 Temp = CreateUserDir;
450 std::string ConfigDir;
static void setValue(const std::string &name, const CType &value)
static bool isDir(const std::string &path)
static bool isRelativePath(const std::string &path)
static std::string getCopasiDir(void)
static std::string getPWD(void)
static std::string getConfigFile(void)
static std::string dirName(const std::string &path)
static const nonOptionType & getNonOptions()
SBMLSchema_enum SBMLSchema
static std::string getEnvironmentVariable(const std::string &name)
static bool compareValue(const std::string &name, const CType &value)
static bool createDir(const std::string &dir, const std::string &parent="")
static optionType mOptions
static const std::string Separator
static bool isWritable(const std::string &path)
const std::vector< std::string > & get_non_options(void) const
get a list of nonoptions from the command line
std::map< std::string, COptionValue * > optionType
std::string ExportBerkeleyMadonna
static std::string getConfigDir(void)
static void getValue(const std::string &name, CType &value)
std::string toUtf8() const
const options & get_options(void) const
get the main options
static nonOptionType mNonOptions
void parse(int argc, char *argv[], bool call_finalize=true)
parse the command line
static std::string getHome(void)
std::vector< std::string > nonOptionType
static CLocaleString fromUtf8(const std::string &utf8)
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
static std::string getTemp(void)
static void init(C_INT argc=0, char *argv[]=NULL)
#define CONSTRUCTOR_TRACE