bool RawData::Open(wxString filename) { wxFile f; void *tempbuffer; uint bytesread = 0, buffer_size = 0; wxString ext; bool ret; ret = false; if (f.Open(filename)) { if (IsLoaded()) Close(); m_header_offset = 0; buffer_size = (uint)f.Length(); tempbuffer = m_buffer.GetWriteBuf(buffer_size); if (tempbuffer != 0) bytesread = (uint)f.Read(tempbuffer, buffer_size); f.Close(); if (bytesread == buffer_size) { m_buffer.UngetWriteBuf(buffer_size); rawdata_filename.Assign(filename); ext = filename.AfterLast('.'); ext = ext.Lower(); if (ext == "com") SetFileType(COM); else if (ext == "rom") { SetFileType(ROM); } else if (!SetFileType(BIN)) SetFileType(UNKNOWN); ret = true; } else m_buffer.SetDataLen(0); } #ifdef IDZ80DEBUG if (ret) LogIt(wxString::Format("File opened is %s.\n",filename.c_str())); else LogIt("File not found !\n"); #endif return ret; }
bool gstTXTTable::SetFileType(const char* ftype) { if (!strcasecmp(ftype, "delimited")) { SetFileType(Delimited); } else if (!strcasecmp(ftype, "fixedwidth")) { SetFileType(FixedWidth); } else { return false; } return true; }
void RawData::SetStrFileType(const wxString &str_type) { str_type.Upper(); if (str_type == "COM") SetFileType(COM); else if (str_type == "ROM") SetFileType(ROM); else if (str_type == "BIN") SetFileType(BIN); else SetFileType(UNKNOWN); }
void CAbstractFile::SetFileName(LPCTSTR pszFileName, bool bReplaceInvalidFileSystemChars, bool bAutoSetFileType, bool bRemoveControlChars) { m_strFileName = pszFileName; if (bReplaceInvalidFileSystemChars){ m_strFileName.Replace(_T('/'), _T('-')); m_strFileName.Replace(_T('>'), _T('-')); m_strFileName.Replace(_T('<'), _T('-')); m_strFileName.Replace(_T('*'), _T('-')); m_strFileName.Replace(_T(':'), _T('-')); m_strFileName.Replace(_T('?'), _T('-')); m_strFileName.Replace(_T('\"'), _T('-')); m_strFileName.Replace(_T('\\'), _T('-')); m_strFileName.Replace(_T('|'), _T('-')); } if (bAutoSetFileType) SetFileType(GetFileTypeByName(m_strFileName)); if (bRemoveControlChars){ for (int i = 0; i < m_strFileName.GetLength(); ) if (m_strFileName.GetAt(i) <= '\x1F') m_strFileName.Delete(i); else i++; } }
gstTXTTable::gstTXTTable(const char* n) : gstTable(n), file_descriptor_(-1) { SetFileType(Undefined); status_ = GST_UNKNOWN; skip_rows_ = 0; }
CCollectionFile::CCollectionFile(CFileDataIO* in_data) { UINT tagcount = in_data->ReadUInt32(); for (UINT i = 0; i < tagcount; i++) { CTag* toadd = new CTag(in_data, true); if (toadd) taglist.Add(toadd); } CTag* pTagHash = GetTag(FT_FILEHASH); if(pTagHash) SetFileHash(pTagHash->GetHash()); else ASSERT(0); // here we have two choices // - if the server/client sent us a filetype, we could use it (though it could be wrong) // - we always trust our filetype list and determine the filetype by the extension of the file // // if we received a filetype from server, we use it. // if we did not receive a filetype, we determine it by examining the file's extension. // // but, in no case, we will use the receive file type when adding this search result to the download queue, to avoid // that we are using 'wrong' file types in part files. (this has to be handled when creating the part files) const CString& rstrFileType = GetStrTagValue(FT_FILETYPE); SetFileName(GetStrTagValue(FT_FILENAME), false, rstrFileType.IsEmpty()); SetFileSize(GetIntTagValue(FT_FILESIZE)); if (!rstrFileType.IsEmpty()) { if (_tcscmp(rstrFileType, _T(ED2KFTSTR_PROGRAM))==0) { CString strDetailFileType = GetFileTypeByName(GetFileName()); if (!strDetailFileType.IsEmpty()) SetFileType(strDetailFileType); else SetFileType(rstrFileType); } else SetFileType(rstrFileType); } if(!GetFileSize() || !GetFileName().Compare(_T(""))) ASSERT(0); }
RawData::RawData(LogWindow *logparent) { m_buffer.SetDataLen(0); SetFileType(UNKNOWN); m_header_offset = 0; m_cartridge = 0; m_binheader = 0; m_iscartridge = false; m_isbasic = false; ModuleName = "RawData"; SetTextLog(logparent); }
void RawData::Clear() { if (m_cartridge != 0) { delete m_cartridge; m_cartridge = 0; } if (m_binheader != 0) { delete m_binheader; m_binheader = 0; } memset(m_buffer.GetData(), '\0', m_buffer.GetDataLen()); m_buffer.SetBufSize(0); rawdata_filename.Clear(); SetFileType(UNKNOWN); m_isbasic = false; }
OSErr TShioTimeValue::ReadTimeValues (char *path, short format, short unitsIfKnownInAdvance) { // code goes here, use unitsIfKnownInAdvance to tell if we're coming from a location file, // if not and it's a heights file ask if progressive or standing wave (add new field or track as 'P') //#pragma unused(unitsIfKnownInAdvance) char strLine[kMaxKeyedLineLength]; long i,numValues; double value1, value2, magnitude, degrees; CHARH f = 0; DateTimeRec time; TimeValuePair pair; OSErr err = noErr,scanErr; long lineNum = 0; char *p; long numScanned; double value, stationLat, stationLon; CONTROLVAR DatumControls; if (err = OSSMTimeValue_c::InitTimeFunc()) return err; timeValues = 0; fileName[0] = 0; if (!path) return -1; strcpy(strLine, path); SplitPathFile(strLine, this->fileName); err = ReadFileContents(TERMINATED, 0, 0, path, 0, 0, &f); if(err) { TechError("TShioTimeValue::ReadTimeValues()", "ReadFileContents()", 0); return -1; } lineNum = 0; // first line if(!(p = GetKeyedLine(f, "[StationInfo]",lineNum++,strLine))) goto readError; // 2nd line if(!(p = GetKeyedLine(f, "Type=",lineNum++,strLine))) goto readError; switch(p[0]) { //case 'c': case 'C': this->fStationType = 'C'; break; //case 'h': case 'H': this->fStationType = 'H'; break; //case 'p': case 'P': this->fStationType = 'P'; // for now assume progressive waves selected in file, maybe change to user input case 'c': case 'C': this->fStationType = 'C'; break; case 'h': case 'H': this->fStationType = 'H'; { // if not a location file, Ask user if this is a progressive or standing wave // also ask for scale factor here /*if (unitsIfKnownInAdvance==kFudgeFlag) { short buttonSelected; buttonSelected = MULTICHOICEALERT(1690,"The file you selected is a shio heights file. Are you sure you want to treat it as a progressive wave?",TRUE); switch(buttonSelected){ case 1:// continue, treat as progressive wave this->fStationType = 'P'; break; case 3: // cancel //return 0;// leave as standing wave? return -1; break; } //printNote("The shio heights file will be treated as a progressive wave file"); //this->fStationType = 'P'; }*/ if (unitsIfKnownInAdvance!=-2) // not a location file { Boolean bStandingWave = true; float scaleFactor = fScaleFactor; err = ShioHtsDialog(&bStandingWave,&scaleFactor,mapWindow); if (!err) { if (!bStandingWave) this->fStationType = 'P'; //this->fScaleFactor = scaleFactor; } } } break; case 'p': case 'P': this->fStationType = 'P'; // for now assume progressive waves selected in file, maybe change to user input //printError("You have selected a SHIO heights file. Only SHIO current files can be used in GNOME."); //return -1; break; // Allow heights files to be read in 9/18/00 default: goto readError; } // 3nd line if(!(p = GetKeyedLine(f, "Name=",lineNum++,strLine))) goto readError; strncpy(this->fStationName,p,MAXSTATIONNAMELEN); this->fStationName[MAXSTATIONNAMELEN-1] = 0; // if(err = this->GetKeyedValue(f,"Latitude=",lineNum++,strLine,&stationLat)) goto readError; if(err = this->GetKeyedValue(f,"Longitude=",lineNum++,strLine,&stationLon)) goto readError; this->fStationPosition.p.pLat = stationLat * 1000000; this->fStationPosition.p.pLong = stationLon * 1000000; // if(!(p = GetKeyedLine(f, "[Constituents]",lineNum++,strLine))) goto readError; // code goes here in version 1.2.7 these lines won't be required for height files, but should still allow old format //if(err = this->GetKeyedValue(f,"DatumControls.datum=",lineNum++,strLine,&this->fConstituent.DatumControls.datum)) goto readError; if(err = this->GetKeyedValue(f,"DatumControls.datum=",lineNum++,strLine,&this->fConstituent.DatumControls.datum)) { if(this->fStationType=='h' || this->fStationType=='H') { lineNum--; // possibly new Shio output which eliminated the unused datumcontrols for height files goto skipDatumControls; } else { goto readError; } } if(err = this->GetKeyedValue(f,"DatumControls.FDir=",lineNum++,strLine,&this->fConstituent.DatumControls.FDir)) goto readError; if(err = this->GetKeyedValue(f,"DatumControls.EDir=",lineNum++,strLine,&this->fConstituent.DatumControls.EDir)) goto readError; if(err = this->GetKeyedValue(f,"DatumControls.L2Flag=",lineNum++,strLine,&this->fConstituent.DatumControls.L2Flag)) goto readError; if(err = this->GetKeyedValue(f,"DatumControls.HFlag=",lineNum++,strLine,&this->fConstituent.DatumControls.HFlag)) goto readError; if(err = this->GetKeyedValue(f,"DatumControls.RotFlag=",lineNum++,strLine,&this->fConstituent.DatumControls.RotFlag)) goto readError; skipDatumControls: if(err = this->GetKeyedValue(f,"H=",lineNum++,strLine,&this->fConstituent.H)) goto readError; if(err = this->GetKeyedValue(f,"kPrime=",lineNum++,strLine,&this->fConstituent.kPrime)) goto readError; if(!(p = GetKeyedLine(f, "[Offset]",lineNum++,strLine))) goto readError; switch(this->fStationType) { case 'c': case 'C': if(err = this->GetKeyedValue(f,"MinBefFloodTime=",lineNum++,strLine,&this->fCurrentOffset.MinBefFloodTime)) goto readError; if(err = this->GetKeyedValue(f,"FloodTime=",lineNum++,strLine,&this->fCurrentOffset.FloodTime)) goto readError; if(err = this->GetKeyedValue(f,"MinBefEbbTime=",lineNum++,strLine,&this->fCurrentOffset.MinBefEbbTime)) goto readError; if(err = this->GetKeyedValue(f,"EbbTime=",lineNum++,strLine,&this->fCurrentOffset.EbbTime)) goto readError; if(err = this->GetKeyedValue(f,"FloodSpdRatio=",lineNum++,strLine,&this->fCurrentOffset.FloodSpdRatio)) goto readError; if(err = this->GetKeyedValue(f,"EbbSpdRatio=",lineNum++,strLine,&this->fCurrentOffset.EbbSpdRatio)) goto readError; if(err = this->GetKeyedValue(f,"MinBFloodSpd=",lineNum++,strLine,&this->fCurrentOffset.MinBFloodSpd)) goto readError; if(err = this->GetKeyedValue(f,"MinBFloodDir=",lineNum++,strLine,&this->fCurrentOffset.MinBFloodDir)) goto readError; if(err = this->GetKeyedValue(f,"MaxFloodSpd=",lineNum++,strLine,&this->fCurrentOffset.MaxFloodSpd)) goto readError; if(err = this->GetKeyedValue(f,"MaxFloodDir=",lineNum++,strLine,&this->fCurrentOffset.MaxFloodDir)) goto readError; if(err = this->GetKeyedValue(f,"MinBEbbSpd=",lineNum++,strLine,&this->fCurrentOffset.MinBEbbSpd)) goto readError; if(err = this->GetKeyedValue(f,"MinBEbbDir=",lineNum++,strLine,&this->fCurrentOffset.MinBEbbDir)) goto readError; if(err = this->GetKeyedValue(f,"MaxEbbSpd=",lineNum++,strLine,&this->fCurrentOffset.MaxEbbSpd)) goto readError; if(err = this->GetKeyedValue(f,"MaxEbbDir=",lineNum++,strLine,&this->fCurrentOffset.MaxEbbDir)) goto readError; SetFileType(SHIOCURRENTSFILE); break; case 'h': case 'H': if(err = this->GetKeyedValue(f,"HighTime=",lineNum++,strLine,&this->fHeightOffset.HighTime)) goto readError; if(err = this->GetKeyedValue(f,"LowTime=",lineNum++,strLine,&this->fHeightOffset.LowTime)) goto readError; if(err = this->GetKeyedValue(f,"HighHeight_Mult=",lineNum++,strLine,&this->fHeightOffset.HighHeight_Mult)) goto readError; if(err = this->GetKeyedValue(f,"HighHeight_Add=",lineNum++,strLine,&this->fHeightOffset.HighHeight_Add)) goto readError; if(err = this->GetKeyedValue(f,"LowHeight_Mult=",lineNum++,strLine,&this->fHeightOffset.LowHeight_Mult)) goto readError; if(err = this->GetKeyedValue(f,"LowHeight_Add=",lineNum++,strLine,&this->fHeightOffset.LowHeight_Add)) goto readError; SetFileType(SHIOHEIGHTSFILE); break; case 'p': case 'P': if(err = this->GetKeyedValue(f,"HighTime=",lineNum++,strLine,&this->fHeightOffset.HighTime)) goto readError; if(err = this->GetKeyedValue(f,"LowTime=",lineNum++,strLine,&this->fHeightOffset.LowTime)) goto readError; if(err = this->GetKeyedValue(f,"HighHeight_Mult=",lineNum++,strLine,&this->fHeightOffset.HighHeight_Mult)) goto readError; if(err = this->GetKeyedValue(f,"HighHeight_Add=",lineNum++,strLine,&this->fHeightOffset.HighHeight_Add)) goto readError; if(err = this->GetKeyedValue(f,"LowHeight_Mult=",lineNum++,strLine,&this->fHeightOffset.LowHeight_Mult)) goto readError; if(err = this->GetKeyedValue(f,"LowHeight_Add=",lineNum++,strLine,&this->fHeightOffset.LowHeight_Add)) goto readError; SetFileType(PROGRESSIVETIDEFILE); break; } if(f) DisposeHandle((Handle)f); f = nil; return 0; readError: if(f) DisposeHandle((Handle)f); f = nil; sprintf(strLine,"Error reading SHIO time file %s on line %ld",this->fileName,lineNum); printError(strLine); this->Dispose(); return -1; Error: if(f) DisposeHandle((Handle)f); f = nil; return -1; }
/* AddFile - create a named file buffer * * Create and initialize a named buffer. The contents are initially * empty. * * p character pointer to name * * returns file handle to internal file structure */ PFILE AddFile ( char *p ) { PFILE pFileTmp; PFILE pFileSrch; #ifdef DEBUG /* * assert we're not attempting to add a duplicate entry */ for (pFileTmp = pFileHead; pFileTmp != NULL; pFileTmp = pFileTmp->pFileNext) { assert (_stricmp ((char *)(pFileTmp->pName), p)); } #endif pFileTmp = (PFILE) ZEROMALLOC (sizeof (*pFileTmp)); #ifdef DEBUG pFileTmp->id = ID_PFILE; #endif pFileTmp->pName = ZMakeStr (p); /* * Everything that we explicitly set NULL, we can assume, as LMAlloc init's * the allocated PFILE to all nulls. * * pFileTmp->pFileNext = NULL; * pFileTmp->cLines = 0; * pFileTmp->refCount = 0; * FLAGS(pFileTmp) = FALSE; * pFileTmp->cUndo = 0; */ pFileTmp->plr = NULL; pFileTmp->pbFile = NULL; pFileTmp->vaColor = (PVOID)(-1L); pFileTmp->vaHiLite = (PVOID)(-1L); pFileTmp->vaMarks = NULL; pFileTmp->vaUndoCur = pFileTmp->vaUndoHead = pFileTmp->vaUndoTail = (PVOID)(-1L); CreateUndoList (pFileTmp); /* * Place the file at the end of the pFile list */ if (pFileHead == NULL) { pFileHead = pFileTmp; } else { for (pFileSrch = pFileHead; pFileSrch->pFileNext; pFileSrch = pFileSrch->pFileNext) { ; } pFileSrch->pFileNext = pFileTmp; } SetFileType (pFileTmp); return pFileTmp; }
void HMQHashInit(HANDLE hMPQ) { hmqHashSize=128; for(int size=(SFileGetFileInfo(hMPQ,SFILE_INFO_NUM_FILES)+54)<<1; hmqHashSize<size; hmqHashSize<<=1) ; hmqHashFactor=hmqHashSize-1; hmqHashSize<<=1; hmqHashString=(char**)Calloc(hmqHashSize*28); hmqFileType=(char*)(hmqHashString+hmqHashSize); hmqReadFile=(char*)(hmqFileType+hmqHashSize); bufferFile=(char**)(hmqReadFile+hmqHashSize); bufferFileName=(char**)(bufferFile+hmqHashSize); bufferFileSize=(int*)(bufferFileName+hmqHashSize); bufferNeedRemove=(bool*)(bufferFileSize+hmqHashSize); bufferFileCount=0; bufferFinishCount=0; SetFileType("(attributes)",1); SetFileType("war3map.imp",2); SetFileType("war3campaign.imp",2); SetFileType("war3map.w3c",2); SetFileType("war3map.w3s",2); SetFileType("war3map.w3r",2); SetFileType("war3map.wct",2); SetFileType("war3map.wtg",2); SetFileType("war3mapunits.doo",2); SetFileType("(listfile)",3); SetFileType("war3map.wts",3); SetFileType("war3campaign.wts",3); SetFileType("war3map.w3i",3); SetFileType("war3map.doo",3); SetFileType("war3map.w3u",3); SetFileType("war3map.w3t",3); SetFileType("war3map.w3b",3); SetFileType("war3map.w3d",3); SetFileType("war3map.w3a",3); SetFileType("war3map.w3h",3); SetFileType("war3map.w3q",3); SetFileType("war3campaign.w3u",3); SetFileType("war3campaign.w3t",3); SetFileType("war3campaign.w3b",3); SetFileType("war3campaign.w3d",3); SetFileType("war3campaign.w3a",3); SetFileType("war3campaign.w3h",3); SetFileType("war3campaign.w3q",3); SetFileType("war3map.j",3); SetFileType("scripts\\war3map.j",3); SetFileType("war3mapskin.txt",3); SetFileType("war3mapmisc.txt",3); if (OPT_UNIT) { SetFileType("units\\campaignunitfunc.txt",4); SetFileType("units\\campaignunitstrings.txt",4); SetFileType("units\\humanunitfunc.txt",4); SetFileType("units\\humanunitstrings.txt",4); SetFileType("units\\neutralunitfunc.txt",4); SetFileType("units\\neutralunitstrings.txt",4); SetFileType("units\\nightelfunitfunc.txt",4); SetFileType("units\\nightelfunitstrings.txt",4); SetFileType("units\\orcunitfunc.txt",4); SetFileType("units\\orcunitstrings.txt",4); SetFileType("units\\undeadunitfunc.txt",4); SetFileType("units\\undeadunitstrings.txt",4); SetFileType("units\\unitabilities.slk",4); SetFileType("units\\unitbalance.slk",4); SetFileType("units\\unitdata.slk",4); SetFileType("units\\unitweapons.slk",4); SetFileType("units\\unitui.slk",4); } if (OPT_ITEM) { SetFileType("units\\itemdata.slk",4); SetFileType("units\\itemfunc.txt",4); SetFileType("units\\itemstrings.txt",4); } if (OPT_DEST) SetFileType("units\\destructabledata.slk",4); if (OPT_DOOD) SetFileType("doodads\\doodads.slk",4); if (OPT_ABIL) { SetFileType("units\\abilitydata.slk",4); SetFileType("units\\abilitybuffdata.slk",4); SetFileType("units\\campaignabilityfunc.txt",4); SetFileType("units\\campaignabilitystrings.txt",4); SetFileType("units\\commonabilityfunc.txt",4); SetFileType("units\\commonabilitystrings.txt",4); SetFileType("units\\humanabilityfunc.txt",4); SetFileType("units\\humanabilitystrings.txt",4); SetFileType("units\\itemabilityfunc.txt",4); SetFileType("units\\itemabilitystrings.txt",4); SetFileType("units\\neutralabilityfunc.txt",4); SetFileType("units\\neutralabilitystrings.txt",4); SetFileType("units\\nightelfabilityfunc.txt",4); SetFileType("units\\nightelfabilitystrings.txt",4); SetFileType("units\\orcabilityfunc.txt",4); SetFileType("units\\orcabilitystrings.txt",4); SetFileType("units\\undeadabilityfunc.txt",4); SetFileType("units\\undeadabilitystrings.txt",4); } if (OPT_UPGR) { SetFileType("units\\campaignupgradefunc.txt",4); SetFileType("units\\campaignupgradestrings.txt",4); SetFileType("units\\humanupgradefunc.txt",4); SetFileType("units\\humanupgradestrings.txt",4); SetFileType("units\\neutralupgradefunc.txt",4); SetFileType("units\\neutralupgradestrings.txt",4); SetFileType("units\\nightelfupgradefunc.txt",4); SetFileType("units\\nightelfupgradestrings.txt",4); SetFileType("units\\orcupgradefunc.txt",4); SetFileType("units\\orcupgradestrings.txt",4); SetFileType("units\\undeadupgradefunc.txt",4); SetFileType("units\\undeadupgradestrings.txt",4); SetFileType("units\\upgradedata.slk",4); } }
bool RawData::CheckCartridge() { SetFileType(ROM); return m_iscartridge; }