test/test_physfs.c
changeset 165 cbb1b0dcf6da
parent 164 a93a65be81fb
child 170 d826bf2c38c8
equal deleted inserted replaced
164:a93a65be81fb 165:cbb1b0dcf6da
   100 } /* cmd_deinit */
   100 } /* cmd_deinit */
   101 
   101 
   102 
   102 
   103 static int cmd_addarchive(char *args)
   103 static int cmd_addarchive(char *args)
   104 {
   104 {
   105     char *ptr = strchr(args, ' ');
   105     char *ptr = strrchr(args, ' ');
   106     int appending = atoi(ptr + 1);
   106     int appending = atoi(ptr + 1);
   107     *ptr = '\0';
   107     *ptr = '\0';
       
   108 
       
   109     if (*args == '\"')
       
   110     {
       
   111         args++;
       
   112         *(ptr - 1) = '\0';
       
   113     }
       
   114 
       
   115     /*printf("[%s], [%d]\n", args, appending);*/
   108 
   116 
   109     if (PHYSFS_addToSearchPath(args, appending))
   117     if (PHYSFS_addToSearchPath(args, appending))
   110         printf("Successful.\n");
   118         printf("Successful.\n");
   111     else
   119     else
   112         printf("Failure. reason: %s.\n", PHYSFS_getLastError());
   120         printf("Failure. reason: %s.\n", PHYSFS_getLastError());
   367 
   375 
   368 /* must have spaces trimmed prior to this call. */
   376 /* must have spaces trimmed prior to this call. */
   369 static int count_args(const char *str)
   377 static int count_args(const char *str)
   370 {
   378 {
   371     int retval = 0;
   379     int retval = 0;
       
   380     int in_quotes = 0;
   372 
   381 
   373     if (str != NULL)
   382     if (str != NULL)
   374     {
   383     {
   375         for (; *str != '\0'; str++)
   384         for (; *str != '\0'; str++)
   376         {
   385         {
   377             if (*str == ' ')
   386             if (*str == '\"')
       
   387                 in_quotes = !in_quotes;
       
   388             else if ((*str == ' ') && (!in_quotes))
   378                 retval++;
   389                 retval++;
   379         } /* for */
   390         } /* for */
   380         retval++;
   391         retval++;
   381     } /* if */
   392     } /* if */
   382 
   393