Beispiel #1
0
CRASHRPTAPI(void) AddFileA(LPVOID lpState, LPCSTR lpFile, LPCSTR lpDesc)
{
  strconv_t strconv;
  LPCWSTR lpwszFile = strconv.a2w(lpFile);
  LPCWSTR lpwszDesc = strconv.a2w(lpDesc);
  AddFileW(lpState, lpwszFile, lpwszDesc);
}
void CrashRptAPITests::Test_AddFile()
{   
  LPVOID pState = InstallW(NULL, L"*****@*****.**", L"Error report");
  TEST_ASSERT(pState==NULL);

  AddFileW(NULL, L"abc.log", L"Log!");

  AddFileA(NULL, "abc.log", "Log!");
  
  __TEST_CLEANUP__;

  Uninstall(NULL);
}
Beispiel #3
0
	// Adds a folder with all its files and all its subfolders to the CAB file
	// sw_Path    = "C:\MyFolder\"
	// sw_Filter  = "*.*  or  "*.dll"
	// b_Compress = FALSE --> store in CAB file without compression
	// Do never set or modify s32_BaseLen !!
	BOOL AddFolderW(/*NO const*/ CStrW sw_Path, const CStrW& sw_Filter=L"*.*", BOOL b_Compress=TRUE, int s32_BaseLen=-1)
	{
		CFile::TerminatePathW(sw_Path);

		int s32_Len = sw_Path.Len();
		if (s32_BaseLen < 0) 
			s32_BaseLen = s32_Len;

		sw_Path += sw_Filter;

		WIN32_FIND_DATAW k_Find;
		HANDLE h_File = FindFirstFileW(sw_Path, &k_Find);

		if (h_File == INVALID_HANDLE_VALUE)
			return (GetLastError() == ERROR_FILE_NOT_FOUND);

		do
		{
			if (k_Find.cFileName[0] == '.') // directories "." and ".."
				continue;

			CStrW sw_File = sw_Path;

			sw_File[s32_Len] = 0;
			sw_File += k_Find.cFileName;

			if (k_Find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				if (!AddFolderW(sw_File, sw_Filter, b_Compress, s32_BaseLen))
				{
					FindClose(h_File);
					return FALSE;
				}
			}
			else
			{
				if (!AddFileW(sw_File, (WCHAR*)sw_File + s32_BaseLen, b_Compress))
				{
					FindClose(h_File);
					return FALSE;
				}
			}
		}
		while (FindNextFileW(h_File, &k_Find));

		FindClose(h_File);
		return TRUE;
	}