#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"
Go to the source code of this file.
Functions | |
| string const | get_config_filename (string const &filename) |
| bool | check_and_create_config_dir () |
| string const | format (string const &orig, uint const maxlen) |
| int | do_exec_command (string const &cmd, vector< string > const &args) |
| string const | do_open_file_or_dir (string const &base_dir, bool dir_only) |
| bool | verify_argument (string const &str) |
Miscellaneous helpers for the GUI start
Definition in file oprof_start_util.cpp.
| bool check_and_create_config_dir | ( | ) |
check_and_create_config_dir - make sure config dir is accessible
Returns true if the dir is accessible.
Definition at line 155 of file oprof_start_util.cpp.
References create_dir(), and get_config_filename().
Referenced by oprof_start::load_config_file().


| 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.
Definition at line 240 of file oprof_start_util.cpp.
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(), oprof_start::oprof_start(), and oprof_start::save_config().


| 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.
Definition at line 291 of file oprof_start_util.cpp.
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
Definition at line 187 of file oprof_start_util.cpp.
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.
Definition at line 144 of file oprof_start_util.cpp.
Referenced by check_and_create_config_dir(), oprof_start::load_config_file(), and oprof_start::read_set_events().

| 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 '='
Definition at line 323 of file oprof_start_util.cpp.
Referenced by do_exec_command().

1.6.1