Miscellaneous helpers for the GUI start. More...
#include <dirent.h>#include <unistd.h>#include <glob.h>#include <cerrno>#include <vector>#include <cmath>#include <sstream>#include <iostream>#include <fstream>#include <cstdlib>#include <qfiledialog.h>#include <qmessagebox.h>#include "op_file.h"#include "file_manip.h"#include "child_reader.h"#include "op_libiberty.h"#include "oprof_start.h"#include "oprof_start_util.h"
Functions | |
| string const | get_config_filename (string const &filename) |
| get_config_filename - get absolute filename of file in user $HOME | |
| bool | check_and_create_config_dir () |
| check_and_create_config_dir - make sure config dir is accessible | |
| string const | format (string const &orig, uint const maxlen) |
| format - re-format a string | |
| int | do_exec_command (string const &cmd, vector< string > const &args) |
| do_exec_command - execute a command | |
| string const | do_open_file_or_dir (string const &base_dir, bool dir_only) |
| do_open_file_or_dir - open file/directory | |
| bool | verify_argument (string const &str) |
| verify_argument - check string for potentially dangerous characters | |
Miscellaneous helpers for the GUI start.
| bool check_and_create_config_dir | ( | ) |
check_and_create_config_dir - make sure config dir is accessible
Returns true if the dir is accessible.
References create_dir(), and get_config_filename().
| int do_exec_command | ( | string const & | cmd, | |
| vector< string > const & | args | |||
| ) |
do_exec_command - execute a command
| cmd | command name | |
| args | arguments to command |
Execute a command synchronously. An error message is shown if the command returns a non-zero status, which is also returned.
The arguments are verified and will refuse to execute if they contain shell metacharacters.
References error(), child_reader::error(), child_reader::error_str(), format(), child_reader::get_data(), child_reader::terminate_process(), and verify_argument().
Referenced by oprof_start::on_flush_profiler_data(), oprof_start::on_reset_sample_files(), oprof_start::on_start_profiler(), oprof_start::on_stop_profiler(), and oprof_start::oprof_start().
| string const do_open_file_or_dir | ( | string const & | base_dir, | |
| bool | dir_only | |||
| ) |
do_open_file_or_dir - open file/directory
| base_dir | directory to start at | |
| dir_only | directory or filename to select |
Select a file or directory. The selection is returned; an empty string if the selection was cancelled.
Referenced by oprof_start::choose_kernel_filename().
| string const format | ( | string const & | orig, | |
| uint const | maxlen | |||
| ) |
format - re-format a string
| orig | string to format | |
| maxlen | width of line |
Re-formats a string to fit into a certain width, breaking lines at spaces between words.
Returns the formatted string
Referenced by Agent_OnLoad(), and do_exec_command().
| string const get_config_filename | ( | string const & | filename | ) |
get_config_filename - get absolute filename of file in user $HOME
| filename | the relative filename |
Get the absolute path of a file in a user's home directory.
Referenced by check_and_create_config_dir().
| bool verify_argument | ( | string const & | str | ) |
verify_argument - check string for potentially dangerous characters
This function returns false if the string contains dangerous shell metacharacters.
WWW Security FAQ dangerous chars:
& ; ` ' \ | * ? ~ < > ^ ( ) [ ] { } $
David Wheeler: ! #
We allow '-' because we disallow whitespace. We allow ':' and '='
Referenced by do_exec_command().
1.6.1