*/ DEVICE_CMD Read_File(REBREQ *file) /* ***********************************************************************/ { if (GET_FLAG(file->modes, RFM_DIR)) { return Read_Directory(file, (REBREQ*)file->data); } if (!file->id) { file->error = -RFE_NO_HANDLE; return DR_ERROR; } if (file->modes & ((1 << RFM_SEEK) | (1 << RFM_RESEEK))) { CLR_FLAG(file->modes, RFM_RESEEK); if (!Seek_File_64(file)) return DR_ERROR; } // printf("read %d len %d\n", file->id, file->length); file->actual = read(file->id, file->data, file->length); if (file->actual < 0) { file->error = -RFE_BAD_READ; return DR_ERROR; } else { file->file.index += file->actual; } return DR_DONE; }
//--------------------------------------------------------------------------- void File_Tiff::Data_Parse() { int32u IFDOffset=0; if (IfdItems.empty()) { //Default values Infos.clear(); Infos[Tiff_Tag::BitsPerSample]=__T("1"); //Parsing new IFD while (Element_Offset+8+4<Element_Size) Read_Directory(); Get_X4 (IFDOffset, "IFDOffset"); } else { //Handling remaining IFD data from a previous IFD GetValueOffsetu(IfdItems.begin()->second); //Parsing the IFD item IfdItems.erase(IfdItems.begin()->first); //Removing IFD item from the list of IFD items to parse } //Some items are not inside the directory, jumping to the offset if (!IfdItems.empty()) GoTo(IfdItems.begin()->first, "TIFF"); else { //This IFD is finished, filling data then going to next IFD Data_Parse_Fill(); if (IFDOffset) GoTo(IFDOffset, "TIFF"); else { Finish(); //No more IFDs GoToFromEnd(0); } } }
//--------------------------------------------------------- int CTL_Extract::Read_Directory(const SG_Char *Directory, CSG_Table &Elements) { int nFiles = 0; wxString Name, s; wxFileName File; wxDir Dir; if( !Dir.Open(Directory) ) { return( nFiles ); } File.AssignDir(Directory); if( Dir.GetFirst(&Name, "*.cpp", wxDIR_FILES|wxDIR_HIDDEN) ) { do { File.SetFullName(Name); nFiles += Read_File(s = File.GetFullPath(), Elements); } while( Dir.GetNext(&Name) ); } if( Dir.GetFirst(&Name, "*.h" , wxDIR_FILES|wxDIR_HIDDEN) ) { do { File.SetFullName(Name); nFiles += Read_File(s = File.GetFullPath(), Elements); } while( Dir.GetNext(&Name) ); } if( Dir.GetFirst(&Name, "*.xml", wxDIR_FILES|wxDIR_HIDDEN) ) { do { File.SetFullName(Name); nFiles += Read_ToolChain(s = File.GetFullPath(), Elements); } while( Dir.GetNext(&Name) ); } if( Dir.GetFirst(&Name, "*" , wxDIR_DIRS |wxDIR_HIDDEN) ) { do { File.AssignDir(Directory); File.AppendDir(Name); nFiles += Read_Directory(s = File.GetFullPath(), Elements); } while( Dir.GetNext(&Name) ); } return( nFiles ); }
//--------------------------------------------------------- bool CTL_Extract::On_Execute(void) { //----------------------------------------------------- CSG_Table Elements; Elements.Add_Field(SG_T("TEXT"), SG_DATATYPE_String); Elements.Add_Field(SG_T("FILE"), SG_DATATYPE_String); int nFiles = Read_Directory(Parameters("DIRECTORY")->asString(), Elements); if( nFiles <= 0 ) { Error_Set(SG_T("no source code files found")); return( false ); } Message_Add(CSG_String::Format("\n%s: %d", SG_T("number of scanned files"), nFiles), false); if( Elements.Get_Count() <= 0 ) { Error_Set(SG_T("no translatable text elements found")); return( false ); } Message_Add(CSG_String::Format("\n%s: %d", SG_T("number of translatable elements"), Elements.Get_Count()), false); //----------------------------------------------------- Process_Set_Text(SG_T("collecting elements")); CSG_String Text; bool bLocation = Parameters("LOCATION" )->asBool(); CSG_Table *pTarget = Parameters("TARGET")->asTable(); pTarget->Destroy(); pTarget->Set_Name(SG_T("Translatable Elements")); pTarget->Add_Field("TEXT" , SG_DATATYPE_String); pTarget->Add_Field("TRANSLATION", SG_DATATYPE_String); if( bLocation ) { pTarget->Add_Field("FILE" , SG_DATATYPE_String); } Elements.Set_Index(0, TABLE_INDEX_Ascending); for(int i=0; i<Elements.Get_Count() && Set_Progress(i, Elements.Get_Count()); i++) { if( i == 0 || Text.Cmp(Elements.Get_Record_byIndex(i)->asString(0)) ) { Text = Elements.Get_Record_byIndex(i)->asString(0); CSG_Table_Record *pRecord = pTarget->Add_Record(); pRecord->Set_Value(0, Text); if( bLocation ) { pRecord->Set_Value(2, Elements.Get_Record_byIndex(i)->asString(1)); } } } //----------------------------------------------------- return( true ); }