From: Markus R. <rol...@us...> - 2007-02-09 16:17:50
|
Update of /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv32688 Modified Files: Tag: WIN32 scriptserver.cpp Log Message: - adapat path construction for init file sourcing Index: scriptserver.cpp =================================================================== RCS file: /cvsroot/simspark/simspark/spark/zeitgeist/scriptserver/scriptserver.cpp,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** scriptserver.cpp 16 May 2006 10:17:32 -0000 1.2 --- scriptserver.cpp 9 Feb 2007 16:17:40 -0000 1.2.2.1 *************** *** 23,26 **** --- 23,27 ---- #include <boost/scoped_array.hpp> #include <sstream> + #include <salt/fileclasses.h> #include "scriptserver.h" #include <zeitgeist/corecontext.h> *************** *** 118,122 **** Class::TCmdProc cmd = ! gMyPrivateContext->GetObject()->GetClass()->GetCmdProc (STR2CSTR(functionName)); --- 119,123 ---- Class::TCmdProc cmd = ! gMyPrivateContext->GetSelection()->GetClass()->GetCmdProc (STR2CSTR(functionName)); *************** *** 125,129 **** if (cmd != 0) { ! out = cmd(static_cast<Object*>(gMyPrivateContext->GetObject().get()), in); } else { --- 126,130 ---- if (cmd != 0) { ! out = cmd(static_cast<Object*>(gMyPrivateContext->GetSelection().get()), in); } else { *************** *** 243,247 **** rb_define_global_function("dirs", RUBY_METHOD_FUNC(dirs), 0); ! mRelPathPrefix = "../../"; } --- 244,248 ---- rb_define_global_function("dirs", RUBY_METHOD_FUNC(dirs), 0); ! mRelPathPrefix = string("..") + salt::PathSeparator + ".." + salt::PathSeparator; } *************** *** 471,475 **** { // run the init script in the sourceDir ! string sourcePath = sourceDir + "/" + name; GetLog()->Debug() << "(ScriptServer) Running " << sourcePath << "... "; --- 472,476 ---- { // run the init script in the sourceDir ! string sourcePath = sourceDir + salt::PathSeparator + name; GetLog()->Debug() << "(ScriptServer) Running " << sourcePath << "... "; *************** *** 494,498 **** } ! string destPath = destDir + "/" + name; GetLog()->Normal() << "Copying " << sourcePath --- 495,499 ---- } ! string destPath = destDir + salt::PathSeparator + name; GetLog()->Normal() << "Copying " << sourcePath *************** *** 515,519 **** } ! char* home = getenv("HOME"); if (!home) { --- 516,527 ---- } ! const char* envName = ! #ifdef WIN32 ! "USERPROFILE"; ! #else ! "HOME"; ! #endif ! ! char* home = getenv(envName); if (!home) { *************** *** 522,527 **** } ! dotDir = string(home) + "/" + mDotName; ! return true; } --- 530,534 ---- } ! dotDir = string(home) + salt::PathSeparator + mDotName; return true; } *************** *** 531,535 **** --- 538,546 ---- { char cwd[PATH_MAX+1]; + #if WIN32 + if (GetCurrentDirectory(PATH_MAX, cwd) == 0) + #else if (getcwd(cwd,sizeof(cwd)) == NULL) + #endif { GetLog()->Error() *************** *** 538,542 **** --- 549,557 ---- } + #if WIN32 + if (! SetCurrentDirectory(dotDir.c_str())) + #else if (chdir(dotDir.c_str()) == 0) + #endif { // dot dir exists; change back to original directory *************** *** 546,550 **** --- 561,569 ---- // dot dir is not existent, try to create it + #if WIN32 + if (! CreateDirectory(dotDir.c_str(), 0)) + #else if (mkdir(dotDir.c_str(),0777) != 0) + #endif { GetLog()->Error() << "(ScriptServer) ERROR: Cannot create directory '" *************** *** 569,572 **** --- 588,594 ---- CreateDotDir(dotDir); + #ifdef WIN32 + string pkgdatadir = "c:\\"; + #else // some macro magic (not at all) string pkgdatadir = PREFIX "/share/" PACKAGE_NAME; *************** *** 575,580 **** //std::cout << "pkgdatadir = " << pkgdatadir << std::endl; //std::cout << "filename = " << fileName << std::endl; ! ERunScriptErrorType result; if (validDotDir) --- 597,603 ---- //std::cout << "pkgdatadir = " << pkgdatadir << std::endl; //std::cout << "filename = " << fileName << std::endl; + #endif ! ERunScriptErrorType result = eNotFound; if (validDotDir) *************** *** 586,627 **** { GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << dotDir << "/" << fileName << "'\n"; return true; } ! if (result == eNotFound) { GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << dotDir << "/" << fileName << "'\n"; } else if (result == eError) { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << dotDir << "/" << fileName << "'\n"; return false; } - ! // result = RunInitScriptInternal(pkgdatadir, fileName, validDotDir, dotDir); ! if (result == eOK) { GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << pkgdatadir << "/" << fileName << "'\n"; return true; } ! if (result == eNotFound) { GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << pkgdatadir << "/" << fileName << "'\n"; } else if (result == eError) { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << pkgdatadir << "/" << fileName << "'\n"; ! } ! result = RunInitScriptInternal(mRelPathPrefix+relPath, fileName, validDotDir, dotDir); --- 609,650 ---- { GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << dotDir << salt::PathSeparator << fileName << "'\n"; return true; } ! if (result == eNotFound) { GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << dotDir << salt::PathSeparator << fileName << "'\n"; } else if (result == eError) { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << dotDir << salt::PathSeparator << fileName << "'\n"; return false; } ! ! // result = RunInitScriptInternal(pkgdatadir, fileName, validDotDir, dotDir); ! if (result == eOK) { GetLog()->Debug() << "(ScriptServer) : Ran init script '" ! << pkgdatadir << salt::PathSeparator << fileName << "'\n"; return true; } ! if (result == eNotFound) { GetLog()->Debug() << "(ScriptServer) : Did not find init script '" ! << pkgdatadir << salt::PathSeparator << fileName << "'\n"; } else if (result == eError) { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << pkgdatadir << salt::PathSeparator << fileName << "'\n"; ! } ! result = RunInitScriptInternal(mRelPathPrefix+relPath, fileName, validDotDir, dotDir); *************** *** 635,641 **** { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << mRelPathPrefix+relPath << "/" << fileName << "'\n"; } ! return (result == eOK); } --- 658,664 ---- { GetLog()->Error() << "(ScriptServer) ERROR: Found error in init script '" ! << mRelPathPrefix+relPath << salt::PathSeparator << fileName << "'\n"; } ! return (result == eOK); } |