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; }
void SplitString(const wstring &srcString, WStringArray &destStrings) { destStrings.clear(); wstring s; size_t len = srcString.length(); if (len == 0) return; for (size_t i = 0; i < len; i++) { wchar_t c = srcString[i]; if (c == L' ') { if (!s.empty()) { destStrings.push_back(s); s.clear(); } } else s += c; } if (!s.empty()) destStrings.push_back(s); }
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; }
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()); } }
int InitializeCodetables () { int Result = E_PERFECTSUCCESS; //060115 don't load if already loaded // -- look at an arbitrary one, but not near the beginning because // it may be null on purpose if (UTF2MARC[1000].utf8[0]) return Result; int i; long kk; char* tablenames [] = {"MARC2UTF", "UTF2MARC"}; long table_len; // pointers to first element in each table charconvert_rt* tables [] = {MARC2UTF, UTF2MARC}; FILE* FH; char t_line [80]; WString tablename, t_string; WStringArray tlinearray; charconvert_rt* thistable; // loop to load multiple tables for (i = 0; i < (sizeof (tables) / sizeof (thistable)); i++) { tablename = tablenames [i]; if (i == 0) table_len = sizeof (MARC2UTF); else if (i == 1) table_len = sizeof (UTF2MARC); tablename.Concat (".txt"); thistable = tables [i]; memset (thistable, 0, table_len); /* find default dir -- debugging char *cwd; cwd = getcwd( NULL, 0 ); */ if ((FH = fopen (tablename, "r")) == NULL) { return E_FILENOTOPEN; } else { kk = 0; // loop to load a single table while (!feof (FH)) { fgets (t_line, sizeof (t_line), FH); if (!feof(FH)) { t_string = t_line; tlinearray = t_string.Parse (",\r\n"); if (tlinearray.GetCount () < 4) return E_CONVERSION; strcpy ((thistable + kk)->marc, tlinearray [0].GetText ()); strcpy ((thistable + kk)->utf8, tlinearray [1].GetText ()); if (tlinearray[2].GetCharacter(0) == '0') strcpy ((thistable + kk)->combining, "0"); else strcpy ((thistable + kk)->combining, "1"); strcpy ((thistable + kk)->charset, tlinearray [3].GetText ()); kk++; } } } fclose (FH); } //051231 LOAD DECOMPOSITION TABLE tablename = "DECOMP.TXT"; table_len = sizeof (DECOMP); memset (DECOMP, 0, table_len); if ((FH = fopen (tablename, "r")) == NULL) { return E_FILENOTOPEN; } else { kk = 0; while (!feof (FH)) { fgets (t_line, sizeof (t_line), FH); if (!feof(FH)) { t_string = t_line; tlinearray = t_string.Parse (",\r\n"); if (tlinearray.GetCount () < 2) return E_CONVERSION; strcpy ((DECOMP + kk)->utf8, tlinearray [0].GetText ()); strcpy ((DECOMP + kk)->decomp, tlinearray [1].GetText ()); kk++; } } } fclose (FH); return Result; }