/** * Add a filename to our list of filenames. * @param const MYODD_STRING& fileName the filename we want to add. */ void Clipboard::SetText(const MYODD_STRING& srcText) { // set the text value. _clipboardData.SetText(srcText); // it is posible that the text selected represents a file // or a directory, in that case it is useful to display it to the APIs AddFileName(srcText); }
void LoadAssemblyFile(const std::wstring& fileName, TextFile::Encoding encoding) { tTextData Text; int num = 0; AddFileName((char*)convertWStringToUtf8(fileName).c_str()); Global.IncludeNestingLevel++; if (Global.IncludeNestingLevel == ASSEMBLER_INCLUDE_NESTING_LEVEL) { Logger::printError(Logger::Error,L"Maximum include nesting level reached"); return; } TextFile input; if (input.open(fileName,TextFile::Read,encoding) == false) { Logger::printError(Logger::Error,L"Could not open file"); return; } while (!input.atEnd()) { Global.FileInfo.LineNumber++; Global.FileInfo.TotalLineCount++; if (GetLine(input,Text.buffer) == false) continue; if (Text.buffer.size() == 0) continue; Text.buffer = Global.symbolTable.insertEquations(Text.buffer,Global.FileInfo.FileNum,Global.Section); if (CheckEquLabel(Text.buffer) == false) { Text.buffer = checkLabel(Text.buffer,false); splitLine(Text.buffer,Text.name,Text.params); if (Text.name.empty()) continue; if (ParseMacro(input,Text.name,Text.params) == true) continue; if (Arch->AssembleDirective(Text.name,Text.params) == false) { Arch->AssembleOpcode(Text.name,Text.params); } } if (Logger::hasFatalError()) return; } Logger::printQueue(); Global.IncludeNestingLevel--; input.close(); }
void TK_OpenSource(char *fileName) { int size; TK_CloseSource(); size = MS_LoadFile(fileName, &FileStart); tk_SourceName = AddFileName(fileName); SetLocalIncludePath(fileName); SourceOpen = TRUE; FileEnd = FileStart+size; FilePtr = FileStart; tk_Line = 1; tk_Token = TK_NONE; AlreadyGot = FALSE; NestDepth = 0; NextChr(); }
void TK_Include(char *fileName) { char sourceName[MAX_FILE_NAME_LENGTH]; int size, i; nestInfo_t *info; boolean foundfile = FALSE; MS_Message(MSG_DEBUG, "*Including %s\n", fileName); if(NestDepth == MAX_NESTED_SOURCES) { ERR_Exit(ERR_INCL_NESTING_TOO_DEEP, YES, fileName); } info = &OpenFiles[NestDepth++]; info->name = tk_SourceName; info->start = FileStart; info->end = FileEnd; info->position = FilePtr; info->line = tk_Line; info->incLineNumber = IncLineNumber; info->lastChar = Chr; info->imported = NO; // Pascal 30/11/08 // Handle absolute paths if(MS_IsPathAbsolute(fileName)) { #if defined(_WIN32) || defined(__MSDOS__) sourceName[0] = '\0'; if(MS_IsDirectoryDelimiter(fileName[0])) { // The source file is absolute for the drive, but does not // specify a drive. Use the path for the current file to // get the drive letter, if it has one. if(IncludePaths[0][0] != '\0' && IncludePaths[0][1] == ':') { sourceName[0] = IncludePaths[0][0]; sourceName[1] = ':'; sourceName[2] = '\0'; } } strcat(sourceName, fileName); #else strcpy(sourceName, fileName); #endif foundfile = MS_FileExists(sourceName); } else { // Pascal 12/11/08 // Find the file in the include paths for(i = 0; i < NumIncludePaths; i++) { strcpy(sourceName, IncludePaths[i]); strcat(sourceName, fileName); if(MS_FileExists(sourceName)) { foundfile = TRUE; break; } } } if(!foundfile) { ERR_ErrorAt(tk_SourceName, tk_Line); ERR_Exit(ERR_CANT_FIND_INCLUDE, YES, fileName, tk_SourceName, tk_Line); } MS_Message(MSG_DEBUG, "*Include file found at %s\n", sourceName); // Now change the first include path to the file directory SetLocalIncludePath(sourceName); tk_SourceName = AddFileName(sourceName); size = MS_LoadFile(tk_SourceName, &FileStart); FileEnd = FileStart+size; FilePtr = FileStart; tk_Line = 1; IncLineNumber = FALSE; tk_Token = TK_NONE; AlreadyGot = FALSE; BumpMasterSourceLine('x',TRUE); // dummy x NextChr(); }
/** * Parse the clipboard data and add file names, texts and what ever info could be used. * We cannot do much with non text items. * Update this function as new clipboard items are discovered. * * @param vector of clipboard data been parsed. * @return none. */ void Clipboard::ParseClipboard( V_CF& s_cf ) { USES_CONVERSION; for( V_CF::const_iterator it = s_cf.begin(); it != s_cf.end(); it++ ) { try { ClipboardData* cf = *it; if( NULL == cf ) { continue; } switch( cf->uFormat ) { case 0x0c006: /* FILENAME */ { // a file name was added const wchar_t* lp = T_A2T((CHAR*)cf->data); AddFileName( lp ); } break; case 0x0c007: /*FILENAMEW*/ { // a file name was added const wchar_t* lp = (WCHAR*)cf->data; AddFileName(lp); } break; case CF_UNICODETEXT: { // normal, selected text. const wchar_t* lp = (WCHAR*)cf->data; SetText( lp ); } break; case CF_TEXT: { // normal, selected text. const wchar_t* lp = T_A2T( (CHAR*)cf->data ); SetText( lp ); } break; case CF_HDROP: { ClipboardDropData* cdd = (ClipboardDropData*)cf->data; const std::vector<MYODD_STRING>& files = cdd->Files(); for (std::vector<MYODD_STRING>::const_iterator it = files.begin(); it != files.end(); ++it) { AddFileName( *it ); } } break; default: // not handled. break; } } catch(... ) { _ASSERT(0); // the main reason for failure is probably because // there is a format in the Clipboard that I am not handling properly // there should be a way of seending me a mail when this happens so we can look into fixing it. } }// for each clipboard items }