void PixInsightX11Installer::DirectorySearch_Recursive( StringList& foundItems, const String& dirPath, const String& baseDir ) { if ( dirPath.Has( ".." ) ) throw Error( "SearchDirectory(): Attempt to redirect outside the base directory." ); if ( !dirPath.BeginsWith( baseDir ) ) throw Error( "SearchDirectory(): Attempt to redirect outside the base directory." ); if ( !File::DirectoryExists( dirPath ) ) throw Error( "SearchDirectory(): Attempt to search a nonexistent directory." ); String currentDir = dirPath; if ( !currentDir.EndsWith( '/' ) ) currentDir += '/'; StringList directories; FindFileInfo info; for ( File::Find f( currentDir + "*" ); f.NextItem( info ); ) if ( info.IsDirectory() ) { if ( info.name != "." && info.name != ".." ) { directories.Add( info.name ); foundItems.Add( currentDir + info.name + '/' ); } } else foundItems.Add( currentDir + info.name ); for ( StringList::const_iterator i = directories.Begin(); i != directories.End(); ++i ) DirectorySearch_Recursive( foundItems, currentDir + *i, baseDir ); }
static void SearchDirectory_Recursive( StringList& fileNames, const String& fileName, bool recursive ) { String fileDir = File::ExtractDrive( fileName ) + File::ExtractDirectory( fileName ); String wildSpec = File::ExtractName( fileName ) + File::ExtractExtension( fileName ); FindFileInfo info; for ( File::Find f( fileName ); f.NextItem( info ); ) if ( !info.IsDirectory() ) if ( info.name.WildMatch( wildSpec ) ) { String path = fileDir + '/' + info.name; if ( !fileNames.Contains( path ) ) fileNames.Add( path ); } if ( recursive ) { StringList directories; for ( File::Find f( fileDir + "/*" ); f.NextItem( info ); ) if ( info.IsDirectory() && info.name != "." && info.name != ".." ) directories.Add( info.name ); for ( StringList::const_iterator i = directories.Begin(); i != directories.End(); ++i ) SearchDirectory_Recursive( fileNames, fileDir + '/' + *i + '/' + wildSpec, true ); } }
void FillFormat(const char *TypeName) { GetIniString(TypeName, "Start", "", StartText, sizeof(StartText)); GetIniString(TypeName, "End", "", EndText, sizeof(EndText)); int FormatNumber = 0; delete Format; Format = new StringList; for(StringList * CurFormat = Format;; CurFormat = CurFormat->Add()) { char FormatName[100]; SPrintf(FormatName, "Format%d", FormatNumber++); GetIniString(TypeName, FormatName, "", CurFormat->Str(), PROF_STR_LEN); if(*CurFormat->Str() == 0) break; } int Number = 0; delete IgnoreStrings; IgnoreStrings = new StringList; for(StringList * CurIgnoreString = IgnoreStrings;; CurIgnoreString = CurIgnoreString->Add()) { char Name[100]; SPrintf(Name, "IgnoreString%d", Number++); GetIniString(TypeName, Name, "", CurIgnoreString->Str(), PROF_STR_LEN); if(*CurIgnoreString->Str() == 0) break; } }
StringList CSxSParser::FindMatchedFSObjects(LPCTSTR szParentFolder, LPCTSTR szFilter, BOOL bIsFile) const { CString strParent(szParentFolder); if(strParent[strParent.GetLength() - 1] != _T('\\')) strParent += _T('\\'); CString strFilter(strParent); strFilter += szFilter; StringList listResult; WIN32_FIND_DATA data; HANDLE hFind = ::FindFirstFile(strFilter, &data); if(hFind == INVALID_HANDLE_VALUE) return listResult; CString strFilePath; do { if(_tcscmp(data.cFileName, _T(".")) == 0 || _tcscmp(data.cFileName, _T("..")) == 0) continue; if(bIsFile && ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)) continue; if(!bIsFile && ((data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)) continue; strFilePath = data.cFileName; listResult.Add(strFilePath); } while (::FindNextFile(hFind, &data)); ::FindClose(hFind); return listResult; }
void FontComboBox::ResetFonts() { // ### TODO: Add item icons for standard, scalable, bitmapped and fixed-pitch fonts. StringList faces = Font::AvailableFonts(); for ( size_type i = 0; i < ItemsInArray( s_standardFaces ); ++i ) if ( !faces.Has( s_standardFaces[i] ) ) faces.Add( s_standardFaces[i] ); faces.Sort(); SetFaceList( this, faces ); }
StringList getSelectionListFromSettings(const SimulationSettings& settings) { //read from settings the variables found in the amounts and concentrations lists StringList theList; TSelectionRecord record; int nrOfVars = settings.mVariables.Count(); for(int i = 0; i < settings.mAmount.Count(); i++) { theList.Add("[" + settings.mAmount[i] + "]"); //In the setSelection list below, the [] selects the correct 'type' } for(int i = 0; i < settings.mConcentration.Count(); i++) { theList.Add(settings.mConcentration[i]); } //We may have variables //A variable 'exists' only in "variables", not in the amount or concentration section int currCount = theList.Count(); if( nrOfVars > currCount) { //Look for a variable that is not in the list for(int i = 0; i < settings.mVariables.Count(); i++) { string aVar = settings.mVariables[i]; if(settings.mAmount.DontContain(aVar) && settings.mConcentration.DontContain(aVar)) { theList.Add(settings.mVariables[i]); } } } theList.InsertAt(0, "time"); return theList; }
StringList TMForm::GetCheckedSpecies() { //Go trough the listbox and return checked items StringList checked; for(int i = 0; i < SelList->Count; i++) { if(SelList->Checked[i]) { String anItem = SelList->Items->Strings[i]; checked.Add(ToSTDString(anItem)); } } return checked; }
json_t* OBSAPIMessageHandler::HandleSetSourcesOrder(OBSAPIMessageHandler* handler, json_t* message) { StringList sceneNames; json_t* arry = json_object_get(message, "scene-names"); if(arry != NULL && json_typeof(arry) == JSON_ARRAY) { for(size_t i = 0; i < json_array_size(arry); i++) { json_t* sceneName = json_array_get(arry, i); String name = json_string_value(sceneName); sceneNames.Add(name); } OBSSetSourceOrder(sceneNames); } return GetOkResponse(); }
static int32 api_func ProcessCommandLine( meta_process_handle hp, int32 argc, const char16_type** argv ) { bool wasConsoleOutput = Exception::IsConsoleOutputEnabled(); bool wasGUIOutput = Exception::IsGUIOutputEnabled(); try { StringList args; for ( int i = 0; i < argc; ++i ) args.Add( String( argv[i] ) ); Exception::EnableConsoleOutput(); Exception::DisableGUIOutput(); int result = process->ProcessCommandLine( args ); Exception::EnableConsoleOutput( wasConsoleOutput ); Exception::EnableGUIOutput( wasGUIOutput ); return result; } catch ( Exception& x ) { Console().WriteLn( "<end><cbr>" + x.FormatInfo() ); } catch ( ... ) { try { throw; } ERROR_HANDLER } Exception::EnableConsoleOutput( wasConsoleOutput ); Exception::EnableGUIOutput( wasGUIOutput ); return -1; }
PixInsightX11Installer::PixInsightX11Installer( int argc, const char** argv ) { // Install PixInsight by default. m_task = InstallTask; // Assume that we get a path to the executable file (possibly a relative // path) in argv[0]. This is standard in all known unices. m_executablePath = Unquoted( String::UTF8ToUTF16( argv[0] ) ).Trimmed(); // Base directory where we are running. m_baseDir = File::FullPath( File::ExtractDirectory( m_executablePath ) ); if ( m_baseDir.EndsWith( '/' ) ) m_baseDir.Delete( m_baseDir.UpperBound() ); // Default source installation directory. m_sourceDir = m_baseDir + "/PixInsight"; // Default application installation directory. m_installDir = "/opt/PixInsight"; // Default desktop entry installation directory. m_installDesktopDir = "/usr/share/applications"; if ( !File::DirectoryExists( m_installDesktopDir ) ) m_installDesktopDir = "/usr/local/share/applications"; // FreeBSD // Default application icons installation directory. m_installIconsDir = "/usr/share/icons/hicolor"; if ( !File::DirectoryExists( m_installIconsDir ) ) m_installIconsDir = "/usr/local/share/icons/hicolor"; // FreeBSD // By default, we create a launcher script on /bin so one can say just // PixInsight from a terminal. m_createBinLauncher = true; // By default, we do not backup a previous installation. m_removePrevious = true; // Assume we are running on an UTF-8 POSIX-compliant system. StringList inputArgs; for ( int i = 1; i < argc; ++i ) inputArgs.Add( IsoString( argv[i] ).UTF8ToUTF16() ); // Parse the list of command-line arguments. ArgumentList arguments = ExtractArguments( inputArgs, ArgumentItemMode::NoItems ); // Iterate and interpret command-line arguments. for ( ArgumentList::const_iterator i = arguments.Begin(); i != arguments.End(); ++i ) { if ( i->IsNumeric() ) { throw Error( "Unknown numeric argument: " + i->Token() ); } else if ( i->IsString() ) { if ( i->Id() == "-source-dir" || i->Id() == "s" ) m_sourceDir = i->StringValue(); else if ( i->Id() == "-install-dir" || i->Id() == "i" ) m_installDir = i->StringValue(); else if ( i->Id() == "-install-desktop-dir" ) m_installDesktopDir = i->StringValue(); else if ( i->Id() == "-install-icons-dir" ) m_installIconsDir = i->StringValue(); else throw Error( "Unknown string argument: " + i->Token() ); } else if ( i->IsSwitch() ) { if ( i->Id() == "-remove" || i->Id() == "r" ) m_removePrevious = i->SwitchState(); else if ( i->Id() == "-bin-launcher" ) m_createBinLauncher = i->SwitchState(); else throw Error( "Unknown switch argument: " + i->Token() ); } else if ( i->IsLiteral() ) { if ( i->Id() == "-remove" || i->Id() == "r" ) m_removePrevious = true; else if ( i->Id() == "-no-remove" || i->Id() == "r" ) // also support the --no-xxx idiom m_removePrevious = false; else if ( i->Id() == "-bin-launcher" ) m_createBinLauncher = true; else if ( i->Id() == "-no-bin-launcher" ) m_createBinLauncher = false; else if ( i->Id() == "-uninstall" || i->Id() == "u" ) m_task = UninstallTask; else if ( i->Id() == "-version" ) m_task = ShowVersionTask; else if ( i->Id() == "-help" ) m_task = ShowHelpTask; else throw Error( "Unknown argument: " + i->Token() ); } else if ( i->IsItemList() ) { throw Error( "Unexpected non-parametric argument: " + i->Token() ); } } // Sanitize working directories. if ( m_sourceDir.EndsWith( '/' ) ) m_sourceDir.Delete( m_sourceDir.UpperBound() ); if ( m_installDir.EndsWith( '/' ) ) m_installDir.Delete( m_installDir.UpperBound() ); if ( m_installDesktopDir.EndsWith( '/' ) ) m_installDesktopDir.Delete( m_installDesktopDir.UpperBound() ); if ( m_installIconsDir.EndsWith( '/' ) ) m_installIconsDir.Delete( m_installIconsDir.UpperBound() ); // Launcher script m_binLauncherFile = "/bin/PixInsight"; // Application desktop entry file m_desktopEntryFile = m_installDesktopDir + "/PixInsight.desktop"; // Application icon files m_icon16x16File = m_installIconsDir + "/16x16/apps/PixInsight.png"; m_icon24x24File = m_installIconsDir + "/24x24/apps/PixInsight.png"; m_icon32x32File = m_installIconsDir + "/32x32/apps/PixInsight.png"; m_icon48x48File = m_installIconsDir + "/48x48/apps/PixInsight.png"; m_icon64x64File = m_installIconsDir + "/64x64/apps/PixInsight.png"; m_icon128x128File = m_installIconsDir + "/128x128/apps/PixInsight.png"; m_icon256x256File = m_installIconsDir + "/256x256/apps/PixInsight.png"; // Source icon files m_sourceIcon16x16File = m_sourceDir + "/rsc/icons/pixinsight-icon.16.png"; m_sourceIcon24x24File = m_sourceDir + "/rsc/icons/pixinsight-icon.24.png"; m_sourceIcon32x32File = m_sourceDir + "/rsc/icons/pixinsight-icon.32.png"; m_sourceIcon48x48File = m_sourceDir + "/rsc/icons/pixinsight-icon.48.png"; m_sourceIcon64x64File = m_sourceDir + "/rsc/icons/pixinsight-icon.64.png"; m_sourceIcon128x128File = m_sourceDir + "/rsc/icons/pixinsight-icon.128.png"; m_sourceIcon256x256File = m_sourceDir + "/rsc/icons/pixinsight-icon.256.png"; }
ArgumentList ExtractArguments( const StringList& argv, argument_item_mode mode, ArgumentOptions options ) { bool noItems = mode == ArgumentItemMode::NoItems; bool itemsAsFiles = mode == ArgumentItemMode::AsFiles; bool itemsAsViews = mode == ArgumentItemMode::AsViews; bool allowWildcards = !noItems && options.IsFlagSet( ArgumentOption::AllowWildcards ); bool noPreviews = itemsAsViews && options.IsFlagSet( ArgumentOption::NoPreviews ); bool recursiveDirSearch = itemsAsFiles && allowWildcards && options.IsFlagSet( ArgumentOption::RecursiveDirSearch ); bool recursiveSearchArgs = recursiveDirSearch && options.IsFlagSet( ArgumentOption::RecursiveSearchArgs ); // This is the recursive search mode flag, controlled by --r[+|-] bool recursiveSearch = false; // The list of existing view identifiers, in case itemsAsViews = true. SortedStringList imageIds; // The list of extracted arguments ArgumentList arguments; for ( StringList::const_iterator i = argv.Begin(); i != argv.End(); ++i ) { if ( i->StartsWith( '-' ) ) { Argument arg( i->At( 1 ) ); if ( recursiveSearchArgs && arg.Id() == s_recursiveSearchArg ) { if ( arg.IsSwitch() ) recursiveSearch = arg.SwitchState(); else if ( arg.IsLiteral() ) recursiveSearch = true; else arguments.Add( arg ); } else arguments.Add( arg ); } else { if ( noItems ) throw ParseError( "Non-parametric arguments are not allowed", *i ); StringList items; if ( itemsAsFiles ) { String fileName = *i; if ( fileName.StartsWith( '\"' ) ) fileName.Delete( 0 ); if ( fileName.EndsWith( '\"' ) ) fileName.Delete( fileName.UpperBound() ); fileName.Trim(); if ( fileName.IsEmpty() ) throw ParseError( "Empty path specification", *i ); fileName = File::FullPath( fileName ); if ( fileName.HasWildcards() ) { if ( !allowWildcards ) throw ParseError( "Wildcards not allowed", fileName ); items = SearchDirectory( fileName, recursiveSearch ); } else items.Add( fileName ); } else if ( itemsAsViews ) { String viewId = *i; if ( !allowWildcards ) if ( viewId.HasWildcards() ) throw ParseError( "Wildcards not allowed", viewId ); size_type p = viewId.Find( "->" ); if ( p != String::notFound ) { if ( noPreviews ) throw ParseError( "Preview identifiers not allowed", viewId ); String imageId = viewId.Left( p ); if ( imageId.IsEmpty() ) throw ParseError( "Missing image identifier", viewId ); String previewId = viewId.Substring( p+2 ); if ( previewId.IsEmpty() ) throw ParseError( "Missing preview identifier", viewId ); FindPreviews( items, imageId, previewId ); } else { if ( viewId.HasWildcards() ) { Array<ImageWindow> W = ImageWindow::AllWindows(); for ( size_type i = 0; i < W.Length(); ++i ) { View v = W[i].MainView(); if ( String( v.Id() ).WildMatch( viewId ) ) AddView( items, v ); } } else { ImageWindow w = ImageWindow::WindowById( IsoString( viewId ) ); if ( w.IsNull() ) throw ParseError( "Image not found", viewId ); AddView( items, w.MainView() ); } } } else items.Add( *i ); Argument arg( *i, items ); arguments.Add( arg ); } } return arguments; }
static void AddView( StringList& items, const View& v ) { String id( v.FullId() ); if ( !items.Contains( id ) ) items.Add( id ); }
ConvolutionFilterCodeDialog::ConvolutionFilterCodeDialog( String mode, const Filter& _filter ) : Dialog(), filter( _filter ) { // ### TextBox FilterCode_TextBox.SetScaledMinSize( 700, 300 ); FilterCode_TextBox.OnCaretPositionUpdated( (TextBox::caret_event_handler)&ConvolutionFilterCodeDialog::__TextBox_CaretPosition, *this ); if ( mode == "Edit" ) { FilterCode_TextBox.SetReadWrite(); FilterCode_TextBox.SetText( filter.ToSource() ); } tableRow = 0; String s; String html( "<html style=\"white-space:pre;text-align:right;\">" "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">" ); StringList cols; UpdateTableColors(); if ( mode == "View" ) { FilterCode_TextBox.SetReadOnly(); if ( filter.IsSeparable() ) { SeparableFilter fs( filter.Separable() ); float element; // Rows for ( int i = 0; i < fs.Size(); ++i ) { // Cols for ( int j = 0; j < fs.Size(); ++j ) { // Calculus of each coefficient of the separable filter element = Round( fs.ColFilter()[i] * fs.RowFilter()[j], 6 ); cols.Add( String().Format( "%10.6f", element ) ); } html += TR( cols ); cols.Clear(); } } else { KernelFilter k( filter.Kernel() ); for ( int i = 0; i < k.Size(); ++i ) { for ( int j = 0; j < k.Size(); ++j ) { float element = Round( k.Coefficients()[i][j], 6 ); // The elements of the KernelFilter can be accessed directly God thanks and the [] operator. cols.Add( String().Format( "%10.6f", element ) ); } html += TR( cols ); cols.Clear(); } } html += "</table></html>"; // We got it!! we set the TextBox text by passing the composed String s. FilterCode_TextBox.SetText( html ); UpdateTableColors(); } if ( mode == "View" ) LineCol_Label.Hide(); else LineCol_Label.Show(); LineCol_Sizer.SetSpacing( 4 ); LineCol_Sizer.Add( LineCol_Label ); LineCol_Sizer.AddStretch(); // ### Save PushButton Save_PushButton.SetText( "Save" ); Save_PushButton.SetCursor( StdCursor::Checkmark ); Save_PushButton.OnClick( (Button::click_event_handler)&ConvolutionFilterCodeDialog::__Button_Click, *this ); if ( mode == "View" ) Save_PushButton.Hide(); else Save_PushButton.SetDefault(); if ( mode == "View" ) { Cancel_PushButton.SetText( "Close" ); Cancel_PushButton.SetCursor( StdCursor::Checkmark ); Cancel_PushButton.SetDefault(); } else { Cancel_PushButton.SetText( "Cancel" ); Cancel_PushButton.SetCursor( StdCursor::Crossmark ); } Cancel_PushButton.OnClick( (Button::click_event_handler)&ConvolutionFilterCodeDialog::__Button_Click, *this ); DialogButtons_Sizer.SetSpacing( 8 ); DialogButtons_Sizer.AddStretch(); DialogButtons_Sizer.Add( Save_PushButton ); DialogButtons_Sizer.Add( Cancel_PushButton ); DialogButtons_Sizer.AddStretch(); Global_Sizer.SetMargin( 4 ); Global_Sizer.SetSpacing( 4 ); Global_Sizer.Add( FilterCode_TextBox ); Global_Sizer.Add( LineCol_Sizer ); Global_Sizer.Add( DialogButtons_Sizer ); SetSizer( Global_Sizer ); EnableUserResizing(); AdjustToContents(); BringToFront(); //SetFixedSize(); if ( mode == "View" ) SetWindowTitle( '\"' + filter.Name() + '\"' + " filter elements" ); else if ( mode == "Edit" ) SetWindowTitle( '\"' + filter.Name() + '\"' + " edit" ); else if ( mode == "New" ) SetWindowTitle( "New filter" ); else throw Error( "Internal error: Invalid dialog operation mode in ConvolutionFilterCodeDialog" ); }
StringList JPCFormat::FileExtensions() const { StringList exts; exts.Add( ".jpc" ); exts.Add( ".j2c" ); return exts; }
StringList JP2Format::FileExtensions() const { StringList exts; exts.Add( ".jp2" ); exts.Add( ".jpx" ); exts.Add( ".jpk" ); exts.Add( ".j2k" ); return exts; }