BOOL CDownloadDirectory::Read(LPCSTR pszDirFile) { // Remember what we tried to read. m_csDirName = pszDirFile; // Get rid of any files we currently have. m_Files.RemoveAll(); // Setup the INI file to read from. CIniFile DirFile(pszDirFile); // Read the Files section. LPSTR pszKeys = DirFile.GetSectionKeys("Files"); if (pszKeys != NULL) { // We got some keys. LPSTR p = pszKeys; while (*p != '\0') { // Fill out the file structure. CDownloadFile File; File.m_csFileName = p; // Read the source file. File.m_csSourceName = DirFile.GetString("Files", p); // Read anything else... // Validate the file. if (!File.m_csSourceName.IsEmpty()) { // OK to add. m_Files.Add(File); } // Advance to the next key. p += strlen(p)+1; } // Get rid of the keys data. delete [] pszKeys; } // Only valid if we actually got some files. return (m_Files.GetSize() > 0); }
U0 EdCodeTools2(CDoc *doc,I64 tool_action) { Bool okay,unlock=DocLock(doc),start_of_line=TRUE; CDocEntry *doc_e,*doc_ne; I64 i,start_y,end_y,x,r,goto_line_num; U8 *b,*st,*st2,*prj_file; CTask *task=NULL; CSrvCmd *tempc; CQueVectU8 *indent; DocRecalc(doc); goto_line_num=doc->cur_entry->y+1; DocCaptureUndo(doc,TRUE); switch (tool_action) { case EF_CHK_COMPILE: okay=FALSE; if (doc->flags&DOCF_PLAIN_TEXT) DocFlagsToggle(doc,DOCF_PLAIN_TEXT); DocWrite(doc); task=Spawn(&SrvUserCmdLine,NULL,"Srv",,Fs); st2=CurDir; st=MSPrintF("Cd(\"%s\");",st2); tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); Free(st2); Free(st); SetWinHorz(Fs->win_left,Fs->win_right, task); SetWinVert(Fs->win_top, Fs->win_bottom,task); if (ScanResult(tempc,&r)) { st=DirFile(doc->filename.name,,"PRJ.Z"), prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z); Free(st); if (FileFind(prj_file)) { st2=DirFile(prj_file), st=MSPrintF("Cd(\"%s\");",st2); Free(st2); tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER|1<<SVCf_FREE_ON_COMPLETE); Free(st); st=MSPrintF("\"$$WW,1$$\";Cmp(\"%s\",\"SysTemp\",\"SysTemp\");",prj_file); tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); Free(st); if (ScanResult(tempc,&r)) if (!r) { tempc=TaskExeStrQue(task,Fs, "Load(\"SysTemp\",LDF_JUST_LOAD);",1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); if (ScanResult(tempc,&r)) okay=TRUE; } tempc=TaskExeStrQue(task,Fs,"Del(\"SysTemp.*\");",1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); ScanResult(tempc,&r); } else { Free(prj_file); st=DirFile(doc->filename.name,"Load","CPP.Z"); prj_file=FileNameAbs(st,FUF_Z_OR_NOT_Z); Free(st); if (FileFind(prj_file)) st=MSPrintF("\"$$WW,1$$\";ExeFile(\"%s\",TRUE);",prj_file); else st=MSPrintF("\"$$WW,1$$\";ExeFile(\"%s\",TRUE);",doc->filename.name); tempc=TaskExeStrQue(task,Fs,st,1<<SVCf_WAKE_MASTER|1<<SVCf_FOCUS_MASTER); Free(st); if (ScanResult(tempc,&r) && r) okay=TRUE; } Free(prj_file); } if (!okay) { PopUpOk("Has Errors"); while (LBts(&sys_semas[SYS_SEMA_FIX],0)) Yield; ToFileLine(sys_fix_file_line,&st,&i); LBtr(&sys_semas[SYS_SEMA_FIX],0); if (!StrCmp(st,doc->filename.name)) goto_line_num=i; Free(st); } break; case EF_REINDENT: if (EdGoToFun(doc,FALSE,FALSE)) { start_y=doc->cur_entry->y; indent=EdRICode(doc); DocUnlock(doc); Snd(2000); Sleep(150); Snd(0); Sleep(100); Snd(2000); Sleep(150); Snd(0); DocLock(doc); EdRemFunLeadingSpace(doc); DocLineNumGoTo(doc,start_y+1); doc_e=doc->cur_entry; end_y=start_y+indent->total_cnt; while (start_y<=doc_e->y<end_y) { if (doc_e!=doc && doc_e!=doc->cur_entry && !(doc_e->flags1&(DOCEG1_DONT_EDIT-DOCEF1_SCROLLING_X)) && !(doc_e->flags2&DOCEG2_DONT_EDIT)) { if (doc_e->type_u8==DOCT_NEW_LINE||doc_e->type_u8==DOCT_SOFT_NEW_LINE) start_of_line=TRUE; else { if (start_of_line) { i=QueVectU8Get(indent,doc_e->y)*C_INDENT_SPACES; x=doc_e->x+1; while (i>8) { doc_ne=CAlloc(sizeof(CDocEntryBase),doc->mem_task); doc_ne->type=DOCT_TAB | doc->settings_root.dft_text_attr << 8; doc_ne->x=x; doc_ne->y=doc_e->y; doc_ne->page_line_num=doc_e->page_line_num; QueIns(doc_ne,doc_e->last); i-=8; x+=8; } if (i>0) { b=MAlloc(i+1,doc->mem_task); MemSet(b,CH_SPACE,i); b[i]=0; doc_ne=CAlloc(sizeof(CDocEntryBase),doc->mem_task); doc_ne->type=DOCT_TEXT | doc->settings_root.dft_text_attr << 8; doc_ne->tag=b; doc_ne->max_col=1; doc_ne->x=x; doc_ne->y=doc_e->y; doc_ne->page_line_num=doc_e->page_line_num; QueIns(doc_ne,doc_e->last); } } start_of_line=FALSE; } } doc_e=doc_e->next; } QueVectU8Del(indent); } break; case EF_RENUM_ASM: if (EdGoToFun(doc,FALSE,TRUE)) { if (EdCurU8(doc)=='{') { EdCursorRight(doc); DocRecalc(doc); } else if (EdCurU8(doc)==':') { EdCursorRight(doc); if (EdCurU8(doc)==':') EdCursorRight(doc); DocRecalc(doc); } DocUnlock(doc); Snd(2000); Sleep(150); Snd(0); Sleep(100); Snd(2000); Sleep(150); Snd(0); DocLock(doc); EdRenumAsm(doc); } break; }