Example #1
0
String GetExeFileTypeAssociation(const String ext) {

	String buff = GetWinRegString("", GetWinRegString("", ext, HKEY_CLASSES_ROOT) + String("\\Shell\\Open\\Command"), HKEY_CLASSES_ROOT);
	buff = buff.Left(buff.Find(".exe")+4);
	if(buff.Left(1) == "\"") return buff.Right(buff.GetCount() - 1);
	else return buff;
}
Example #2
0
String MIValue::Dump(int level) const
{
	String spacer(' ', level);
	switch(type)
	{
		case MIString:
			return spacer + MARK_STRING + Dump(string);

		case MITuple:
		{
			String s = spacer + MARK_TUPLE + "{\n";
			level += 4;
			spacer = String(' ', level);
			for(int i = 0; i < tuple.GetCount(); i++)
			{
				String s1 = spacer + tuple.GetKey(i) + "=";
				s += s1;
				MIValue const &val = tuple[i];
				if(val.type == MIString)
					s += val.Dump();
				else
				{
					s += '\n' + val.Dump(level + 4);
					s = s.Left(s.GetCount()-1);
				}
				if(i < tuple.GetCount() - 1)
					s += ',';
				s += '\n';
			}
			level -= 4;
			spacer = String(' ', level);
			s += spacer + "}\n";
			return s;
		}

		case MIArray:
		{
			String s = spacer + MARK_ARRAY + "[ \n";
			level += 4;
			for(int i = 0; i < array.GetCount(); i++)
			{
				MIValue const &val = array[i];
				s += val.Dump(level);
				if(val.type != MIString)
					s = s.Left(s.GetCount()-1);
				if(i < array.GetCount() - 1)
					s += ',';
				s += '\n';
			}
			s += spacer + "]\n";
			return s;
		}
		
		default:
			return spacer + "*UNKNOWN MIVALUE TYPE*";
	}
}
Example #3
0
   void 
   Language::_CleanString(String &sText) 
   {
      // Remove lading "&"
      if (sText.Left(1) == _T("&"))
         sText = sText.Mid(1);

      // Remove trailing "..."
      if (sText.Right(3) == _T("..."))
         sText = sText.Left(sText.GetLength() - 3);

   }
   void
   IMAPFetchParser::_CleanFetchString(String &sString)
   {
      if (sString.Left(1) == _T(" "))
         sString = sString.Mid(1);
      
      if (sString.Left(1) == _T("("))
         sString = sString.Mid(1);

      if (sString.Right(1) == _T(")"))
         sString = sString.Mid(0, sString.GetLength() - 1);
      

   }
Example #5
0
bool							clsIGInterface::Open(const String& sDevice)
{
	Close();

	try
		{
		clsCritObj	CO(_Crit);

		if (sDevice.Left(4) == "USB:")
			{
			_pIO = new clsUSBIO(this);
			}
		  else
		if (sDevice.Left(4) == "COM:")
			{
			_pIO = new clsRS232IO(this,57600);
			}
		  else
		if (sDevice.Left(5) == "FTDI:")
			{
			_pIO = new clsFTDIIO(this,57600);
			}
		  else
		if (sDevice.Left(8) == "FTDIW32:")
			{
			_pIO = new clsFTDIW32IO(this,57600);
			}
		  else
			{
			throw clsExcept("port '%s' has unknown format",(LPCTSTR)sDevice);
			}

		if (_pIO == NULL)
			{
			return(false);
			}
		if (!_pIO->IOOpen(sDevice.GetToken(1,':')))
			{
			Close();
			return(false);
			}
		}
	catch (clsExcept& e)
		{
		Close();
		throw;
		}

	return(true);
}
Example #6
0
String ChangeTopicLanguage(const String &topic, int lang) {
	int pos = topic.ReverseFind('$');
	if (pos < 0)
		return "";			
	String langtxt = ToLower(LNGAsText(lang));		
	return topic.Left(pos+1) + langtxt + topic.Mid(pos+1+langtxt.GetCount()); 
}
Example #7
0
bool IsQuoted(const String &s) {
	
	if(s.Left(1) == "\"" && s.Right(1) == "\"") {
		return true;	
	}
	return false;	
}
Example #8
0
void OutMode::CmdOptions()
{
	const Workspace& wspc = ide.IdeWorkspace();
	int pi = wspc.GetCount() > 0 ? 0 : -1;
	if (pi < 0) {
		PromptOK("No main package");
		return;
	}
	VectorMap<String, String> bm = ide.GetMethodVars(~method);
	if (bm.GetCount() == 0) {
		PromptOK("Invalid build method");
		return;
	}
	One<Host> host = ide.CreateHost(false);
	One<Builder> b = ide.CreateBuilder(~host);
	const String& p = wspc[pi];
	String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true));
	if (output.Right(1) == ".")
		output = output.Left(output.GetCount() - 1);
	const ModePane& pane = ~mode == 0 ? debug : release;
	int blitzpackage = pane.package.Get(0, 2);
	bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz
		&& (IsNull(blitzpackage) ? true : blitzpackage);
	CmdBuildOptionsWindow window(p, ~method, ~config, output,
		~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild);
	LoadFromGlobal(window, "CmdBuildOptionsWindow");
	window.GenerateCmd();
	window.Run();
	StoreToGlobal(window, "CmdBuildOptionsWindow");
}
Example #9
0
   String 
   Utilities::GetWin32TempDirectory()
   {
      // No username specified. Fetch local computer name.
      if (!m_sCachedWin32TempDir.IsEmpty())
         return m_sCachedWin32TempDir;

      
      unsigned long iSize = 255;
      TCHAR pCharBuf[255];
      
      if (::GetTempPath(iSize, pCharBuf) != 0)
      {
         String sShort = pCharBuf;

         if (sShort.Right(1) == _T("\\"))
            sShort = sShort.Left(sShort.GetLength() - 1);

         m_sCachedWin32TempDir = FileUtilities::GetLongPath(sShort);
        
      }

      return m_sCachedWin32TempDir;

   }
