Example #1
0
	// Extract the CAB file at the given URL into the given target directory
	// If u16_LocalFile = ""  -> a temporary file will be created
	// A Cabfile will be written to disk ONLY if u32_Blocksize = 0 !!
	// u16_TargetDir = L"" AND Blocksize = 0 --> only download any file from internet to disk
	BOOL ExtractUrlW(const CStrW& sw_URL, DWORD u32_Blocksize, const CStrW& sw_LocalFile, const CStrW& sw_TargetDir, void* pParam = NULL)
	{
		if (!Initialize(sw_URL, sw_LocalFile, u32_Blocksize))
			return FALSE;

		// Just a download without CAB extraction
		if (!u32_Blocksize && sw_LocalFile.Len() && !sw_TargetDir.Len())
		{
			// The caller may want to access the file immediately -> close all
			mi_Internet.CleanUp();
			return TRUE;
		}

		// Pass it on to the base class
		return ExtractFileW(L"*CABINET\\*URL", sw_TargetDir, pParam);
	}
Example #2
0
	CStrW(const CStrW& s_String)
	{
		mu16_Buf  = 0;
		mu32_Size = 0;
		Allocate(max(DEFAULT_BUFSIZE, s_String.Len())); // throws
		wcscpy(mu16_Buf, s_String);
	}
Example #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;
	}
Example #4
0
	void operator+=(const CStrW& s_String)
	{
		Allocate(Len() + s_String.Len());
		wcscat(mu16_Buf, s_String);
	}
Example #5
0
	void operator=(const CStrW& s_String)
	{
		Assign(s_String, s_String.Len());
	}