Example #1
0
static void PrepareOptFolder(string &strSrc, int IsLocalPath_FarPath)
{
	if (strSrc.IsEmpty())
	{
		strSrc = g_strFarPath;
		DeleteEndSlash(strSrc);
	}
	else
	{
		apiExpandEnvironmentStrings(strSrc, strSrc);
	}

	if (!StrCmp(strSrc,L"/"))
	{
		strSrc = g_strFarPath;

		if (IsLocalPath_FarPath)
		{
			strSrc.SetLength(2);
			strSrc += L"\\";
		}
	}
	else
	{
		CheckShortcutFolder(&strSrc,FALSE,TRUE);
	}

	//ConvertNameToFull(strSrc,strSrc);
}
Example #2
0
void UnquoteExternal(string &strStr)
{
	size_t len = strStr.GetLength();

	if (len > 1 && strStr.At(0) == L'\"' && strStr.At(len-1) == L'\"')
	{
		strStr.SetLength(len-1);
		strStr.LShift(1);
	}
}
Example #3
0
bool CutToSlash(string &strStr, bool bInclude)
{
	size_t pos;

	if (FindLastSlash(pos,strStr))
	{
		if (pos==3 && HasPathPrefix(strStr))
			return false;

		if (bInclude)
			strStr.SetLength(pos);
		else
			strStr.SetLength(pos+1);

		return true;
	}

	return false;
}
Example #4
0
string& WINAPI RemoveTrailingSpaces(string &strStr)
{
	if (strStr.IsEmpty())
		return strStr;

	const wchar_t *Str = strStr;
	const wchar_t *ChPtr = Str + strStr.GetLength() - 1;

	for (; ChPtr >= Str && (IsSpace(*ChPtr) || IsEol(*ChPtr)); ChPtr--)
		;

	strStr.SetLength(ChPtr < Str ? 0 : ChPtr-Str+1);
	return strStr;
}
Example #5
0
int GetRegKey(const wchar_t *Key,const wchar_t *ValueName,string &strValueData,const wchar_t *Default,DWORD *pType)
{
	int ExitCode=!ERROR_SUCCESS;
	HKEY hKey=OpenRegKey(Key);

	if (hKey) // надобно проверить!
	{
		DWORD Type,QueryDataSize=0;

		if ((ExitCode = RegQueryValueEx(
		                    hKey,
		                    ValueName,
		                    0,
		                    &Type,
		                    nullptr,
		                    &QueryDataSize
		                )) == ERROR_SUCCESS)
		{
			wchar_t *TempBuffer = strValueData.GetBuffer(QueryDataSize/sizeof(wchar_t)+1);  // ...то выделим сколько надо
			ExitCode = RegQueryValueEx(hKey,ValueName,0,&Type,(unsigned char *)TempBuffer,&QueryDataSize);
			strValueData.ReleaseBuffer(QueryDataSize/sizeof(wchar_t));

			if (strValueData.GetLength() > 0 && !strValueData.At(strValueData.GetLength()-1))
				strValueData.SetLength(strValueData.GetLength()-1);
		}

		if (pType)
			*pType=Type;

		CloseRegKey(hKey);
	}

	if (ExitCode!=ERROR_SUCCESS)
	{
		strValueData = Default;
		return FALSE;
	}

	return TRUE;
}
Example #6
0
void ConsoleTitle::SetFarTitle(const wchar_t *Title, bool Force)
{
	CriticalSectionLock Lock(TitleCS);
	static string strFarTitle;
	string strOldFarTitle;

	if (Title)
	{
		Console.GetTitle(strOldFarTitle);
		strFarTitle=Title;
		strFarTitle.SetLength(0x100);
		strFarTitle+=GetFarTitleAddons();
		TitleModified=true;

		if (StrCmp(strOldFarTitle, strFarTitle) &&
		        ((CtrlObject->Macro.IsExecuting() && !CtrlObject->Macro.IsDsableOutput()) ||
		         !CtrlObject->Macro.IsExecuting() || CtrlObject->Macro.IsExecutingLastKey()))
		{
			DWORD CurTime=GetTickCount();
			if(CurTime-ShowTime>RedrawTimeout || Force)
			{
				ShowTime=CurTime;
				Console.SetTitle(strFarTitle);
				TitleModified=true;
			}
		}
	}
	else
	{
		/*
			Title=nullptr для случая, когда нужно выставить пред.заголовок
			SetFarTitle(nullptr) - это не для всех!
			Этот вызов имеет право делать только макро-движок!
		*/
		Console.SetTitle(strFarTitle);
		TitleModified=false;
		//_SVS(SysLog(L"  (nullptr)FarTitle='%s'",FarTitle));
	}
}
Example #7
0
void ConvertDate(const FILETIME &ft,string &strDateText, string &strTimeText,int TimeLength,
                 int Brief,int TextMonth,int FullYear,int DynInit)
{
	static int WDateFormat;
	static wchar_t WDateSeparator,WTimeSeparator,WDecimalSeparator;
	static bool Init=false;
	static SYSTEMTIME lt;
	int DateFormat;
	wchar_t DateSeparator,TimeSeparator,DecimalSeparator;

	if (!Init)
	{
		WDateFormat=GetDateFormat();
		WDateSeparator=GetDateSeparator();
		WTimeSeparator=GetTimeSeparator();
		WDecimalSeparator=GetDecimalSeparator();
		GetLocalTime(&lt);
		Init=true;
	}

	DateFormat=DynInit?GetDateFormat():WDateFormat;
	DateSeparator=DynInit?GetDateSeparator():WDateSeparator;
	TimeSeparator=DynInit?GetTimeSeparator():WTimeSeparator;
	DecimalSeparator=DynInit?GetDecimalSeparator():WDecimalSeparator;
	int CurDateFormat=DateFormat;

	if (Brief && CurDateFormat==2)
		CurDateFormat=0;

	SYSTEMTIME st;
	FILETIME ct;

	if (!ft.dwHighDateTime)
	{
		strDateText.Clear();
		strTimeText.Clear();
		return;
	}

	FileTimeToLocalFileTime(&ft,&ct);
	FileTimeToSystemTime(&ct,&st);
	//if ( !strTimeText.IsEmpty() )
	{
		const wchar_t *Letter=L"";

		if (TimeLength==6)
		{
			Letter=(st.wHour<12) ? L"a":L"p";

			if (st.wHour>12)
				st.wHour-=12;

			if (!st.wHour)
				st.wHour=12;
		}

		if (TimeLength<7)
			strTimeText.Format(L"%02d%c%02d%s",st.wHour,TimeSeparator,st.wMinute,Letter);
		else
		{
			string strFullTime;
			strFullTime.Format(L"%02d%c%02d%c%02d%c%03d",st.wHour,TimeSeparator,
			                   st.wMinute,TimeSeparator,st.wSecond,DecimalSeparator,st.wMilliseconds);
			strTimeText.Format(L"%.*s",TimeLength, strFullTime.CPtr());
		}
	}
	//if ( !strDateText.IsEmpty() )
	{
		int Year=st.wYear;

		if (!FullYear)
			Year%=100;

		if (TextMonth)
		{
			const wchar_t *Month=MSG(MMonthJan+st.wMonth-1);

			switch (CurDateFormat)
			{
				case 0:
					strDateText.Format(L"%3.3s %2d %02d",Month,st.wDay,Year);
					break;
				case 1:
					strDateText.Format(L"%2d %3.3s %02d",st.wDay,Month,Year);
					break;
				default:
					strDateText.Format(L"%02d %3.3s %2d",Year,Month,st.wDay);
					break;
			}
		}
		else
		{
			int p1,p2,p3=Year;
			int w1=2, w2=2, w3=2;
			wchar_t f1=L'0', f2=L'0', f3=FullYear==2?L' ':L'0';
			switch (CurDateFormat)
			{
				case 0:
					p1=st.wMonth;
					p2=st.wDay;
					break;
				case 1:
					p1=st.wDay;
					p2=st.wMonth;
					break;
				default:
					p1=Year;
					w1=FullYear==2?5:2;
					f3=f1;
					f1=L' ';
					p2=st.wMonth;
					p3=st.wDay;
					break;
			}
			FormatString Fmt;
			Fmt<<fmt::FillChar(f1)<<fmt::Width(w1)<<p1<<DateSeparator<<fmt::FillChar(f2)<<fmt::Width(w2)<<p2<<DateSeparator<<fmt::FillChar(f3)<<fmt::Width(w3)<<p3;
			strDateText=Fmt;
		}
	}

	if (Brief)
	{
		strDateText.SetLength(TextMonth ? 6 : 5);

		if (lt.wYear!=st.wYear)
			strTimeText.Format(L"%5d",st.wYear);
	}
}