Example #10
0
   bool 
   IMAPFolder::IsValidFolderName(const std::vector<String> &vecPath, bool bIsPublicFolder)
   {
      if (vecPath.size() > IMAPFolder::MaxFolderDepth)
         return false;

      if (vecPath.size() < 1)
         return false;

      if (!bIsPublicFolder)
      {
         String s = vecPath[0];

         if (s.Left(1) == _T("#"))
            return false;
      }

      std::vector<String>::const_iterator iter = vecPath.begin();
      std::vector<String>::const_iterator iterEnd = vecPath.end();
      for (; iter != iterEnd; iter++)
      {
         String s = (*iter);
         
         if (s.GetLength() == 0 || s.GetLength() > 255) 
            return false;
      }

      return true;
   }
Example #11
0
File: main.cpp Project: WangHoi/slc
bool ParseArguments(int argc, char* argv[]) {
    g_options.output_type = PROGRAM_OUTPUT_OPENGL;
    g_options.arguments.resize(argc);
    for (int i = 0; i < argc; ++i) g_options.arguments[i].Set(argv[i]);

    if (argc < 3) return false;
    int i = 1;
    bool has_input = false;
    bool has_output = false;
    while (i < argc) {
        String arg = g_options.arguments[i];
        if (arg == "-gl") {
            g_options.output_type = PROGRAM_OUTPUT_OPENGL;
            ++i;
        } else if (arg == "-dx") {
            g_options.output_type = PROGRAM_OUTPUT_DIRECTX;
            ++i;
        } else if (arg.Left(2) == "-D") {
            g_options.defines.push_back(arg.Substr(2));
            ++i;
        } else if (!has_input) {
            has_input = true;
            g_options.input_filename = arg;
            ++i;
        } else if (!has_output) {
            has_output = true;
            g_options.output_filename = arg;
            ++i;
        } else break;
    }
    return true;
}
Example #12
0
template<> void Jsonize(JsonIO& io, Date& var)
{
	if(io.IsLoading()) {
		const Value& v = io.Get();
		if(IsNull(v)) {
			var = Null;
			return;
		}
		if(IsString(v)) {
			String text = v;
			if(text.GetCount() > 6) {
				Date d;
				d.year = ScanInt(text.Left(4));
				d.month = ScanInt(text.Mid(4, 2));
				d.day = ScanInt(text.Mid(6));
				if(d.IsValid()) {
					var = d;
					return;
				}
			}
		}
		throw JsonizeError("string expected for Date value");
	}
	else
		if(IsNull(var))
			io.Set(Null);
		else
			io.Set(Format("%04d%02d%02d", var.year, var.month, var.day));
}
Example #13
0
bool DriveOpenClose(String drive, bool open)
{
	int operation;
	if (open)
		operation = IOCTL_STORAGE_EJECT_MEDIA;
	else
		operation = IOCTL_STORAGE_LOAD_MEDIA;
	if (drive.IsEmpty())
		return false;
	else if (drive.GetCount() == 1)
		drive += ":";
	else {
		drive = drive.Left(2);
		if (drive[1] != ':')
			return false;
	}
	HANDLE hDrive;
	hDrive = CreateFile("\\\\.\\" + drive, GENERIC_READ || GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
	if (hDrive == INVALID_HANDLE_VALUE)
		return false;
	bool ret = false;
	DWORD dummyBytesReturned;
	if (DeviceIoControl(hDrive, operation, 0, 0, 0, 0, &dummyBytesReturned, 0))
		ret = true;
  	CloseHandle(hDrive);
  	return ret;
}
Example #14
0
template<> void Jsonize(JsonIO& io, Time& var)
{
	if(io.IsLoading()) {
		const Value& v = io.Get();
		if(IsNull(v)) {
			var = Null;
			return;
		}
		if(IsString(v)) {
			String text = v;
			if(text.GetCount() > 15) {
				Time tm;
				tm.year = ScanInt(text.Left(4));
				tm.month = ScanInt(text.Mid(4, 2));
				tm.day = ScanInt(text.Mid(6, 2));
				tm.hour = ScanInt(text.Mid(9, 2));
				tm.minute = ScanInt(text.Mid(12, 2));
				tm.second = ScanInt(text.Mid(15));
				if(tm.IsValid()) {
					var = tm;
					return;
				}
			}
		}
		throw JsonizeError("string expected for Time value");
	}
	else
		if(IsNull(var))
			io.Set(Null);
		else
			io.Set(Format("%04d%02d%02d`T%02d:%02d:%02d",
				          var.year, var.month, var.day, var.hour, var.minute, var.second));
}
Example #15
0
String RemoveQuote(const String &str) {

	if(str.Left(1) == "\"" && str.Right(1) == "\"") {
		if(str.GetCount() == 2) return String("");
		return str.Mid(1, str.GetLength()-2);	
	}
	return str;
}
   bool 
   SQLScriptParser::PreprocessLine_(String &sLine)
   {
      // Do some basic preprocessing...
      while (sLine.Left(2).Compare(_T("\r\n")) == 0)
         sLine = sLine.Mid(2);
      
      while (sLine.Left(1).Compare(_T(" ")) == 0)
         sLine = sLine.Mid(1);
     
      while (sLine.Left(1).Compare(_T("\t")) == 0)
         sLine = sLine.Mid(1);


      String sTempLine = sLine;

      if (settings_->GetType() == HM::DatabaseSettings::TypeMSSQLCompactEdition)
      {
         if (sTempLine.ToLower().Left(3).Compare(_T("if ")) == 0)
         {
            return false;
         }
         else if (sLine.FindNoCase(_T(" CLUSTERED ")) >= 0)
         {
            sLine.ReplaceNoCase(_T(" CLUSTERED "), _T(" "));
         }
         else if (sLine.FindNoCase(_T("CREATE PROC")) >= 0)
         {
            // Procedures not supported by SQL CE
            return false;
         }

         sLine.Replace(_T("\t"), _T(" "));
         sLine.Replace(_T(" varchar"), _T(" nvarchar"));

      }

      if (sLine.IsEmpty())
         return false;


      return true;
   }
Example #17
0
// from complete lib name/path (libXXX.so.ver.minVer) gets the link name (libXXX.so)
String CppBuilder::GetSoLinkName(String libName) const
{
	
	String linkName = GetFileName(libName);
	int soPos = ToLower(linkName).ReverseFind(".so");
	if(soPos < 0)
		soPos = linkName.GetCount();
	else
		soPos += 3;
	return linkName.Left(soPos);
}
Example #18
0
 void AddDefine(MacroObjectPtr &mac,const String &s)
   {
     int pos = s.find("=");
     if (pos < 0)
       return;
     String name = s.Left(pos);
     String value = s.Right(-pos-1);
     NamedList_MacroObjAdapter *p = (NamedList_MacroObjAdapter *)mac.get_ptr();
     // printf("adding name %s value %s\n",(const char *)name,(const char *)value);
     p->AddObject(name,new StringMacroObject(value));
     // p->Print(0);
   }
Example #19
0
static String VFKParseDOPLKOD(String s)
{
	const char *p = s;
	while(*p && !(p[0] == '/' && p[1] == ' ' && p[2] == 'D' && p[3] == 'O'
		&& p[4] == 'P' && p[5] == 'L' && p[6] == 'K' && p[7] == 'O' && p[8] == 'D'))
		p++;
	if(!*p)
		return s;
	while(p > s.Begin() && (byte)p[-1] <= ' ')
		p--;
	return s.Left(p - s.Begin());
}
void ColorCalibrationInterface::__EditCompleted( Edit& sender )
{
   try
   {
      String id = sender.Text();
      id.Trim();
      if ( id == TARGET_IMAGE )
         id.Clear();
      if ( !id.IsEmpty() )
      {
         bool valid;
         size_type p = id.Find( "->" );
         if ( p == String::notFound )
            valid = id.IsValidIdentifier();
         else
            valid = id.Left( p ).IsValidIdentifier() && id.Substring( p+2 ).IsValidIdentifier();
         if ( !valid )
            throw Error( "Invalid view identifier: " + id );
      }

      if ( sender == GUI->WhiteReferenceView_Edit )
      {
         instance.whiteReferenceViewId = id;
         sender.SetText( WHITE_REFERENCE_ID );
      }
      else if ( sender == GUI->BackgroundReferenceView_Edit )
      {
         instance.backgroundReferenceViewId = id;
         sender.SetText( BACKGROUND_REFERENCE_ID );
      }
      return;
   }

   catch ( ... )
   {
      if ( sender == GUI->WhiteReferenceView_Edit )
         sender.SetText( WHITE_REFERENCE_ID );
      else if ( sender == GUI->BackgroundReferenceView_Edit )
         sender.SetText( BACKGROUND_REFERENCE_ID );

      try
      {
         throw;
      }

      ERROR_HANDLER

      sender.SelectAll();
      sender.Focus();
   }
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Increments the current file name
// a4.png --> a5.png
// a04.png --> a05.png
// a4b.png --> a5b.png
// xyz.png --> xyz 2.png
void AskForFileNameDlg::IncrementFileName()
{
	if( !m_incrementFileName )
	{
		return;
	}

	String strName = m_fileName;
	String strExt = ".png";
	if( strName.EndsWith(strExt) )
	{
		int nStop = m_fileName.GetLength() - strExt.GetLength();
		strName = strName.Left(nStop);
	}

	int nGroupStart, nGroupStop;
	if( !GetDigitGroup(strName, nGroupStart, nGroupStop) )
	{
		m_fileName = strName + " 2.png";
		return;
	}

	String strNum = strName.Mid(nGroupStart, nGroupStop - nGroupStart);
	int32 nNum;
	if( !strNum.ToInt(nNum) )
	{
		m_fileName = strName + " 2.png";
		return;
	}

	// Check if there are leading 0
	String strSameNum = String::FromInt(nNum);
	String strPrefix = strNum.ReplaceAll(strSameNum, "");
	String strNewNum = strPrefix + String::FromInt(nNum + 1);

	m_fileName = strName.Left(nGroupStart) + strNewNum + strName.Mid(nGroupStop) + ".png";
}
bool
PersistentAccount::ReadObject(boost::shared_ptr<Account> pAccount, boost::shared_ptr<DALRecordset> pRS)
{
    pAccount->SetID(pRS->GetLongValue("accountid"));
    pAccount->SetActive(pRS->GetLongValue("accountactive") ? true : false);
    pAccount->SetADDomain(pRS->GetStringValue("accountaddomain"));
    pAccount->SetAddress(pRS->GetStringValue("accountaddress"));
    pAccount->SetADUsername(pRS->GetStringValue("accountadusername"));
    pAccount->SetDomainID(pRS->GetLongValue("accountdomainid"));
    pAccount->SetAdminLevel((Account::AdminLevel) pRS->GetLongValue("accountadminlevel"));

    pAccount->SetIsAD(pRS->GetLongValue("accountisad") ? true : false);
    pAccount->SetPassword(pRS->GetStringValue("accountpassword"));
    pAccount->SetAccountMaxSize(pRS->GetLongValue("accountmaxsize"));

    pAccount->SetVacationMessageIsOn(pRS->GetLongValue("accountvacationmessageon") ? true : false);
    pAccount->SetVacationMessage(pRS->GetStringValue("accountvacationmessage"));
    pAccount->SetVacationSubject(pRS->GetStringValue("accountvacationsubject"));
    pAccount->SetVacationExpires(pRS->GetLongValue("accountvacationexpires") ? true : false);

    String sVacationExpiresDate = pRS->GetStringValue("accountvacationexpiredate");
    if (sVacationExpiresDate.Left(4) != _T("0000"))
        pAccount->SetVacationExpiresDate(sVacationExpiresDate);

    pAccount->SetForwardEnabled(pRS->GetLongValue("accountforwardenabled") ? true : false);
    pAccount->SetForwardAddress(pRS->GetStringValue("accountforwardaddress"));
    pAccount->SetForwardKeepOriginal(pRS->GetLongValue("accountforwardkeeporiginal") ? true : false);

    pAccount->SetPasswordEncryption(pRS->GetLongValue("accountpwencryption"));

    pAccount->SetEnableSignature(pRS->GetLongValue("accountenablesignature") ? true : false);
    pAccount->SetSignaturePlainText(pRS->GetStringValue("accountsignatureplaintext"));
    pAccount->SetSignatureHTML(pRS->GetStringValue("accountsignaturehtml"));

    pAccount->SetLastLogonTime(pRS->GetStringValue("accountlastlogontime"));

    pAccount->SetPersonFirstName(pRS->GetStringValue("accountpersonfirstname"));
    pAccount->SetPersonLastName(pRS->GetStringValue("accountpersonlastname"));

    if (pAccount->GetPasswordEncryption() == 0)
    {
        // The password isn't encrypted. Encrypt it now using the preferred hash algorithm.
        int preferredHashAlgorithm = IniFileSettings::Instance()->GetPreferredHashAlgorithm();
        pAccount->SetPassword(Crypt::Instance()->EnCrypt(pAccount->GetPassword(), (HM::Crypt::EncryptionType) preferredHashAlgorithm));
        pAccount->SetPasswordEncryption(preferredHashAlgorithm);
    }

    return true;
}
Example #23
0
bool VcfHelper::isAutosome(const String & chr)
{
    // Return true for numeric chromosome number (1-22 or chr1-chr22),
    // false for anything else
    int n = atoi(chr.c_str());
    if ( n > 0 ) { return true; }
    else {
        String s = chr;
        if ( s.Left(3).Compare("chr") == 0 ) {
            n = atoi(s.SubStr(3).c_str());
            if ( n > 0 ) { return true; }
        }
        return false;
    }
}
Example #24
0
   bool 
   MimeTester::TestFolder(const String &sFolderName)
   {
      return true;

      String sCleanFolder = sFolderName;
      if (sCleanFolder.Right(1) == _T("\\"))
         sCleanFolder = sCleanFolder.Left(sCleanFolder.GetLength() - 1);

      if (sCleanFolder.Right(1) != _T("\\"))
         sCleanFolder += "\\";

      String sWildCard = sCleanFolder + "*.*";

      // Locate first match
      WIN32_FIND_DATA ffData;
      HANDLE hFileFound = FindFirstFile(sWildCard, &ffData);

      if (hFileFound == INVALID_HANDLE_VALUE)
         return FALSE;

      while (hFileFound && FindNextFile(hFileFound, &ffData))
      {
         String sFullPath = sCleanFolder + ffData.cFileName;

         if (ffData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) 
         {
            if( (_tcscmp(ffData.cFileName, _T(".")) != 0) &&
               (_tcscmp(ffData.cFileName, _T("..")) != 0) ) 
            {
               if( !TestFolder(sFullPath) )
                  return false;
            }

         }
         else
         { 
            TestLoadFile(sFullPath);
         }
      }

      FindClose(hFileFound);

      return true;
   
   }
Example #25
0
// from complete lib name/path (libXXX.so.ver.minVer) gets the soname (libXXX.so.ver)
String CppBuilder::GetSoname(String libName) const
{
	
	String soname = GetFileName(libName);
	int soLen = soname.GetCount();
	int soPos = ToLower(soname).ReverseFind(".so");
	if(soPos < 0)
		soPos = soLen;
	else
		soPos += 3;
	if(soname.Mid(soPos, 1) == ".")
	{
		soPos++;
		while(soPos < soLen && IsDigit(soname[soPos]))
			soPos++;
	}
	return soname.Left(soPos);
}
Example #26
0
int VcfHelper::chromName2Num(const String & chr) {
  int n = atoi(chr.c_str());
  if ( n > 0 ) { return n; }
  else {
    String s = chr;
    if ( s.Left(3).Compare("chr") == 0 ) {
      n = atoi(s.SubStr(3).c_str());
      if ( n > 0 ) { return n; }
      s = s.SubStr(3);
    }
    for(int i=0; i < asChromNames.Length(); ++i) {
      if ( s.Compare(asChromNames[i]) == 0 ) {
	return vnChromNums[i];
      }
    }
  }
  throw VcfFileException("Cannot recognize chromosome %s",chr.c_str());
}
Example #27
0
// main updater proc inside normal mode
// prepares environment, copy app in temporary folder
// and restarts it in superuser mode
// returns true if app must continue execution, false otherwise
bool Updater::START_Updater(String const &operation)
{
	// prepare environment for updating
	environment.Add("UPDATER_USER", user);
	environment.Add("UPDATER_OP", operation);
	environment.Add("UPDATER_STATE", "INSIDEUPDATER");
	environment.Add("UPDATER_APPNAME", appName);
	environment.Add("UPDATER_EXEPATH", GetExeFilePath());
	
	if(CommandLine().GetCount() && CommandLine()[0] != "--UNINSTALL")
	{
		String s;
		for(int i = 0; i < CommandLine().GetCount(); i++)
			s += CommandLine()[i] + " ";
		s = s.Left(s.GetCount() - 1);
		environment.Add("UPDATER_CMDLINE", s);
	}

	// gets current executable path
	String exePath = GetExeFilePath();
	
	// creates a temporary filename and copies itself
	// in temporary folder
	String tempName = GetTempFileName();
#ifdef PLATFORM_WIN32
	tempName += ".exe";
#endif
	if(!FileCopy(exePath, tempName))
		return true;
	
#ifdef PLATFORM_POSIX
	// for posix, change temp file permission
	// allowing its execution and executes it as a superuser
	if(chmod(~tempName, 0755) != 0)
		return true;
#endif
	
	// executes the file asking for password
	bool res = !SysStartAdmin(tempName, "", environment);
	return res;

}
   void
   MessageUtilities::CleanIMAPFolderRuleString(String &sIMAPFolder)
   {
      SYSTEMTIME pTime;
      GetLocalTime(&pTime);

      String sYear;
      String sMonth;
      String sDay;

      sYear.Format(_T("%.04d"), pTime.wYear);
      sMonth.Format(_T("%.02d"), pTime.wMonth);
      sDay.Format(_T("%.02d"), pTime.wDay);

      sIMAPFolder.ReplaceNoCase(_T("%YEAR%"), sYear);
      sIMAPFolder.ReplaceNoCase(_T("%MONTH%"), sMonth);
      sIMAPFolder.ReplaceNoCase(_T("%DAY%"), sDay);
      if (sIMAPFolder.Left(1) == Configuration::Instance()->GetIMAPConfiguration()->GetHierarchyDelimiter())
         sIMAPFolder = sIMAPFolder.Mid(1);
   }
Example #29
0
const wchar_t* PathHelper::GetModuleDir(HINSTANCE hInstance)
{
    WCHAR szModulePath[MAX_PATH  + 1];
    ::GetModuleFileName(hInstance, szModulePath, MAX_PATH);

    String	strPath = szModulePath;
    int index = strPath.ReverseFind((const WCHAR*)L"\\");
    if(index > 0)
    {
        strPath = strPath.Left(index + 1);
    }
    else
    {
        ASSERT(FALSE);
        strPath += L"\\";
    }

    strPath.Replace((const WCHAR*)L"/",(const WCHAR*)L"\\");
    return _wcsdup(strPath.GetData());
}
Example #30
0
static int UppStringSimplify(VarItem &varItem, int step)
{
	enum { SMALL = 0, MEDIUM = 31 }; // SMALL has to be 0 because of GetSpecial and because is it ending zero
	enum { KIND = 14, SLEN = 15, LLEN = 2, SPECIAL = 13 };
	union
	{
		char chr[16];
		char  *ptr;
		dword *wptr;
		qword *qptr;
		word   v[8];
		dword  w[4];
		qword  q[2];
	} u;
	
	// see Upp::String code for how it works....
	MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ")." + "chr");
	if(!val.IsString())
		return 0;
	String chrs = val.ToString();
	memcpy(u.chr, ~chrs, 16);

	bool isSmall = (u.chr[14] == 0);
	String s;
	if(isSmall)
	{
		byte len = u.chr[SLEN];
		s = chrs.Left(len);
	}
	else
	{
		dword len = u.w[LLEN];
		MIValue val = varItem.EvaluateExpression("(" + varItem.evaluableExpression + ").ptr[0]@" + FormatInt(len));
		if(!val.IsString())
			return 0;
		s = val.ToString();
	}
	varItem.value = "\"" + s + "\"";
	varItem.kind = VarItem::SIMPLE;
	return 0;
}