Example #1
0
HRESULT CTickdataGrid::init()
{
    HRESULT hr = WARMGUI::CGridCtrl::init();
    if (SUCCEEDED(hr)) {
        try {
            char key[MAX_PATH];
            _snprintf_s(key, MAX_PATH, "%s.head", _str_conf);
            //const std::string tmp = _config->getString(key).c_str();
            //CChineseCodeLib::Gb2312ToUnicode(head, MAX_PATH, tmp.c_str());
            WStringArray wsa;
            _config->getStringVector(wsa, key);
            SetColumnCount(wsa.size());
            SetFixedRowCount(1);
            {//test first cell
                GV_ITEM item;
                item.mask = GVIF_TEXT;
    
                item.col = item.row = 0;
                for (int i = 0; i < wsa.size(); i++) {
                    item.col = i;
                    item.strText = wsa[i];
                    SetItem(&item);
                }
            }
       }catch( ... ) {
            hr = -1;
        }
    }
    _count = 1;
    return hr;
}
Example #2
0
int main(int argc, char * argv[])
#endif
{
	C7ZipLibrary lib;

	if (!lib.Initialize()) {
		wprintf(L"initialize fail!\n");
		return 1;
	}

	WStringArray exts;

	if (!lib.GetSupportedExts(exts)) {
		wprintf(L"get supported exts fail\n");
		return 1;
	}

	size_t size = exts.size();

	for(size_t i = 0; i < size; i++) {
		wstring ext = exts[i];

		for(size_t j = 0; j < ext.size(); j++) {
			wprintf(L"%c", (char)(ext[j] &0xFF));
		}

		wprintf(L"\n");
	}

	C7ZipArchive * pArchive = NULL;

	TestInStream stream("Test7Zip.zip");
	TestOutStream oStream("TestResult.txt");
        if (lib.OpenArchive(&stream, &pArchive, true)) {
		unsigned int numItems = 0;

		pArchive->GetItemCount(&numItems);

		wprintf(L"%d\n", numItems);

		for(unsigned int i = 0;i < numItems;i++) {
			C7ZipArchiveItem * pArchiveItem = NULL;

			if (pArchive->GetItemInfo(i, &pArchiveItem)) {
				wprintf(L"%d,%ls,%d\n", pArchiveItem->GetArchiveIndex(),
						pArchiveItem->GetFullPath().c_str(),
						pArchiveItem->IsDir());

				wprintf(L"get all properties\n");
				for(lib7zip::PropertyIndexEnum index = lib7zip::kpidPackSize;
					index <= lib7zip::kpidIsDir;
					index = (lib7zip::PropertyIndexEnum)(index + 1)) {
					wstring strVal = L"";
					unsigned __int64 val = 0;
					bool bVal = false;

					bool result = pArchiveItem->GetUInt64Property(index, val);

					wprintf(L"\n\nGetProperty:%d %ls\n", (int)index, 
							index_names[(int)index]);

					wprintf(L"UInt64 result:%ls val=%ld\n", 
							result ? L"true" : L"false",
							val);

					result = pArchiveItem->GetBoolProperty(index, bVal);

					wprintf(L"Bool result:%ls val=%ls\n", 
							result ? L"true" : L"false",
							bVal ? L"true" : L"false");

					result = pArchiveItem->GetStringProperty(index, strVal);

					wprintf(L"String result:%ls val=%ls\n", 
							result ? L"true" : L"false",
							strVal.c_str());				

					result = pArchiveItem->GetFileTimeProperty(index, val);

					wprintf(L"FileTime result:%ls val=%ld\n", 
							result ? L"true" : L"false",
							val);				
				}

				//set archive password or item password
				pArchive->SetArchivePassword(L"test");
				if (i==0) {
					//Or set password for each archive item
					//pArchiveItem->SetArchiveItemPassword(L"test");
					pArchive->Extract(pArchiveItem, &oStream);
				}
			} //if
		}//for
	}
	else {
		wprintf(L"open archive Test7Zip.zip fail\n");
	}

	if (pArchive != NULL)
		delete pArchive;

	return 0;
}
Example #3
0
	Fuse7z_lib7zip(std::string const & filename, std::string const & cwd) : Fuse7z(filename, cwd), stream(filename) {
		logger << "Initialization of fuse-7z with archive " << filename << Logger::endl;

		if (!lib.Initialize()) {
			stringstream ss;
			ss << "7z library initialization failed";
			throw runtime_error(ss.str());
		}

		WStringArray exts;

		if (!lib.GetSupportedExts(exts)) {
			stringstream ss;
			ss << "Could not get list of 7z-supported file extensions";
			throw runtime_error(ss.str());
		}

		
		logger << "Supported extensions : ";
		size_t size = exts.size();
		for(size_t i = 0; i < size; i++) {
			std::wstring ext = exts[i];
			

			for(size_t j = 0; j < ext.size(); j++) {
				logger << (char)(ext[j] &0xFF);
			}
			logger << " ";

		}
		logger << Logger::endl;


		if (lib.OpenArchive(&stream, &archive)) {
			unsigned int numItems = 0;

			archive->GetItemCount(&numItems);

			logger << "Archive contains " << numItems << " entries" << Logger::endl;
			Node * node;
			for(unsigned int i = 0;i < numItems;i++) {
				C7ZipArchiveItem * pArchiveItem = NULL;
				if (archive->GetItemInfo(i, &pArchiveItem)) {
					std::wstring wpath(pArchiveItem->GetFullPath());
					std::string path;
					path.resize(wpath.length());
					std::copy(wpath.begin(), wpath.end(), path.begin());

					node = root_node->insert(const_cast<char*>(path.c_str()));
					node->id = i;

					node->is_dir = pArchiveItem->IsDir();

					{
						unsigned long long size;
						pArchiveItem->GetUInt64Property(lib7zip::kpidSize, size);
						node->stat.st_size = size;
					}

					{
						unsigned long long secpy, time, bias, gain;
						secpy = 31536000;
						gain = 10000000ULL;
						bias = secpy * gain * 369 + secpy * 2438356ULL + 5184000ULL;
						pArchiveItem->GetFileTimeProperty(lib7zip::kpidATime, time);
						node->stat.st_atim.tv_sec = (time - bias)/gain;
						node->stat.st_atim.tv_nsec = ((time - bias) % gain) * 100;
						pArchiveItem->GetFileTimeProperty(lib7zip::kpidCTime, time);
						node->stat.st_ctim.tv_sec = (time - bias)/gain;
						node->stat.st_ctim.tv_nsec = ((time - bias) % gain) * 100;
						pArchiveItem->GetFileTimeProperty(lib7zip::kpidMTime, time);
						node->stat.st_mtim.tv_sec = (time - bias)/gain;
						node->stat.st_mtim.tv_nsec = ((time - bias) % gain) * 100;
					}
				}
				if ((i+1) % 10000 == 0) {
					logger << "Indexed " << (i+1) << "th file : " << node->fullname() << Logger::endl;
				}
			}
		}
		else {
			stringstream ss;
			ss << "open archive " << archive_fn  << " failed" << endl;
			throw runtime_error(ss.str());
		}

	}