Hi!
My QProcess doesn't run command if it contains spaces in filenames.
E.g. if I run such a line from command line ( bash or sh ):
$mplayer dvd://1 -dvd-device /mnt/work/video/torrents/HQ/Film\ 1\ 2\ 3
it works.
But if I run exactly the same line from QProcess -- it doesn't work:
|
Source code
|
1
2
|
QProcess my_process;
my_process.start(QString(mlayer dvd://1 -dvd-device /mnt/work/video/torrents/HQ/Film\ 1\ 2\ 3));
|
Here we go:
1. extract filename from QTreeView ( QDirModel ):
|
Source code
|
1
2
|
QModelIndex cur_index = directory_browser->currentIndex();
QString dvd_dir_name = directories->filePath( cur_index )
|
dvd_dir_name == "dir 1 2 3" ( for example )
2. replace all spaces with '\ ' construction:
|
Source code
|
1
|
dvd_dir_name.replace( QRegExp( " " ), "\\ " );
|
dvd_dir_name == "dir\ 1\ 2\ 3"
3. Prepare command line:
|
Source code
|
1
2
|
QString command_line = "some_process";
command_line += dvd_dir_name;
|
command_line == "some_process dir\ 1\ 2\ 3"
4. Finally run process with command_line:
|
Source code
|
1
2
|
QProcess mplayer_process;
mplayer_process.start( command_line);
|
On my Linux machine QProcess runs such a command:
|
Source code
|
1
|
$mplayer dvd://1 -dvd-device /mnt/work/video/torrents/HQ/Film\ 1\ 2\ 3
|
The problem is if I run mplayer from QProcess -- it fails, but if I run
exactly the same command from bash or sh it works fine...
What may it be with QProcess and spaces in dir filename?
P.S. here is log for mplayer:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
|
Playing dvd://1.
Playing 1\.
Playing 2\.
Playing 3.
|