Branch Coverage

file.c
Criterion Covered Total %
branch 1065 1866 57.0


line true false branch
126 28 28 if (!g_file_plugin_registry)
134 56 0 if (!plugin || !plugin->name || !*plugin->name) return -1;
56 0 if (!plugin || !plugin->name || !*plugin->name) return -1;
0 56 if (!plugin || !plugin->name || !*plugin->name) return -1;
138 1 55 if (hv_exists(g_file_plugin_registry, plugin->name, name_len))
142 0 55 if (!hv_store(g_file_plugin_registry, plugin->name, name_len, entry, 0)) {
150 12 0 if (!g_file_plugin_registry || !name) return 0;
0 12 if (!g_file_plugin_registry || !name) return 0;
151 7 5 if (g_file_last_plugin && strcmp(g_file_last_plugin->name, name) == 0)
7 0 if (g_file_last_plugin && strcmp(g_file_last_plugin->name, name) == 0)
161 0 66 if (!name) return NULL;
162 49 17 if (g_file_last_plugin && strcmp(g_file_last_plugin->name, name) == 0)
21 28 if (g_file_last_plugin && strcmp(g_file_last_plugin->name, name) == 0)
164 0 45 if (!g_file_plugin_registry) return NULL;
167 40 5 if (!svp || !*svp) return NULL;
0 40 if (!svp || !*svp) return NULL;
181 0 60 if (start >= items) return NULL;
182 2 58 if ((items - start) % 2 != 0)
187 73 58 for (i = start; i < items; i += 2) {
193 0 73 if (!SvOK(key_sv))
197 0 73 if (!hv_store(opts, key, (I32)key_len, SvREFCNT_inc(val_sv), 0)) {
202 55 18 if (key_len == 6 && memcmp(key, "plugin", 6) == 0)
55 0 if (key_len == 6 && memcmp(key, "plugin", 6) == 0)
206 3 55 if (!has_plugin) {
247 16 30 if (chain->per_plugin) {
248 28 16 for (i = 0; i < chain->count; i++) {
249 3 25 if (chain->per_plugin[i])
255 16 30 if (chain->shared) {
259 46 0 if (chain->plugins) {
283 51 0 if (!slot || !*slot || !SvOK(*slot))
51 0 if (!slot || !*slot || !SvOK(*slot))
0 51 if (!slot || !*slot || !SvOK(*slot))
288 34 17 if (!SvROK(plugin_sv)) {
291 4 30 if (!p) croak("File::Raw::%s: unknown plugin '%s'", fn_name, name);
298 0 17 if (SvTYPE(SvRV(plugin_sv)) != SVt_PVAV)
304 0 17 if (n <= 0)
307 0 17 Newx(out->plugins, n, const FilePlugin *);
310 30 17 for (i = 0; i < n; i++) {
314 30 0 if (!np || !*np || !SvOK(*np))
30 0 if (!np || !*np || !SvOK(*np))
0 30 if (!np || !*np || !SvOK(*np))
317 0 30 if (SvROK(*np))
322 0 30 if (!p)
333 0 17 Newxz(out->per_plugin, n, HV *);
338 22 17 while ((he = hv_iternext(opts))) {
345 17 5 if (klen == 6 && memcmp(key, "plugin", 6) == 0) continue;
17 0 if (klen == 6 && memcmp(key, "plugin", 6) == 0) continue;
347 3 2 if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVHV) {
3 0 if (SvROK(val) && SvTYPE(SvRV(val)) == SVt_PVHV) {
349 4 0 for (j = 0; j < (int)n; j++) {
352 3 1 if (plen == klen && memcmp(key, pn, klen) == 0) {
3 0 if (plen == klen && memcmp(key, pn, klen) == 0) {
359 3 2 if (matched >= 0) {
378 4 0 if (!slot || !*slot || !SvOK(*slot))
4 0 if (!slot || !*slot || !SvOK(*slot))
0 4 if (!slot || !*slot || !SvOK(*slot))
380 2 2 if (SvROK(*slot))
386 1 1 if (!p) croak("File::Raw::%s: unknown plugin '%s'", fn_name, name);
402 28 0 if (chain->shared) {
404 4 28 while ((he = hv_iternext(chain->shared))) {
411 28 0 if (chain->per_plugin && chain->per_plugin[idx]) {
3 25 if (chain->per_plugin && chain->per_plugin[idx]) {
414 4 3 while ((he = hv_iternext(pp))) {
446 22 11 if (chain.shared == NULL) {
450 0 22 if (!p->read_fn) {
464 1 21 if (ctx.cancel) return NULL;
472 20 9 for (i = 0; i < chain.count; i++) {
478 0 20 if (!p->read_fn) {
479 0 0 if (we_own) SvREFCNT_dec(current);
498 18 1 if (ctx.cancel || !next) {
0 18 if (ctx.cancel || !next) {
499 1 0 if (we_own) SvREFCNT_dec(current);
504 18 0 if (next != current) {
505 7 11 if (we_own) SvREFCNT_dec(current);
536 8 6 if (chain.shared == NULL) {
540 1 7 if (!p->write_fn) {
554 1 6 if (ctx.cancel) return NULL;
561 8 5 for (i = chain.count - 1; i >= 0; i--) {
567 0 8 if (!p->write_fn) {
568 0 0 if (we_own) SvREFCNT_dec(current);
587 7 1 if (ctx.cancel || !next) {
0 7 if (ctx.cancel || !next) {
588 1 0 if (we_own) SvREFCNT_dec(current);
593 7 0 if (next != current) {
594 1 6 if (we_own) SvREFCNT_dec(current);
613 0 0 if (!p->record_fn)
626 0 0 if (ctx.cancel) return NULL;
640 1 0 if (!p->stream_fn)
656 0 0 if (fd < 0) return NULL;
667 0 0 while ((n = read(fd, buf, sizeof(buf))) > 0) {
668 0 0 if (p->stream_fn(aTHX_ &ctx, buf, (size_t)n, 0) || ctx.cancel) {
0 0 if (p->stream_fn(aTHX_ &ctx, buf, (size_t)n, 0) || ctx.cancel) {
673 0 0 if (!cancelled) {
678 0 0 return (cancelled || ctx.cancel) ? NULL : &PL_sv_yes;
0 0 return (cancelled || ctx.cancel) ? NULL : &PL_sv_yes;
702 335 51 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
148 187 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
707 32 206 if (stat(path, st) < 0) {
714 206 0 if (len < STAT_CACHE_PATH_MAX) {
738 1 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
750 1 8 if (cached_stat(path, &st) < 0) return 0;
752 8 0 if (g_stat_cache.uid == 0) return 1; /* root can read anything */
754 0 0 if (st.st_uid == g_stat_cache.uid) {
756 0 0 } else if (st.st_gid == g_stat_cache.gid) {
771 1 8 if (cached_stat(path, &st) < 0) return 0;
773 8 0 if (g_stat_cache.uid == 0) return 1; /* root can write anything */
775 0 0 if (st.st_uid == g_stat_cache.uid) {
777 0 0 } else if (st.st_gid == g_stat_cache.gid) {
800 0 8 if (cached_stat(path, &st) < 0) return 0;
802 8 0 if (g_stat_cache.uid == 0) return 1; /* root can execute anything */
804 0 0 if (st.st_uid == g_stat_cache.uid) {
806 0 0 } else if (st.st_gid == g_stat_cache.gid) {
908 0 76 if (fd < 0) {
914 76 0 if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) {
0 76 if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) {
922 1 75 if (st.st_size == 0) {
940 0 75 if (st.st_size >= MMAP_SLURP_THRESHOLD) {
942 0 0 if (map != MAP_FAILED) {
961 75 0 if (n == st.st_size) {
972 0 0 if (n < 0) {
973 0 0 if (errno == EINTR) {
985 0 0 while (total < st.st_size) {
987 0 0 if (n < 0) {
988 0 0 if (errno == EINTR) continue;
995 0 0 if (n == 0) break;
1014 86 0 PUSHs(file_spew_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no);
1024 140 7 PUSHs(file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no);
1044 17 12 PUSHs(file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no);
1054 10 14 PUSHs(file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no);
1067 0 6 if (content == &PL_sv_undef) {
1084 1 1 PUSHs(file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no);
1094 1 0 if (SvOK(path_sv)) {
1113 4 0 PUSHs(file_mkdir_internal(path, 0755) ? &PL_sv_yes : &PL_sv_no);
1123 1 0 PUSHs(file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no);
1133 1 0 PUSHs(file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no);
1213 2 4 PUSHs(file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no);
1223 7 0 PUSHs(file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no);
1233 6 0 PUSHs(file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no);
1243 8 0 PUSHs(file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no);
1277 1 0 PUSHs(file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no);
1289 0 0 PUSHs(file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no);
1301 0 0 PUSHs(file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no);
1312 2 0 PUSHs(file_append_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no);
1323 0 0 PUSHs(file_atomic_spew_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no);
1337 265 0 OP *o = OpSIBLING(pushop);
1339 684 265 while (o) {
1341 419 265 o = OpSIBLING(o);
1358 189 0 if (!OpHAS_SIBLING(pushop)) {
1362 20 169 if (file_count_call_args(pushop) != 1) return entersubop;
1365 169 0 argop = OpSIBLING(pushop);
1366 0 169 if (!argop) return entersubop;
1368 169 0 cvop = OpSIBLING(argop);
1369 0 169 if (!cvop) return entersubop;
1400 76 0 if (!OpHAS_SIBLING(pushop)) {
1404 15 61 if (file_count_call_args(pushop) != 2) return entersubop;
1407 61 0 pathop = OpSIBLING(pushop);
1408 0 61 if (!pathop) return entersubop;
1410 61 0 dataop = OpSIBLING(pathop);
1411 0 61 if (!dataop) return entersubop;
1413 61 0 cvop = OpSIBLING(dataop);
1414 0 61 if (!cvop) return entersubop;
1527 0 28 if (file_initialized) return;
1530 0 28 Newxz(g_mmaps, g_mmaps_size, MmapEntry);
1532 0 28 Newxz(g_free_mmaps, g_free_mmaps_size, IV);
1535 0 28 Newxz(g_iters, g_iters_size, LineIterEntry);
1537 0 28 Newxz(g_free_iters, g_free_iters_size, IV);
1569 3 70 if (fd < 0 && errno == EPERM) {
0 3 if (fd < 0 && errno == EPERM) {
1573 3 70 if (fd < 0) {
1577 0 70 if (fstat(fd, &st) < 0) {
1586 70 0 if (S_ISREG(st.st_mode) && st.st_size > 0) {
65 5 if (S_ISREG(st.st_mode) && st.st_size > 0) {
1589 0 65 if (st.st_size >= MMAP_SLURP_THRESHOLD) {
1591 0 0 if (map != MAP_FAILED) {
1616 65 65 while (total < st.st_size) {
1618 0 65 if (n < 0) {
1619 0 0 if (errno == EINTR) continue;
1624 0 65 if (n == 0) break;
1638 0 5 if (total >= (ssize_t)capacity - 1) {
1640 0 0 SvGROW(result, capacity);
0 0 SvGROW(result, capacity);
1645 0 5 if (n < 0) {
1646 0 0 if (errno == EINTR) continue;
1651 5 0 if (n == 0) break;
1688 0 2 if (fd < 0 && errno == EPERM) {
0 0 if (fd < 0 && errno == EPERM) {
1692 0 2 if (fd < 0) {
1696 0 2 if (fstat(fd, &st) < 0) {
1704 2 0 if (S_ISREG(st.st_mode) && st.st_size > 0) {
2 0 if (S_ISREG(st.st_mode) && st.st_size > 0) {
1707 0 2 if (st.st_size >= MMAP_SLURP_THRESHOLD) {
1709 0 0 if (map != MAP_FAILED) {
1731 2 2 while (total < st.st_size) {
1733 0 2 if (n < 0) {
1734 0 0 if (errno == EINTR) continue;
1739 0 2 if (n == 0) break;
1752 0 0 if (total >= (ssize_t)capacity - 1) {
1754 0 0 SvGROW(result, capacity);
0 0 SvGROW(result, capacity);
1759 0 0 if (n < 0) {
1760 0 0 if (errno == EINTR) continue;
1765 0 0 if (n == 0) break;
1801 0 177 if (UNLIKELY(fd < 0)) {
1802 0 0 if (free_write_data) SvREFCNT_dec(write_data);
1808 4 173 if (len >= 65536) {
1815 177 0 if (LIKELY(n == (ssize_t)len)) {
1817 0 177 if (free_write_data) SvREFCNT_dec(write_data);
1819 62 115 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2 60 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1826 0 0 if (n < 0) {
1827 0 0 if (errno != EINTR) {
1829 0 0 if (free_write_data) SvREFCNT_dec(write_data);
1838 0 0 while ((size_t)written < len) {
1840 0 0 if (n < 0) {
1841 0 0 if (errno == EINTR) continue;
1843 0 0 if (free_write_data) SvREFCNT_dec(write_data);
1851 0 0 if (free_write_data) SvREFCNT_dec(write_data);
1853 0 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
0 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1877 0 7 if (UNLIKELY(fd < 0)) {
1883 7 0 if (LIKELY(n == (ssize_t)len)) {
1886 4 3 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1 3 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1893 0 0 if (n < 0) {
1894 0 0 if (errno != EINTR) {
1904 0 0 while ((size_t)written < len) {
1906 0 0 if (n < 0) {
1907 0 0 if (errno == EINTR) continue;
1917 0 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
0 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1928 0 4 if (needed >= g_mmaps_size) {
1929 0 0 IV new_size = g_mmaps_size ? g_mmaps_size * 2 : 16;
1931 0 0 while (new_size <= needed) new_size *= 2;
1932 0 0 Renew(g_mmaps, new_size, MmapEntry);
1933 0 0 for (i = g_mmaps_size; i < new_size; i++) {
1951 10 4 if (g_free_mmaps_count > 0) {
1964 14 0 if (idx < 0 || idx >= g_mmaps_count) return;
0 14 if (idx < 0 || idx >= g_mmaps_count) return;
1980 14 0 if (entry->addr && entry->addr != MAP_FAILED) {
14 0 if (entry->addr && entry->addr != MAP_FAILED) {
1983 14 0 if (entry->fd >= 0) {
1992 0 14 if (g_free_mmaps_count >= g_free_mmaps_size) {
1994 0 0 Renew(g_free_mmaps, g_free_mmaps_size, IV);
2054 1 15 int flags = writable ? O_RDWR : O_RDONLY;
2055 1 15 int prot = writable ? (PROT_READ | PROT_WRITE) : PROT_READ;
2058 1 15 if (fd < 0) {
2062 0 15 if (fstat(fd, &st) < 0) {
2067 1 14 if (st.st_size == 0) {
2076 0 14 if (addr == MAP_FAILED) {
2095 14 0 if (idx < 0 || idx >= g_mmaps_count) {
0 14 if (idx < 0 || idx >= g_mmaps_count) {
2105 14 0 if (!entry->addr || entry->addr == MAP_FAILED) {
0 14 if (!entry->addr || entry->addr == MAP_FAILED) {
2112 14 0 SvUPGRADE(sv, SVt_PV);
2124 14 2 if (idx < 0 || idx >= g_mmaps_count) return;
0 14 if (idx < 0 || idx >= g_mmaps_count) return;
2128 14 0 if (entry->refcount <= 0) {
2137 2 0 if (idx < 0 || idx >= g_mmaps_count) return;
0 2 if (idx < 0 || idx >= g_mmaps_count) return;
2145 2 0 if (entry->addr && entry->addr != MAP_FAILED) {
2 0 if (entry->addr && entry->addr != MAP_FAILED) {
2156 0 12 if (needed >= g_iters_size) {
2157 0 0 IV new_size = g_iters_size ? g_iters_size * 2 : 16;
2159 0 0 while (new_size <= needed) new_size *= 2;
2160 0 0 Renew(g_iters, new_size, LineIterEntry);
2161 0 0 for (i = g_iters_size; i < new_size; i++) {
2178 61 12 if (g_free_iters_count > 0) {
2191 72 0 if (idx < 0 || idx >= g_iters_count) return;
0 72 if (idx < 0 || idx >= g_iters_count) return;
2194 70 2 if (entry->fd >= 0) {
2197 70 2 if (entry->buffer) {
2200 70 2 if (entry->path) {
2203 2 70 if (entry->records) {
2218 0 72 if (g_free_iters_count >= g_free_iters_size) {
2220 0 0 Renew(g_free_iters, g_free_iters_size, IV);
2237 4 71 if (fd < 0) {
2274 1395 0 if (idx < 0 || idx >= g_iters_count) {
0 1395 if (idx < 0 || idx >= g_iters_count) {
2279 0 1395 if (entry->fd < 0) {
2285 1365 109 if (entry->buf_pos < entry->buf_len) {
2289 1353 12 if (newline) {
2298 42 79 if (entry->eof) {
2300 6 36 if (entry->buf_pos < entry->buf_len) {
2310 33 46 if (entry->buf_pos > 0) {
2312 6 27 if (remaining > 0) {
2320 0 79 if (entry->buf_len >= entry->buf_size - 1) {
2328 0 79 if (n < 0) {
2329 0 0 if (errno == EINTR) continue;
2332 36 43 if (n == 0) {
2344 0 0 if (idx < 0 || idx >= g_iters_count) {
0 0 if (idx < 0 || idx >= g_iters_count) {
2349 0 0 return entry->eof && entry->buf_pos >= entry->buf_len;
0 0 return entry->eof && entry->buf_pos >= entry->buf_len;
2354 72 1 if (idx < 0 || idx >= g_iters_count) return;
0 72 if (idx < 0 || idx >= g_iters_count) return;
2358 72 0 if (entry->refcount <= 0) {
2370 2 63 if (cached_stat(path, &st) < 0) {
2385 2 31 if (cached_stat(path, &st) < 0) return 0;
2392 7 31 if (cached_stat(path, &st) < 0) return 0;
2409 1 30 if (cached_stat(path, &st) < 0) {
2418 1 7 if (cached_stat(path, &st) < 0) {
2427 1 7 if (cached_stat(path, &st) < 0) {
2436 1 4 if (cached_stat(path, &st) < 0) {
2447 1 3 if (cached_stat(path, &st) < 0) {
2457 2 1 hv_store(result, "is_file", 7, S_ISREG(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0);
2458 1 2 hv_store(result, "is_dir", 6, S_ISDIR(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0);
2477 1 9 if (lstat(path, &st) < 0) return 0;
2512 2 4 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2537 1 3 if (fd_src < 0) return 0;
2539 3 0 if (fstat(fd_src, &st) < 0 || !S_ISREG(st.st_mode)) {
0 3 if (fstat(fd_src, &st) < 0 || !S_ISREG(st.st_mode)) {
2545 0 3 if (fd_dst < 0) {
2551 2 3 while (offset < st.st_size) {
2553 0 2 if (sent < 0) {
2554 0 0 if (errno == EINTR) continue;
2555 0 0 if (errno == EINVAL || errno == ENOSYS) {
0 0 if (errno == EINVAL || errno == ENOSYS) {
2567 0 0 if (n_read < 0) {
2568 0 0 if (errno == EINTR) continue;
2571 0 0 if (n_read == 0) { result = 1; break; }
2574 0 0 while (written < n_read) {
2576 0 0 if (n_written < 0) {
2577 0 0 if (errno == EINTR) continue;
2587 0 0 if (result && g_stat_cache.valid && strcmp(dst, g_stat_cache.path) == 0) {
0 0 if (result && g_stat_cache.valid && strcmp(dst, g_stat_cache.path) == 0) {
0 0 if (result && g_stat_cache.valid && strcmp(dst, g_stat_cache.path) == 0) {
2596 0 2 if (sent == 0) break;
2602 1 2 if (g_stat_cache.valid && strcmp(dst, g_stat_cache.path) == 0) {
0 1 if (g_stat_cache.valid && strcmp(dst, g_stat_cache.path) == 0) {
2673 2 1 if (rename(src, dst) == 0) {
2677 0 1 else if (errno == EXDEV) {
2678 0 0 if (file_copy_internal(aTHX_ src, dst)) {
2688 1 1 if (g_stat_cache.valid) {
2689 1 0 if (strcmp(src, g_stat_cache.path) == 0 || strcmp(dst, g_stat_cache.path) == 0) {
0 1 if (strcmp(src, g_stat_cache.path) == 0 || strcmp(dst, g_stat_cache.path) == 0) {
2719 1 2 if (utime(path, NULL) == 0) {
2724 0 2 if (fd < 0) {
2732 2 1 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1 1 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2747 1 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
0 1 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2763 6 12 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
1 5 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2778 2 7 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2 0 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
2822 2 5 if (!dir) return result;
2824 27 5 while ((entry = readdir(dir)) != NULL) {
2826 22 5 if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
17 5 if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) {
2845 2 81 if (len == 0) return newSVpvs("");
2848 85 3 while (len > 0 && (path[len-1] == '/' || path[len-1] == '\\')) {
7 78 while (len > 0 && (path[len-1] == '/' || path[len-1] == '\\')) {
0 78 while (len > 0 && (path[len-1] == '/' || path[len-1] == '\\')) {
2851 3 78 if (len == 0) return newSVpvs("");
2855 732 3 while (p > path && *p != '/' && *p != '\\') {
657 75 while (p > path && *p != '/' && *p != '\\') {
657 0 while (p > path && *p != '/' && *p != '\\') {
2858 3 75 if (*p == '/' || *p == '\\') p++;
0 3 if (*p == '/' || *p == '\\') p++;
2867 1 19 if (len == 0) return newSVpvs(".");
2871 19 2 while (end > path && (*end == '/' || *end == '\\')) {
2 17 while (end > path && (*end == '/' || *end == '\\')) {
0 17 while (end > path && (*end == '/' || *end == '\\')) {
2876 131 6 while (end > path && *end != '/' && *end != '\\') {
118 13 while (end > path && *end != '/' && *end != '\\') {
118 0 while (end > path && *end != '/' && *end != '\\') {
2880 6 13 if (end == path) {
2881 2 4 if (*end == '/' || *end == '\\') {
0 2 if (*end == '/' || *end == '\\') {
2888 14 0 while (end > path && (*(end-1) == '/' || *(end-1) == '\\')) {
1 13 while (end > path && (*(end-1) == '/' || *(end-1) == '\\')) {
0 13 while (end > path && (*(end-1) == '/' || *(end-1) == '\\')) {
2900 1 48 if (len == 0) return newSVpvs("");
2904 440 12 while (basename > path && *basename != '/' && *basename != '\\') {
404 36 while (basename > path && *basename != '/' && *basename != '\\') {
404 0 while (basename > path && *basename != '/' && *basename != '\\') {
2907 12 36 if (*basename == '/' || *basename == '\\') basename++;
0 12 if (*basename == '/' || *basename == '\\') basename++;
2911 44 4 if (!dot || dot == basename) return newSVpvs("");
2 42 if (!dot || dot == basename) return newSVpvs("");
2924 0 12 if (len == 0) return newSVpvs("");
2927 28 12 for (i = 0; i < len; i++) {
2929 28 0 if (sv && SvPOK(*sv)) {
28 0 if (sv && SvPOK(*sv)) {
2940 28 12 for (i = 0; i < len; i++) {
2942 28 0 if (sv && SvPOK(*sv)) {
28 0 if (sv && SvPOK(*sv)) {
2946 1 27 if (part_len == 0) continue;
2949 29 0 while (part_len > 0 && (*part == '/' || *part == '\\')) {
9 20 while (part_len > 0 && (*part == '/' || *part == '\\')) {
0 20 while (part_len > 0 && (*part == '/' || *part == '\\')) {
2950 9 0 if (!need_sep && p == buf) break; /* Keep root slash */
7 2 if (!need_sep && p == buf) break; /* Keep root slash */
2955 12 15 if (need_sep && part_len > 0) {
12 0 if (need_sep && part_len > 0) {
2963 27 0 if (part_len > 0) {
2968 24 3 need_sep = (*(p-1) != '/' && *(p-1) != '\\');
24 0 need_sep = (*(p-1) != '/' && *(p-1) != '\\');
2988 1 5 if (n <= 0) return result;
2991 1 4 if (idx < 0) return result;
2993 20 2 while (count < n && (line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
18 2 while (count < n && (line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
3009 1 5 if (n <= 0) return result;
3012 1 4 if (idx < 0) return result;
3018 43 4 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
3019 25 18 if (av_len(buffer) + 1 >= n) {
3030 18 4 for (i = 0; i < buf_len; i++) {
3032 18 0 if (sv) {
3057 7 2 if (count <= 0 || from < 1) return result;
2 5 if (count <= 0 || from < 1) return result;
3060 0 5 if (idx < 0) return result;
3063 56 4 for (i = 0; i < from - 1; i++) {
3065 1 55 if (line == &PL_sv_undef) {
3074 16 3 for (i = 0; i < count; i++) {
3076 1 15 if (line == &PL_sv_undef) break;
3109 0 17 if (fd < 0) {
3113 16 17 while ((size_t)written < len) {
3115 0 16 if (n < 0) {
3116 0 0 if (errno == EINTR) continue;
3135 0 17 if (rename(temp_path, path) != 0) {
3141 10 7 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
0 10 if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) {
3160 14 2 while (start < end) {
3162 10 4 if (p) {
3166 4 0 if (start < end) {
3185 0 46 if (items < 1)
3191 17 29 if (items > 1) {
3195 2 11 if (!out) {
3200 11 0 if (out != bytes) {
3214 0 2 if (items != 1) croak("Usage: file::slurp_raw(path)");
3227 0 94 if (items < 2)
3233 9 85 if (items > 2) {
3237 2 5 if (!bytes_to_write) {
3244 90 0 ST(0) = file_spew_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
3254 0 5 if (items < 2)
3260 3 2 if (items > 2) {
3264 0 3 if (!bytes_to_write) {
3271 5 0 ST(0) = file_append_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
3280 0 11 if (items != 1) croak("Usage: file::size(path)");
3293 0 4 if (items != 1) croak("Usage: file::mtime(path)");
3305 0 21 if (items != 1) croak("Usage: file::exists(path)");
3308 14 7 ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no;
3316 0 4 if (items != 1) croak("Usage: file::is_file(path)");
3319 3 1 ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no;
3327 0 7 if (items != 1) croak("Usage: file::is_dir(path)");
3330 4 3 ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no;
3338 0 2 if (items != 1) croak("Usage: file::is_readable(path)");
3341 1 1 ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no;
3349 0 3 if (items != 1) croak("Usage: file::is_writable(path)");
3352 2 1 ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no;
3372 0 9 if (items < 1)
3381 2 7 if (items > 1) {
3386 0 2 if (!out) {
3391 2 0 if (out != bytes) SvREFCNT_dec(bytes);
3392 1 1 if (SvROK(out) && SvTYPE(SvRV(out)) == SVt_PVAV) {
1 0 if (SvROK(out) && SvTYPE(SvRV(out)) == SVt_PVAV) {
3405 3 0 while (cursor < bend) {
3407 2 1 if (nl) {
3411 1 0 if (cursor < bend)
3423 1 6 if (UNLIKELY(fd < 0)) {
3429 6 0 if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) {
1 5 if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) {
3440 5 5 while ((size_t)total_read < file_size) {
3442 0 5 if (UNLIKELY(n < 0)) {
3443 0 0 if (errno == EINTR) continue;
3446 0 5 if (n == 0) break;
3451 0 5 if (UNLIKELY(total_read == 0)) {
3466 15 0 while (p < end) {
3468 10 5 if (LIKELY(p != NULL)) {
3474 5 0 if (line_start < end) {
3494 16 0 if (items < 1 || items > 2) croak("Usage: file::mmap_open(path, [writable])");
0 16 if (items < 1 || items > 2) croak("Usage: file::mmap_open(path, [writable])");
3497 1 15 writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0;
1 0 writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0;
3500 2 14 if (idx < 0) {
3519 0 14 if (items != 1) croak("Usage: $mmap->data");
3521 14 0 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
0 14 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
3527 14 0 idx = idx_sv ? SvIV(*idx_sv) : -1;
3539 0 2 if (items != 1) croak("Usage: $mmap->sync");
3541 2 0 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
0 2 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
3547 2 0 idx = idx_sv ? SvIV(*idx_sv) : -1;
3559 0 16 if (items != 1) croak("Usage: $mmap->close");
3561 16 0 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
0 16 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
3567 16 0 idx = idx_sv ? SvIV(*idx_sv) : -1;
3582 0 14 if (PL_dirty) XSRETURN_EMPTY;
3584 14 0 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
0 14 if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) {
3590 14 0 idx = idx_sv ? SvIV(*idx_sv) : -1;
3592 0 14 if (idx >= 0) {
3604 0 24 if (items < 1)
3614 5 19 if (items > 1) {
3625 0 3 if (!out) {
3630 3 0 if (out != bytes) SvREFCNT_dec(bytes);
3631 2 1 if (!SvROK(out) || SvTYPE(SvRV(out)) != SVt_PVAV) {
0 2 if (!SvROK(out) || SvTYPE(SvRV(out)) != SVt_PVAV) {
3660 1 18 if (idx < 0) {
3682 0 161 if (items != 1) croak("Usage: $iter->next");
3685 0 161 if (UNLIKELY(!SvROK(rv))) {
3692 161 0 if (UNLIKELY(idx < 0 || idx >= g_iters_count)) {
0 161 if (UNLIKELY(idx < 0 || idx >= g_iters_count)) {
3700 4 157 if (entry->records) {
3702 0 4 if (entry->records_idx >= total) {
3707 4 0 ST(0) = (rp && *rp) ? sv_2mortal(newSVsv(*rp)) : &PL_sv_undef;
4 0 ST(0) = (rp && *rp) ? sv_2mortal(newSVsv(*rp)) : &PL_sv_undef;
3711 0 157 if (UNLIKELY(entry->fd < 0)) {
3719 166 25 if (entry->buf_pos < entry->buf_len) {
3723 142 24 if (newline) {
3733 15 34 if (entry->eof) {
3735 11 4 if (entry->buf_pos < entry->buf_len) {
3747 13 21 if (entry->buf_pos > 0) {
3749 10 3 if (remaining > 0) {
3757 1 33 if (entry->buf_len >= entry->buf_size - 1) {
3765 0 34 if (n < 0) {
3766 0 0 if (errno == EINTR) continue;
3770 15 19 if (n == 0) {
3784 0 131 if (items != 1) croak("Usage: $iter->eof");
3787 0 131 if (UNLIKELY(!SvROK(rv))) {
3794 131 0 if (UNLIKELY(idx < 0 || idx >= g_iters_count)) {
0 131 if (UNLIKELY(idx < 0 || idx >= g_iters_count)) {
3800 4 127 if (entry->records) {
3802 1 3 ? &PL_sv_yes : &PL_sv_no;
3805 9 118 ST(0) = (entry->eof && entry->buf_pos >= entry->buf_len) ? &PL_sv_yes : &PL_sv_no;
9 0 ST(0) = (entry->eof && entry->buf_pos >= entry->buf_len) ? &PL_sv_yes : &PL_sv_no;
3814 0 19 if (items != 1) croak("Usage: $iter->close");
3817 0 19 if (UNLIKELY(!SvROK(rv))) {
3836 0 20 if (PL_dirty) XSRETURN_EMPTY;
3839 0 20 if (UNLIKELY(!SvROK(rv))) {
3845 2 18 if (idx >= 0) {
3873 64 16 for (i = 0; i < len; i++) {
3874 43 21 if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') {
43 0 if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') {
43 0 if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') {
43 0 if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') {
3897 32 8 while (len > 0 && (*s == ' ' || *s == '\t')) {
11 21 while (len > 0 && (*s == ' ' || *s == '\t')) {
0 21 while (len > 0 && (*s == ' ' || *s == '\t')) {
3901 21 8 return len > 0 && *s == '#';
6 15 return len > 0 && *s == '#';
3915 28 0 if (PL_dirty) {
3928 33 28 if (g_file_callback_registry) return;
3983 0 23 if (!g_file_callback_registry) return NULL;
3985 19 4 if (svp && SvIOK(*svp)) {
19 0 if (svp && SvIOK(*svp)) {
4012 1 13 if (items < 2)
4018 12 1 if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) {
0 12 if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) {
4025 4 8 if (items > 2) {
4034 1 7 if (idx < 0) {
4040 7 0 old_defsv = DEFSV;
4042 7 0 DEFSV = line_sv;
4045 0 7 PUSH_MULTICALL(block_cv);
4050 1027 12 if (entry->buf_pos < entry->buf_len) {
4054 1021 6 if (newline) {
4068 6 12 if (entry->eof) {
4070 3 3 if (entry->buf_pos < entry->buf_len) {
4084 5 7 if (entry->buf_pos > 0) {
4086 3 2 if (remaining > 0) {
4094 0 12 if (entry->buf_len >= entry->buf_size - 1) {
4102 0 12 if (n < 0) {
4103 0 0 if (errno == EINTR) continue;
4106 6 6 if (n == 0) {
4114 6 0 POP_MULTICALL;
4117 6 0 DEFSV = old_defsv;
4131 0 13 if (!out) {
4135 13 0 if (out != bytes) SvREFCNT_dec(bytes);
4136 12 1 if (!SvROK(out) || SvTYPE(SvRV(out)) != SVt_PVAV) {
0 12 if (!SvROK(out) || SvTYPE(SvRV(out)) != SVt_PVAV) {
4152 0 21 PUSHMARK(SP);
4153 0 21 XPUSHs(record);
4157 21 0 if (n > 0) {
4176 0 25 if (items < 2)
4183 4 21 if (items > 2) {
4190 3 1 if (!SvROK(predicate) || SvTYPE(SvRV(predicate)) != SVt_PVCV)
0 3 if (!SvROK(predicate) || SvTYPE(SvRV(predicate)) != SVt_PVCV)
4197 0 2 if (!records) {
4204 8 2 for (i = 0; i < n; i++) {
4206 8 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
8 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
4207 7 1 if (file_call_predicate_cv(aTHX_ (CV *)SvRV(predicate), rec))
4217 5 16 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
5 0 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
4222 1 15 if (!fcb) {
4228 0 20 if (idx < 0) {
4234 15 5 if (fcb && fcb->predicate) {
12 3 if (fcb && fcb->predicate) {
4235 91 12 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4236 49 42 if (fcb->predicate(aTHX_ line)) {
4249 3 5 SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv;
4250 1057 8 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4255 0 1057 PUSHMARK(SP);
4256 0 1057 XPUSHs(line);
4260 1057 0 if (count > 0) {
4265 26 1031 if (matches) {
4289 0 9 if (items < 1)
4300 2 7 if (items > 2) {
4308 1 1 if (has_pred && (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVCV))
1 0 if (has_pred && (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVCV))
0 1 if (has_pred && (!SvROK(ST(1)) || SvTYPE(SvRV(ST(1))) != SVt_PVCV))
4315 0 2 if (!records) {
4320 1 1 if (!has_pred) {
4323 5 1 for (i = 0; i < n; i++) {
4325 5 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
5 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
4326 4 1 if (file_call_predicate_cv(aTHX_ (CV *)SvRV(ST(1)), rec))
4336 4 3 if (items == 1) {
4348 1 3 if (UNLIKELY(fd < 0)) {
4356 2 3 while ((n = read(fd, buffer, FILE_BUFFER_SIZE)) > 0) {
4359 1008 2 while ((p = memchr(p, '\n', end - p)) != NULL) {
4370 2 1 if (total_read > 0 && last_char != '\n') {
1 1 if (total_read > 0 && last_char != '\n') {
4381 2 1 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
2 0 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
4386 0 1 if (!fcb) {
4392 0 3 if (idx < 0) {
4398 1 2 if (fcb && fcb->predicate) {
1 0 if (fcb && fcb->predicate) {
4399 9 1 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4400 7 2 if (fcb->predicate(aTHX_ line)) {
4412 0 2 SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv;
4413 13 2 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4418 0 13 PUSHMARK(SP);
4419 0 13 XPUSHs(line);
4423 13 0 if (n > 0) {
4428 10 3 if (matches) {
4450 0 8 if (items < 2)
4456 2 6 if (items > 2) {
4462 2 0 if (!SvROK(predicate) || SvTYPE(SvRV(predicate)) != SVt_PVCV)
0 2 if (!SvROK(predicate) || SvTYPE(SvRV(predicate)) != SVt_PVCV)
4469 0 2 if (!records) XSRETURN_UNDEF;
4472 8 1 for (i = 0; i < n; i++) {
4474 8 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
8 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
4475 1 7 if (file_call_predicate_cv(aTHX_ (CV *)SvRV(predicate), rec)) {
4487 5 1 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
5 0 if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) {
4492 0 1 if (!fcb) {
4498 0 6 if (idx < 0) {
4503 1 5 if (fcb && fcb->predicate) {
1 0 if (fcb && fcb->predicate) {
4504 6 0 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4505 1 5 if (fcb->predicate(aTHX_ line)) {
4518 0 5 SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv;
4519 25 1 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4524 0 25 PUSHMARK(SP);
4525 0 25 XPUSHs(line);
4529 25 0 if (n > 0) {
4534 4 21 if (matches) {
4555 0 5 if (items < 2)
4562 5 0 if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) {
0 5 if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) {
4566 1 4 if (items > 2) {
4577 0 1 if (!records) {
4584 5 1 for (i = 0; i < n; i++) {
4586 5 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
5 0 SV *rec = (rp && *rp) ? *rp : &PL_sv_undef;
4590 0 5 PUSHMARK(SP);
4591 0 5 XPUSHs(rec);
4595 5 0 if (rn > 0) {
4607 0 4 if (idx < 0) {
4614 27 4 while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) {
4618 0 27 PUSHMARK(SP);
4619 0 27 XPUSHs(sv_2mortal(line));
4623 27 0 if (count > 0) {
4671 0 13 if (!b) return;
4672 10 3 if (b->read_cv) SvREFCNT_dec(b->read_cv);
4673 1 12 if (b->write_cv) SvREFCNT_dec(b->write_cv);
4674 1 12 if (b->record_cv) SvREFCNT_dec(b->record_cv);
4675 13 0 if (b->name) Safefree(b->name);
4687 0 42 PUSHMARK(SP);
4688 0 42 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
42 0 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
4689 0 42 XPUSHs(sv_2mortal(newSVsv(ctx->data)));
4690 0 42 XPUSHs(sv_2mortal(newRV_inc((SV *)ctx->options)));
4696 42 0 if (SvTRUE(ERRSV)) {
1 41 if (SvTRUE(ERRSV)) {
4697 1 0 SV *err = newSVsv(ERRSV);
4698 1 0 FREETMPS;
4702 41 0 if (count > 0) {
4704 39 2 if (SvOK(ret)) {
4715 41 0 FREETMPS;
4728 0 15 PUSHMARK(SP);
4729 0 15 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
15 0 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
4730 0 15 XPUSHs(sv_2mortal(newSVsv(ctx->data)));
4731 0 15 XPUSHs(sv_2mortal(newRV_inc((SV *)ctx->options)));
4737 15 0 if (SvTRUE(ERRSV)) {
0 15 if (SvTRUE(ERRSV)) {
4738 0 0 SV *err = newSVsv(ERRSV);
4739 0 0 FREETMPS;
4743 15 0 if (count > 0) {
4745 13 2 if (SvOK(ret)) {
4756 15 0 FREETMPS;
4769 0 0 PUSHMARK(SP);
4770 0 0 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
0 0 XPUSHs(sv_2mortal(newSVpv(ctx->path ? ctx->path : "", 0)));
4771 0 0 XPUSHs(sv_2mortal(newSVsv(record)));
4772 0 0 XPUSHs(sv_2mortal(newRV_inc((SV *)ctx->options)));
4778 0 0 if (SvTRUE(ERRSV)) {
0 0 if (SvTRUE(ERRSV)) {
4779 0 0 SV *err = newSVsv(ERRSV);
4780 0 0 FREETMPS;
4784 0 0 if (count > 0) {
4786 0 0 if (SvOK(ret)) {
4795 0 0 FREETMPS;
4823 0 0 if (!svp || !*svp || !SvOK(*svp))
0 0 if (!svp || !*svp || !SvOK(*svp))
0 0 if (!svp || !*svp || !SvOK(*svp))
4827 0 0 if (!g_file_callback_registry)
4831 0 0 if (!svp || !*svp)
0 0 if (!svp || !*svp)
4835 0 0 if (cb->predicate) {
4836 0 0 return cb->predicate(aTHX_ record) ? record : &PL_sv_undef;
4837 0 0 } else if (cb->perl_callback) {
4838 0 0 SV *old_defsv = DEFSV;
4844 0 0 DEFSV = record;
4847 0 0 PUSHMARK(SP);
4851 0 0 if (count > 0) {
4856 0 0 FREETMPS;
4858 0 0 DEFSV = old_defsv;
4859 0 0 return matched ? record : &PL_sv_undef;
4886 1 7 if (items != 2)
4892 5 2 if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV)
0 5 if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV)
4898 2 3 if (existing) {
4899 2 0 if (existing->perl_callback) SvREFCNT_dec(existing->perl_callback);
4921 3 0 if (g_file_callback_registry) {
4923 39 3 while ((he = hv_iternext(g_file_callback_registry))) {
4945 32 1 if (items < 2 || items > 3)
0 32 if (items < 2 || items > 3)
4949 0 32 if (name_len == 0)
4953 31 1 if (!SvROK(spec) || SvTYPE(SvRV(spec)) != SVt_PVHV)
0 31 if (!SvROK(spec) || SvTYPE(SvRV(spec)) != SVt_PVHV)
4957 1 30 if (items == 3) override = SvTRUE(ST(2));
4959 1 30 if (override) (void)file_unregister_plugin(aTHX_ name);
4965 28 3 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
28 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
27 1 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
27 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
4970 8 23 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
8 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
8 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
8 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
4975 1 30 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
1 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
1 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
1 0 if (svp && *svp && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) {
4980 1 30 if (hv_exists(spec_hv, "stream", 6))
4984 3 27 if (!b->plugin.read_fn && !b->plugin.write_fn && !b->plugin.record_fn) {
3 0 if (!b->plugin.read_fn && !b->plugin.write_fn && !b->plugin.record_fn) {
2 1 if (!b->plugin.read_fn && !b->plugin.write_fn && !b->plugin.record_fn) {
4994 1 27 if (rc != 1) {
4996 1 0 if (rc == 0)
5002 12 15 if (!g_perl_plugins) g_perl_plugins = newHV();
5015 0 11 if (items != 1)
5020 11 0 if (g_perl_plugins) {
5022 10 1 if (svp && *svp) {
10 0 if (svp && *svp) {
5030 1 10 if (!removed_perl)
5043 3 0 if (g_file_plugin_registry) {
5045 4 3 while ((he = hv_iternext(g_file_plugin_registry))) {
5060 0 2 if (items != 1) croak("Usage: file::atime(path)");
5069 0 2 if (items != 1) croak("Usage: file::ctime(path)");
5078 0 2 if (items != 1) croak("Usage: file::mode(path)");
5089 0 4 if (items != 1) croak("Usage: File::Raw::stat(path)");
5092 1 3 if (result == NULL) {
5103 0 4 if (items != 1) croak("Usage: file::is_link(path)");
5105 1 3 ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no;
5112 0 0 if (items != 1) croak("Usage: file::is_executable(path)");
5114 0 0 ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no;
5122 0 4 if (items != 1) croak("Usage: file::unlink(path)");
5124 2 2 ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no;
5132 0 3 if (items != 2) croak("Usage: file::copy(src, dst)");
5135 2 1 ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
5143 0 3 if (items != 2) croak("Usage: file::move(src, dst)");
5146 2 1 ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
5153 0 2 if (items != 1) croak("Usage: file::touch(path)");
5155 2 0 ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no;
5161 0 1 if (items > 1) croak("Usage: file::clear_stat_cache() or file::clear_stat_cache(path)");
5163 0 1 if (items == 1 && SvOK(ST(0))) {
0 0 if (items == 1 && SvOK(ST(0))) {
5178 0 1 if (items != 2) croak("Usage: file::chmod(path, mode)");
5181 1 0 ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
5189 12 0 if (items < 1 || items > 2) croak("Usage: file::mkdir(path, [mode])");
0 12 if (items < 1 || items > 2) croak("Usage: file::mkdir(path, [mode])");
5191 0 12 if (items > 1) mode = SvIV(ST(1));
5192 8 4 ST(0) = file_mkdir_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
5199 0 6 if (items != 1) croak("Usage: file::rmdir(path)");
5201 2 4 ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no;
5209 0 5 if (items != 1) croak("Usage: file::readdir(path)");
5220 0 12 if (items != 1) croak("Usage: file::basename(path)");
5229 0 10 if (items != 1) croak("Usage: file::dirname(path)");
5238 0 13 if (items != 1) croak("Usage: file::extname(path)");
5249 0 11 if (items < 1) croak("Usage: file::join(part1, part2, ...)");
5252 26 11 for (i = 0; i < items; i++) {
5270 0 1 if (items != 1) croak("Usage: file_mkpath(path)");
5272 0 1 if (path_len >= sizeof(buf)) croak("Path too long");
5274 35 1 for (i = 0; i <= path_len; i++) {
5275 34 1 if (i == path_len || path[i] == '/' || path[i] == '\\') {
30 4 if (i == path_len || path[i] == '/' || path[i] == '\\') {
0 30 if (i == path_len || path[i] == '/' || path[i] == '\\') {
5276 1 4 if (i == 0) {
5286 0 4 if (i == 2 && buf[1] == ':') continue;
0 0 if (i == 2 && buf[1] == ':') continue;
5288 2 2 if (!file_is_dir_internal(buf)) {
5289 2 0 if (file_mkdir_internal(buf, 0755))
5295 0 1 ST(0) = created || file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no;
0 0 ST(0) = created || file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no;
5304 0 2 if (!file_is_dir_internal(path)) {
5311 1 2 for (i = 0; i < len; i++) {
5313 1 0 if (sv) {
5323 1 0 if (file_is_dir_internal(child)) {
5341 0 1 if (items != 1) croak("Usage: file_rm_rf(path)");
5360 0 8 if (items < 1)
5364 5 3 n_positional = (items % 2 == 0) ? 2 : 1;
5365 5 3 if (n_positional == 2) n = SvIV(ST(1));
5367 2 6 if (items > n_positional) {
5377 0 2 if (!records) {
5384 0 2 if (take < 0) take = 0;
5386 7 2 for (i = 0; i < take; i++) {
5388 7 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
7 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
5407 0 7 if (items < 1)
5411 5 2 n_positional = (items % 2 == 0) ? 2 : 1;
5412 5 2 if (n_positional == 2) n = SvIV(ST(1));
5414 1 6 if (items > n_positional) {
5424 0 1 if (!records) {
5431 0 1 if (take < 0) take = 0;
5434 2 1 for (i = start; i < total; i++) {
5436 2 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
2 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
5459 2 14 if (items < 3)
5469 5 9 if (items > 3) {
5479 0 2 if (!records) {
5484 2 0 if (from < 1 || count <= 0) {
0 2 if (from < 1 || count <= 0) {
5491 0 2 if (start >= total) {
5497 1 1 if (end > total) end = total;
5499 5 2 for (i = start; i < end; i++) {
5501 5 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
5 0 av_push(out, SvREFCNT_inc(rp && *rp ? *rp : &PL_sv_undef));
5520 0 17 if (items < 2)
5526 3 14 if (items > 2) {
5530 0 3 if (!bytes_to_write) {
5537 17 0 ST(0) = file_atomic_spew_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
5550 0 1 if (items < 1)
5556 1 0 if (items > 1) {
5560 0 1 if (!out) {
5565 1 0 if (out != bytes) {
5579 0 1 if (items < 2)
5585 0 1 if (items > 2) {
5589 0 0 if (!out) { ST(0) = &PL_sv_no; XSRETURN(1); }
5592 1 0 ST(0) = file_spew_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
5599 0 0 if (items != 1) croak("Usage: file_exists($path)");
5601 0 0 ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no;
5608 0 0 if (items != 1) croak("Usage: file_size($path)");
5617 0 0 if (items != 1) croak("Usage: file_is_file($path)");
5619 0 0 ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no;
5626 0 0 if (items != 1) croak("Usage: file_is_dir($path)");
5628 0 0 ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no;
5638 0 0 if (items < 1)
5643 0 0 if (items > 1) {
5648 0 0 if (!out) {
5653 0 0 if (out != bytes) SvREFCNT_dec(bytes);
5654 0 0 if (SvROK(out) && SvTYPE(SvRV(out)) == SVt_PVAV) {
0 0 if (SvROK(out) && SvTYPE(SvRV(out)) == SVt_PVAV) {
5665 0 0 if (content == &PL_sv_undef) {
5678 0 0 if (items != 1) croak("Usage: file_unlink($path)");
5680 0 0 ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no;
5687 0 0 if (items != 1) croak("Usage: file_mkdir($path)");
5689 0 0 ST(0) = file_mkdir_internal(path, 0755) ? &PL_sv_yes : &PL_sv_no;
5696 0 0 if (items != 1) croak("Usage: file_rmdir($path)");
5698 0 0 ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no;
5705 0 0 if (items != 1) croak("Usage: file_touch($path)");
5707 0 0 ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no;
5713 0 0 if (items > 1) croak("Usage: file_clear_stat_cache() or file_clear_stat_cache($path)");
5715 0 0 if (items == 1 && SvOK(ST(0))) {
0 0 if (items == 1 && SvOK(ST(0))) {
5729 0 0 if (items != 1) croak("Usage: file_basename($path)");
5738 0 0 if (items != 1) croak("Usage: file_dirname($path)");
5747 0 0 if (items != 1) croak("Usage: file_extname($path)");
5756 0 0 if (items != 1) croak("Usage: file_mtime($path)");
5765 0 0 if (items != 1) croak("Usage: file_atime($path)");
5774 0 0 if (items != 1) croak("Usage: file_ctime($path)");
5783 0 0 if (items != 1) croak("Usage: file_mode($path)");
5792 0 0 if (items != 1) croak("Usage: file_is_link($path)");
5794 0 0 ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no;
5801 0 0 if (items != 1) croak("Usage: file_is_readable($path)");
5803 0 0 ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no;
5810 0 0 if (items != 1) croak("Usage: file_is_writable($path)");
5812 0 0 ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no;
5819 0 0 if (items != 1) croak("Usage: file_is_executable($path)");
5821 0 0 ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no;
5829 0 0 if (items != 1) croak("Usage: file_readdir($path)");
5839 0 0 if (items != 1) croak("Usage: file_slurp_raw($path)");
5849 0 0 if (items != 2) croak("Usage: file_copy($src, $dst)");
5852 0 0 ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
5860 0 0 if (items != 2) croak("Usage: file_move($src, $dst)");
5863 0 0 ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
5871 0 0 if (items != 2) croak("Usage: file_chmod($path, $mode)");
5874 0 0 ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
5883 0 0 if (items < 2)
5889 0 0 if (items > 2) {
5893 0 0 if (!out) { ST(0) = &PL_sv_no; XSRETURN(1); }
5896 0 0 ST(0) = file_append_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
5905 0 0 if (items < 2)
5911 0 0 if (items > 2) {
5915 0 0 if (!out) { ST(0) = &PL_sv_no; XSRETURN(1); }
5918 0 0 ST(0) = file_atomic_spew_internal(aTHX_ path, payload) ? &PL_sv_yes : &PL_sv_no;
5976 20 135 if (e->args == 0) {
5981 105 30 } else if (e->args == 1) {
5990 136 4 for (i = 0; import_funcs[i].name != NULL; i++) {
6002 36 0 pkg = CopSTASHPV(PL_curcop);
36 0 pkg = CopSTASHPV(PL_curcop);
36 0 pkg = CopSTASHPV(PL_curcop);
0 36 pkg = CopSTASHPV(PL_curcop);
0 0 pkg = CopSTASHPV(PL_curcop);
36 0 pkg = CopSTASHPV(PL_curcop);
0 36 pkg = CopSTASHPV(PL_curcop);
6005 26 10 if (items <= 1) {
6010 23 6 for (i = 1; i < items; i++) {
6015 8 15 if ((len == 4 && strEQ(arg, ":all")) ||
6 2 if ((len == 4 && strEQ(arg, ":all")) ||
6016 6 15 (len == 6 && strEQ(arg, "import"))) {
2 4 (len == 6 && strEQ(arg, "import"))) {
6022 357 0 for (j = 0; import_funcs[j].name != NULL; j++) {
6023 19 338 if (strEQ(arg, import_funcs[j].name)) {
6030 0 19 if (import_funcs[j].name == NULL) {
6350 0 28 if (file_register_plugin(aTHX_ &g_predicate_plugin) != 1) {