path: handle the location with spaces [1/1]
PD#SWPL-161555
Problem:
issue related to spaces in the location
Solution:
handle the "space" case
Verify:
PB
Signed-off-by: Zhiqiang Han <zhiqiang.han@amlogic.com>
Change-Id: I286fb7c6e1453d8f542f8a29ee295edcabe93328
diff --git a/src/dvr_segment.c b/src/dvr_segment.c
index 1c9bd9c..8ec4dac 100644
--- a/src/dvr_segment.c
+++ b/src/dvr_segment.c
@@ -75,7 +75,7 @@
{
/* del file */
memset(cmd, 0, sizeof(cmd));
- sprintf(cmd, "rm %s-* %s.list %s.stats %s.odb %s.dat", location, location, location, location, location);
+ sprintf(cmd, "rm \"%s\"-* \"%s\".list \"%s\".stats \"%s\".odb \"%s\".dat", location, location, location, location, location);
fp = popen(cmd, "r");
DVR_RETURN_IF_FALSE(fp);
}
@@ -183,7 +183,7 @@
} else { /*the list file does not exist*/
uint32_t id = 0;
memset(cmd, 0, sizeof(cmd));
- sprintf(cmd, "ls -l %s-*.ts | wc -l", location);
+ sprintf(cmd, "ls -l \"%s\"-*.ts | wc -l", location);
fp = popen(cmd, "r");
DVR_RETURN_IF_FALSE(fp);
memset(buf, 0, sizeof(buf));
@@ -200,7 +200,7 @@
/*try to get the 1st segment id*/
memset(cmd, 0, sizeof(cmd));
- sprintf(cmd, "ls %s-*.ts", location);
+ sprintf(cmd, "ls \"%s\"-*.ts", location);
fp = popen(cmd, "r");
DVR_RETURN_IF_FALSE(fp);
memset(buf, 0, sizeof(buf));