You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sds *tokens;
int count, j;
FILE *fp;
char path[10350];
/* Open the command for reading. */
fp = popen("/usr/bin/find /home/user/Desktop/|tr '/' '_'", "r");
if (fp == NULL) {
printf("Failed to run command\n" );
exit(1);
}
/* Read the output a line at a time - output it. */
while (fgets(path, sizeof(path)-1, fp) != NULL) {
{
sds y = sdsnew(path);
printf("%s",y);
sds line = sdsnew(y);
tokens = sdssplitlen(line,sdslen(line),"home_user",9,&count);
for (j = 0; j < count; j++)
printf("%s\n", tokens[j]);
sdsfreesplitres(tokens,count);
}}
Thank you for a fantastic library!!
One minor possible issue:
I am using sdssplitlen() to parse out the elements of a path+file string, as in:
/DIR1/DIR2/this_isafile.txt <-- cTempString
tokens = sdssplitlen(cTempString,sdslen(cTempString),"/",1,&count);
With an underscore in the string, sdssplitlen() returns NULL.
Haven't single-step debugged it yet. For now, avoiding using filenames with _
The text was updated successfully, but these errors were encountered: