[PATCH] ecaconvert: escape input filenames
Alessandro Ghedini <[email protected]> Thu, 5 Dec 2013 21:55:46 +0100
| Newsgroups | gmane.comp.audio.ecasound.general |
|---|---|
| Message-ID | <20131205205546.GA3724@kronk> |
Hi,
the attached patch, adds escaping of input filenames to ecaconvert (it simply
replaces " " and "," with "\ " and "\\,").
The code seems to work nicely, but is rather stupid and certainly not the most
beautiful I've ever written (in my defence, C++ isn't really my thing), so if
anyone has a better idea, please come forward.
Also, I added it directly to ecaconvert instead of ecicpp_add_file_input()
because I didn't want to risk breaking other stuff, but I can easily change
this if desired.
Cheers
--
perl -E '$_=q;$/= @{[@_]};and s;\S+;<inidehG ordnasselA>;eg;say~~reverse'
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Ecasound-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ecasound-list
0001-ecaconvert-escape-input-filenames.patch
(text/x-diff, 1.5 KB)
From 6bd016829afa4d7f744d37dcaf0f718482639efa Mon Sep 17 00:00:00 2001 From: Alessandro Ghedini <[email protected]> Date: Thu, 5 Dec 2013 21:30:13 +0100 Subject: [PATCH] ecaconvert: escape input filenames --- ecatools/ecaconvert.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ecatools/ecaconvert.cpp b/ecatools/ecaconvert.cpp index e901840..c0d9874 100644 --- a/ecatools/ecaconvert.cpp +++ b/ecatools/ecaconvert.cpp @@ -47,6 +47,12 @@ using std::string; static const string ecatools_play_version = "20050316-18"; +static void escape(string& str, string& x, string& rep) +{ + for (int i = 0; (i = str.find(x, i)) != string::npos; i += rep.length()) + str.replace(i, x.length(), rep); +} + int main(int argc, char *argv[]) { COMMAND_LINE cline = COMMAND_LINE (argc, argv); @@ -58,6 +64,12 @@ int main(int argc, char *argv[]) string filename; + string space(" "); + string space_e("\\ "); + + string comma(","); + string comma_e("\\\\,"); + ECA_CONTROL_INTERFACE eci; cline.begin(); @@ -77,9 +89,12 @@ int main(int argc, char *argv[]) eci.command("cs-add default"); eci.command("c-add default"); - + + escape(filename, space, space_e); + escape(filename, comma, comma_e); + string format; - if (ecicpp_add_file_input(&eci, filename, &format) < 0) break; + if (ecicpp_add_input(&eci, filename, &format) < 0) break; cout << "Using audio format -f:" << format << "\n"; -- 1.8.5.1
signature.asc
(application/pgp-signature, 836 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) iQIcBAEBAgAGBQJSoOhSAAoJEK+lG9bN5XPL4SMP/AoKGr09V6FjxzmxOLTnxVJ/ 6FqSrU+2012LKf9kDW2dD/C3qd1eQZ4LXRJ9y/Zy+5jUZd3V+JiMq2V4M+vRVHeq ZHfscj5TDdwKNkQ8wcAUJUAR221rm2rkOjF42f0uARRLs1W9aA5Y/6/C2FV+17e/ 9voRyaJwmX0UadWhIlsnZLhS1scAAR/6QQRVftDS69+guy3D9RVjxerw7t5UQ1vV C6vBGj19pw7wfW6cB5MEnHbhcqTazHRmBaiv1n2Ha3qTGlc6NG3mZ6+0sG5BJ09Z G9xm2PMw/YU/yggwFhlz3I8qm1acE85ebvV5jU4IEovgNP/GA4Hl0A+eEPQkb1S1 CbGoKEpo0CEBrMEVL3JcqKVKpC1h6UelzeIl8Dym/619O12n6IfWLYrTXDgY6Wsd Uu9r6LXjJ1AGaQITdE9MZBGU6K3pPGrtJlQHXEtVPSfu3DEO6WjnpE1TO/n3L1im OX0sgHL7Xp58vPaAaVwOXHypktGnIOiT8fAMT6GFzkxZmj7ptUhSgtt2Sub9RY3X XVIoHqyq7co9hQgs4udwPsso7Av+B8CtlqNCG6/VXc1tVEK8I+UQ8yrohvACMap2 jyTXfT5cWWYsbjRsfa++auIaib6DyrM31WdPVvVpQzHFxkwVfz2Eis/8tz45ZLi3 MWni2c1ZciynnWlhsf4Z =GruH -----END PGP SIGNATURE-----