application/window.c

changeset 117
b174e721663e
parent 115
e57ca2747782
equal deleted inserted replaced
116:376ef91111f6 117:b174e721663e
381 return NULL; 381 return NULL;
382 } 382 }
383 383
384 cxstring fpath = cx_strn(full_path, len); 384 cxstring fpath = cx_strn(full_path, len);
385 int protocol = 0; 385 int protocol = 0;
386 if (cx_strcaseprefix(fpath, CX_STR("http://"))) { 386 if (cx_strcaseprefix(fpath, "http://")) {
387 protocol = 7; 387 protocol = 7;
388 } else if (cx_strcaseprefix(fpath, CX_STR("https://"))) { 388 } else if (cx_strcaseprefix(fpath, "https://")) {
389 protocol = 8; 389 protocol = 8;
390 } 390 }
391 391
392 size_t start = 0; 392 size_t start = 0;
393 size_t end = 0; 393 size_t end = 0;
406 skip++; // skip first '/' 406 skip++; // skip first '/'
407 } 407 }
408 408
409 409
410 cxmutstr base = cx_strdup(cx_strn(full_path, end)); 410 cxmutstr base = cx_strdup(cx_strn(full_path, end));
411 cxmutstr base_path = cx_strcat(2, cx_strcast(base), CX_STR("/")); 411 cxmutstr base_path = cx_strcat(2, cx_strcast(base), cx_str("/"));
412 cxstring path = cx_strsubs(fpath, end + skip); 412 cxstring path = cx_strsubs(fpath, end + skip);
413 413
414 cxstring trail = cx_str(len > 0 && full_path[len-1] == '/' ? "/" : ""); 414 cxstring trail = cx_str(len > 0 && full_path[len-1] == '/' ? "/" : "");
415 415
416 cxstring *pathelms; 416 cxstring *pathelms;
417 size_t nelm = 0; 417 size_t nelm = 0;
418 418
419 if (path.length > 0) { 419 if (path.length > 0) {
420 nelm = cx_strsplit_a(cxDefaultAllocator, path, CX_STR("/"), 4096, &pathelms); 420 nelm = cx_strsplit_a(cxDefaultAllocator, path, cx_str("/"), 4096, &pathelms);
421 if (nelm == 0) { 421 if (nelm == 0) {
422 *ret_nelm = 0; 422 *ret_nelm = 0;
423 return NULL; 423 return NULL;
424 } 424 }
425 } 425 }
446 cxmutstr m = cx_strdup(c); 446 cxmutstr m = cx_strdup(c);
447 elms[j].name = m.ptr; 447 elms[j].name = m.ptr;
448 elms[j].name_len = m.length; 448 elms[j].name_len = m.length;
449 449
450 size_t elm_path_len = c.ptr + c.length - full_path; 450 size_t elm_path_len = c.ptr + c.length - full_path;
451 cxmutstr elm_path = cx_strcat(2, cx_strn(full_path, elm_path_len), i+1 < nelm ? CX_STR("/") : trail); 451 cxmutstr elm_path = cx_strcat(2, cx_strn(full_path, elm_path_len), i+1 < nelm ? cx_str("/") : trail);
452 elms[j].path = elm_path.ptr; 452 elms[j].path = elm_path.ptr;
453 elms[j].path_len = elm_path.length; 453 elms[j].path_len = elm_path.length;
454 454
455 j++; 455 j++;
456 } 456 }
513 if(uri[0] == '/') { 513 if(uri[0] == '/') {
514 continue; 514 continue;
515 } 515 }
516 516
517 cxstring uri_s = cx_str(uri); 517 cxstring uri_s = cx_str(uri);
518 if(!cx_strprefix(uri_s, CX_STR("file://"))) { 518 if(!cx_strprefix(uri_s, cx_str("file://"))) {
519 return 1; 519 return 1;
520 } 520 }
521 521
522 files->files[i] = cx_strdup(cx_strsubs(uri_s, 7)).ptr; 522 files->files[i] = cx_strdup(cx_strsubs(uri_s, 7)).ptr;
523 free(uri); 523 free(uri);

mercurial