| line |
true |
false |
branch |
|
145
|
329 |
48 |
if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) { |
|
|
147 |
182 |
if (g_stat_cache.valid && strcmp(path, g_stat_cache.path) == 0) { |
|
150
|
29 |
201 |
if (stat(path, st) < 0) { |
|
157
|
201 |
0 |
if (len < STAT_CACHE_PATH_MAX) { |
|
181
|
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) { |
|
193
|
1 |
8 |
if (cached_stat(path, &st) < 0) return 0; |
|
195
|
8 |
0 |
if (g_stat_cache.uid == 0) return 1; /* root can read anything */ |
|
197
|
0 |
0 |
if (st.st_uid == g_stat_cache.uid) { |
|
199
|
0 |
0 |
} else if (st.st_gid == g_stat_cache.gid) { |
|
214
|
1 |
8 |
if (cached_stat(path, &st) < 0) return 0; |
|
216
|
8 |
0 |
if (g_stat_cache.uid == 0) return 1; /* root can write anything */ |
|
218
|
0 |
0 |
if (st.st_uid == g_stat_cache.uid) { |
|
220
|
0 |
0 |
} else if (st.st_gid == g_stat_cache.gid) { |
|
243
|
0 |
8 |
if (cached_stat(path, &st) < 0) return 0; |
|
245
|
8 |
0 |
if (g_stat_cache.uid == 0) return 1; /* root can execute anything */ |
|
247
|
0 |
0 |
if (st.st_uid == g_stat_cache.uid) { |
|
249
|
0 |
0 |
} else if (st.st_gid == g_stat_cache.gid) { |
|
281
|
0 |
0 |
if (phase == FILE_HOOK_PHASE_READ && g_file_read_hook) return 1; |
|
|
0 |
0 |
if (phase == FILE_HOOK_PHASE_READ && g_file_read_hook) return 1; |
|
282
|
0 |
0 |
if (phase == FILE_HOOK_PHASE_WRITE && g_file_write_hook) return 1; |
|
|
0 |
0 |
if (phase == FILE_HOOK_PHASE_WRITE && g_file_write_hook) return 1; |
|
291
|
0 |
0 |
if (phase > FILE_HOOK_PHASE_CLOSE) return 0; |
|
305
|
0 |
0 |
while (curr && curr->priority <= priority) { |
|
|
0 |
0 |
while (curr && curr->priority <= priority) { |
|
310
|
0 |
0 |
if (prev) { |
|
325
|
0 |
0 |
if (phase > FILE_HOOK_PHASE_CLOSE) return 0; |
|
329
|
0 |
0 |
while (curr) { |
|
330
|
0 |
0 |
if (strcmp(curr->name, name) == 0) { |
|
331
|
0 |
0 |
if (prev) { |
|
336
|
0 |
0 |
if (curr->perl_callback) { |
|
356
|
9 |
5 |
if (phase == FILE_HOOK_PHASE_READ && g_file_read_hook) { |
|
|
2 |
7 |
if (phase == FILE_HOOK_PHASE_READ && g_file_read_hook) { |
|
359
|
5 |
7 |
} else if (phase == FILE_HOOK_PHASE_WRITE && g_file_write_hook) { |
|
|
2 |
3 |
} else if (phase == FILE_HOOK_PHASE_WRITE && g_file_write_hook) { |
|
365
|
4 |
10 |
if (simple_hook) { |
|
373
|
4 |
0 |
if (!result || ctx.cancel) return NULL; |
|
|
0 |
4 |
if (!result || ctx.cancel) return NULL; |
|
377
|
10 |
14 |
for (entry = g_file_hooks[phase]; entry; entry = entry->next) { |
|
384
|
0 |
10 |
if (entry->c_func) { |
|
386
|
10 |
0 |
} else if (entry->perl_callback) { |
|
393
|
0 |
10 |
PUSHMARK(SP); |
|
394
|
0 |
10 |
mXPUSHs(newSVpv(path, 0)); |
|
395
|
0 |
10 |
mXPUSHs(SvREFCNT_inc(result)); |
|
401
|
10 |
0 |
if (count > 0) { |
|
403
|
10 |
0 |
if (SvOK(ret)) { |
|
410
|
10 |
0 |
FREETMPS; |
|
414
|
10 |
0 |
if (!result || ctx.cancel) return NULL; |
|
|
0 |
10 |
if (!result || ctx.cancel) return NULL; |
|
506
|
73 |
2 |
if (g_file_read_hook || g_file_hooks[FILE_HOOK_PHASE_READ]) { |
|
|
7 |
66 |
if (g_file_read_hook || g_file_hooks[FILE_HOOK_PHASE_READ]) { |
|
519
|
0 |
66 |
if (fd < 0) { |
|
525
|
66 |
0 |
if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) { |
|
|
0 |
66 |
if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) { |
|
533
|
1 |
65 |
if (st.st_size == 0) { |
|
551
|
0 |
65 |
if (st.st_size >= MMAP_SLURP_THRESHOLD) { |
|
553
|
0 |
0 |
if (map != MAP_FAILED) { |
|
572
|
65 |
0 |
if (n == st.st_size) { |
|
583
|
0 |
0 |
if (n < 0) { |
|
584
|
0 |
0 |
if (errno == EINTR) { |
|
596
|
0 |
0 |
while (total < st.st_size) { |
|
598
|
0 |
0 |
if (n < 0) { |
|
599
|
0 |
0 |
if (errno == EINTR) continue; |
|
606
|
0 |
0 |
if (n == 0) break; |
|
625
|
71 |
0 |
PUSHs(file_spew_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no); |
|
635
|
140 |
7 |
PUSHs(file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
655
|
17 |
12 |
PUSHs(file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
665
|
9 |
13 |
PUSHs(file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
678
|
0 |
6 |
if (content == &PL_sv_undef) { |
|
695
|
1 |
1 |
PUSHs(file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
705
|
1 |
0 |
if (SvOK(path_sv)) { |
|
724
|
4 |
0 |
PUSHs(file_mkdir_internal(path, 0755) ? &PL_sv_yes : &PL_sv_no); |
|
734
|
1 |
0 |
PUSHs(file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
744
|
1 |
0 |
PUSHs(file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
824
|
2 |
4 |
PUSHs(file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
834
|
7 |
0 |
PUSHs(file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
844
|
6 |
0 |
PUSHs(file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
854
|
8 |
0 |
PUSHs(file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no); |
|
888
|
1 |
0 |
PUSHs(file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no); |
|
900
|
0 |
0 |
PUSHs(file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no); |
|
912
|
0 |
0 |
PUSHs(file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no); |
|
923
|
2 |
0 |
PUSHs(file_append_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no); |
|
934
|
0 |
0 |
PUSHs(file_atomic_spew_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no); |
|
953
|
168 |
0 |
if (!OpHAS_SIBLING(pushop)) { |
|
958
|
168 |
0 |
argop = OpSIBLING(pushop); |
|
959
|
0 |
168 |
if (!argop) return entersubop; |
|
961
|
167 |
1 |
cvop = OpSIBLING(argop); |
|
962
|
1 |
167 |
if (!cvop) return entersubop; |
|
965
|
167 |
0 |
if (OpSIBLING(argop) != cvop) return entersubop; |
|
|
0 |
167 |
if (OpSIBLING(argop) != cvop) return entersubop; |
|
991
|
46 |
0 |
if (!OpHAS_SIBLING(pushop)) { |
|
996
|
46 |
0 |
pathop = OpSIBLING(pushop); |
|
997
|
0 |
46 |
if (!pathop) return entersubop; |
|
999
|
46 |
0 |
dataop = OpSIBLING(pathop); |
|
1000
|
0 |
46 |
if (!dataop) return entersubop; |
|
1002
|
46 |
0 |
cvop = OpSIBLING(dataop); |
|
1003
|
0 |
46 |
if (!cvop) return entersubop; |
|
1006
|
46 |
0 |
if (OpSIBLING(dataop) != cvop) return entersubop; |
|
|
0 |
46 |
if (OpSIBLING(dataop) != cvop) return entersubop; |
|
1109
|
0 |
18 |
if (file_initialized) return; |
|
1112
|
0 |
18 |
Newxz(g_mmaps, g_mmaps_size, MmapEntry); |
|
1114
|
0 |
18 |
Newxz(g_free_mmaps, g_free_mmaps_size, IV); |
|
1117
|
0 |
18 |
Newxz(g_iters, g_iters_size, LineIterEntry); |
|
1119
|
0 |
18 |
Newxz(g_free_iters, g_free_iters_size, IV); |
|
1151
|
2 |
42 |
if (fd < 0 && errno == EPERM) { |
|
|
0 |
2 |
if (fd < 0 && errno == EPERM) { |
|
1155
|
2 |
42 |
if (fd < 0) { |
|
1159
|
0 |
42 |
if (fstat(fd, &st) < 0) { |
|
1168
|
42 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
|
37 |
5 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
1171
|
0 |
37 |
if (st.st_size >= MMAP_SLURP_THRESHOLD) { |
|
1173
|
0 |
0 |
if (map != MAP_FAILED) { |
|
1198
|
37 |
37 |
while (total < st.st_size) { |
|
1200
|
0 |
37 |
if (n < 0) { |
|
1201
|
0 |
0 |
if (errno == EINTR) continue; |
|
1206
|
0 |
37 |
if (n == 0) break; |
|
1220
|
0 |
5 |
if (total >= (ssize_t)capacity - 1) { |
|
1222
|
0 |
0 |
SvGROW(result, capacity); |
|
|
0 |
0 |
SvGROW(result, capacity); |
|
1227
|
0 |
5 |
if (n < 0) { |
|
1228
|
0 |
0 |
if (errno == EINTR) continue; |
|
1233
|
5 |
0 |
if (n == 0) break; |
|
1245
|
40 |
2 |
if (g_file_read_hook || g_file_hooks[FILE_HOOK_PHASE_READ]) { |
|
|
7 |
33 |
if (g_file_read_hook || g_file_hooks[FILE_HOOK_PHASE_READ]) { |
|
1247
|
0 |
9 |
if (!hooked) { |
|
1251
|
9 |
0 |
if (hooked != result) { |
|
1283
|
0 |
3 |
if (fd < 0 && errno == EPERM) { |
|
|
0 |
0 |
if (fd < 0 && errno == EPERM) { |
|
1287
|
0 |
3 |
if (fd < 0) { |
|
1291
|
0 |
3 |
if (fstat(fd, &st) < 0) { |
|
1299
|
3 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
|
3 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
1302
|
0 |
3 |
if (st.st_size >= MMAP_SLURP_THRESHOLD) { |
|
1304
|
0 |
0 |
if (map != MAP_FAILED) { |
|
1326
|
3 |
3 |
while (total < st.st_size) { |
|
1328
|
0 |
3 |
if (n < 0) { |
|
1329
|
0 |
0 |
if (errno == EINTR) continue; |
|
1334
|
0 |
3 |
if (n == 0) break; |
|
1347
|
0 |
0 |
if (total >= (ssize_t)capacity - 1) { |
|
1349
|
0 |
0 |
SvGROW(result, capacity); |
|
|
0 |
0 |
SvGROW(result, capacity); |
|
1354
|
0 |
0 |
if (n < 0) { |
|
1355
|
0 |
0 |
if (errno == EINTR) continue; |
|
1360
|
0 |
0 |
if (n == 0) break; |
|
1394
|
154 |
2 |
if (UNLIKELY(g_file_write_hook || g_file_hooks[FILE_HOOK_PHASE_WRITE])) { |
|
|
3 |
151 |
if (UNLIKELY(g_file_write_hook || g_file_hooks[FILE_HOOK_PHASE_WRITE])) { |
|
1396
|
0 |
5 |
if (!hooked) { |
|
1399
|
5 |
0 |
if (hooked != data) { |
|
1408
|
0 |
156 |
if (UNLIKELY(fd < 0)) { |
|
1409
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1415
|
4 |
152 |
if (len >= 65536) { |
|
1422
|
156 |
0 |
if (LIKELY(n == (ssize_t)len)) { |
|
1424
|
5 |
151 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1426
|
62 |
94 |
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) { |
|
1433
|
0 |
0 |
if (n < 0) { |
|
1434
|
0 |
0 |
if (errno != EINTR) { |
|
1436
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1445
|
0 |
0 |
while ((size_t)written < len) { |
|
1447
|
0 |
0 |
if (n < 0) { |
|
1448
|
0 |
0 |
if (errno == EINTR) continue; |
|
1450
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1458
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1460
|
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) { |
|
1484
|
0 |
4 |
if (UNLIKELY(fd < 0)) { |
|
1490
|
4 |
0 |
if (LIKELY(n == (ssize_t)len)) { |
|
1493
|
4 |
0 |
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) { |
|
1500
|
0 |
0 |
if (n < 0) { |
|
1501
|
0 |
0 |
if (errno != EINTR) { |
|
1511
|
0 |
0 |
while ((size_t)written < len) { |
|
1513
|
0 |
0 |
if (n < 0) { |
|
1514
|
0 |
0 |
if (errno == EINTR) continue; |
|
1524
|
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) { |
|
1535
|
0 |
4 |
if (needed >= g_mmaps_size) { |
|
1536
|
0 |
0 |
IV new_size = g_mmaps_size ? g_mmaps_size * 2 : 16; |
|
1538
|
0 |
0 |
while (new_size <= needed) new_size *= 2; |
|
1539
|
0 |
0 |
Renew(g_mmaps, new_size, MmapEntry); |
|
1540
|
0 |
0 |
for (i = g_mmaps_size; i < new_size; i++) { |
|
1558
|
10 |
4 |
if (g_free_mmaps_count > 0) { |
|
1571
|
14 |
0 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1587
|
14 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
|
14 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
1590
|
14 |
0 |
if (entry->fd >= 0) { |
|
1599
|
0 |
14 |
if (g_free_mmaps_count >= g_free_mmaps_size) { |
|
1601
|
0 |
0 |
Renew(g_free_mmaps, g_free_mmaps_size, IV); |
|
1661
|
1 |
15 |
int flags = writable ? O_RDWR : O_RDONLY; |
|
1662
|
1 |
15 |
int prot = writable ? (PROT_READ | PROT_WRITE) : PROT_READ; |
|
1665
|
1 |
15 |
if (fd < 0) { |
|
1669
|
0 |
15 |
if (fstat(fd, &st) < 0) { |
|
1674
|
1 |
14 |
if (st.st_size == 0) { |
|
1683
|
0 |
14 |
if (addr == MAP_FAILED) { |
|
1702
|
14 |
0 |
if (idx < 0 || idx >= g_mmaps_count) { |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) { |
|
1712
|
14 |
0 |
if (!entry->addr || entry->addr == MAP_FAILED) { |
|
|
0 |
14 |
if (!entry->addr || entry->addr == MAP_FAILED) { |
|
1719
|
14 |
0 |
SvUPGRADE(sv, SVt_PV); |
|
1731
|
14 |
2 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1735
|
14 |
0 |
if (entry->refcount <= 0) { |
|
1744
|
2 |
0 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
2 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1752
|
2 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
|
2 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
1763
|
0 |
7 |
if (needed >= g_iters_size) { |
|
1764
|
0 |
0 |
IV new_size = g_iters_size ? g_iters_size * 2 : 16; |
|
1766
|
0 |
0 |
while (new_size <= needed) new_size *= 2; |
|
1767
|
0 |
0 |
Renew(g_iters, new_size, LineIterEntry); |
|
1768
|
0 |
0 |
for (i = g_iters_size; i < new_size; i++) { |
|
1785
|
51 |
7 |
if (g_free_iters_count > 0) { |
|
1798
|
57 |
0 |
if (idx < 0 || idx >= g_iters_count) return; |
|
|
0 |
57 |
if (idx < 0 || idx >= g_iters_count) return; |
|
1801
|
57 |
0 |
if (entry->fd >= 0) { |
|
1804
|
57 |
0 |
if (entry->buffer) { |
|
1807
|
57 |
0 |
if (entry->path) { |
|
1820
|
0 |
57 |
if (g_free_iters_count >= g_free_iters_size) { |
|
1822
|
0 |
0 |
Renew(g_free_iters, g_free_iters_size, IV); |
|
1839
|
4 |
58 |
if (fd < 0) { |
|
1869
|
1291 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
|
0 |
1291 |
if (idx < 0 || idx >= g_iters_count) { |
|
1874
|
0 |
1291 |
if (entry->fd < 0) { |
|
1880
|
1268 |
84 |
if (entry->buf_pos < entry->buf_len) { |
|
1884
|
1256 |
12 |
if (newline) { |
|
1893
|
35 |
61 |
if (entry->eof) { |
|
1895
|
6 |
29 |
if (entry->buf_pos < entry->buf_len) { |
|
1905
|
26 |
35 |
if (entry->buf_pos > 0) { |
|
1907
|
6 |
20 |
if (remaining > 0) { |
|
1915
|
0 |
61 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
1923
|
0 |
61 |
if (n < 0) { |
|
1924
|
0 |
0 |
if (errno == EINTR) continue; |
|
1927
|
29 |
32 |
if (n == 0) { |
|
1939
|
0 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
|
0 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
1944
|
0 |
0 |
return entry->eof && entry->buf_pos >= entry->buf_len; |
|
|
0 |
0 |
return entry->eof && entry->buf_pos >= entry->buf_len; |
|
1949
|
57 |
1 |
if (idx < 0 || idx >= g_iters_count) return; |
|
|
0 |
57 |
if (idx < 0 || idx >= g_iters_count) return; |
|
1953
|
57 |
0 |
if (entry->refcount <= 0) { |
|
1965
|
2 |
63 |
if (cached_stat(path, &st) < 0) { |
|
1980
|
2 |
31 |
if (cached_stat(path, &st) < 0) return 0; |
|
1987
|
4 |
25 |
if (cached_stat(path, &st) < 0) return 0; |
|
2004
|
1 |
30 |
if (cached_stat(path, &st) < 0) { |
|
2013
|
1 |
7 |
if (cached_stat(path, &st) < 0) { |
|
2022
|
1 |
7 |
if (cached_stat(path, &st) < 0) { |
|
2031
|
1 |
4 |
if (cached_stat(path, &st) < 0) { |
|
2042
|
1 |
3 |
if (cached_stat(path, &st) < 0) { |
|
2052
|
2 |
1 |
hv_store(result, "is_file", 7, S_ISREG(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0); |
|
2053
|
1 |
2 |
hv_store(result, "is_dir", 6, S_ISDIR(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0); |
|
2072
|
1 |
9 |
if (lstat(path, &st) < 0) return 0; |
|
2107
|
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) { |
|
2132
|
1 |
3 |
if (fd_src < 0) return 0; |
|
2134
|
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)) { |
|
2140
|
0 |
3 |
if (fd_dst < 0) { |
|
2146
|
2 |
3 |
while (offset < st.st_size) { |
|
2148
|
0 |
2 |
if (sent < 0) { |
|
2149
|
0 |
0 |
if (errno == EINTR) continue; |
|
2150
|
0 |
0 |
if (errno == EINVAL || errno == ENOSYS) { |
|
|
0 |
0 |
if (errno == EINVAL || errno == ENOSYS) { |
|
2162
|
0 |
0 |
if (n_read < 0) { |
|
2163
|
0 |
0 |
if (errno == EINTR) continue; |
|
2166
|
0 |
0 |
if (n_read == 0) { result = 1; break; } |
|
2169
|
0 |
0 |
while (written < n_read) { |
|
2171
|
0 |
0 |
if (n_written < 0) { |
|
2172
|
0 |
0 |
if (errno == EINTR) continue; |
|
2182
|
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) { |
|
2191
|
0 |
2 |
if (sent == 0) break; |
|
2197
|
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) { |
|
2268
|
2 |
1 |
if (rename(src, dst) == 0) { |
|
2272
|
0 |
1 |
else if (errno == EXDEV) { |
|
2273
|
0 |
0 |
if (file_copy_internal(aTHX_ src, dst)) { |
|
2283
|
1 |
1 |
if (g_stat_cache.valid) { |
|
2284
|
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) { |
|
2314
|
1 |
2 |
if (utime(path, NULL) == 0) { |
|
2319
|
0 |
2 |
if (fd < 0) { |
|
2327
|
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) { |
|
2342
|
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) { |
|
2358
|
6 |
10 |
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) { |
|
2373
|
1 |
6 |
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) { |
|
2417
|
2 |
3 |
if (!dir) return result; |
|
2419
|
22 |
3 |
while ((entry = readdir(dir)) != NULL) { |
|
2421
|
19 |
3 |
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { |
|
|
16 |
3 |
if (strcmp(entry->d_name, ".") != 0 && strcmp(entry->d_name, "..") != 0) { |
|
2440
|
2 |
81 |
if (len == 0) return newSVpvs(""); |
|
2443
|
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] == '\\')) { |
|
2446
|
3 |
78 |
if (len == 0) return newSVpvs(""); |
|
2450
|
732 |
3 |
while (p > path && *p != '/' && *p != '\\') { |
|
|
657 |
75 |
while (p > path && *p != '/' && *p != '\\') { |
|
|
657 |
0 |
while (p > path && *p != '/' && *p != '\\') { |
|
2453
|
3 |
75 |
if (*p == '/' || *p == '\\') p++; |
|
|
0 |
3 |
if (*p == '/' || *p == '\\') p++; |
|
2462
|
1 |
19 |
if (len == 0) return newSVpvs("."); |
|
2466
|
19 |
2 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
|
2 |
17 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
|
0 |
17 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
2471
|
131 |
6 |
while (end > path && *end != '/' && *end != '\\') { |
|
|
118 |
13 |
while (end > path && *end != '/' && *end != '\\') { |
|
|
118 |
0 |
while (end > path && *end != '/' && *end != '\\') { |
|
2475
|
6 |
13 |
if (end == path) { |
|
2476
|
2 |
4 |
if (*end == '/' || *end == '\\') { |
|
|
0 |
2 |
if (*end == '/' || *end == '\\') { |
|
2483
|
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) == '\\')) { |
|
2495
|
1 |
48 |
if (len == 0) return newSVpvs(""); |
|
2499
|
440 |
12 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
|
404 |
36 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
|
404 |
0 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
2502
|
12 |
36 |
if (*basename == '/' || *basename == '\\') basename++; |
|
|
0 |
12 |
if (*basename == '/' || *basename == '\\') basename++; |
|
2506
|
44 |
4 |
if (!dot || dot == basename) return newSVpvs(""); |
|
|
2 |
42 |
if (!dot || dot == basename) return newSVpvs(""); |
|
2519
|
0 |
7 |
if (len == 0) return newSVpvs(""); |
|
2522
|
17 |
7 |
for (i = 0; i < len; i++) { |
|
2524
|
17 |
0 |
if (sv && SvPOK(*sv)) { |
|
|
17 |
0 |
if (sv && SvPOK(*sv)) { |
|
2535
|
17 |
7 |
for (i = 0; i < len; i++) { |
|
2537
|
17 |
0 |
if (sv && SvPOK(*sv)) { |
|
|
17 |
0 |
if (sv && SvPOK(*sv)) { |
|
2541
|
1 |
16 |
if (part_len == 0) continue; |
|
2544
|
18 |
0 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
|
5 |
13 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
|
0 |
13 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
2545
|
5 |
0 |
if (!need_sep && p == buf) break; /* Keep root slash */ |
|
|
3 |
2 |
if (!need_sep && p == buf) break; /* Keep root slash */ |
|
2550
|
6 |
10 |
if (need_sep && part_len > 0) { |
|
|
6 |
0 |
if (need_sep && part_len > 0) { |
|
2558
|
16 |
0 |
if (part_len > 0) { |
|
2563
|
13 |
3 |
need_sep = (*(p-1) != '/' && *(p-1) != '\\'); |
|
|
13 |
0 |
need_sep = (*(p-1) != '/' && *(p-1) != '\\'); |
|
2583
|
1 |
5 |
if (n <= 0) return result; |
|
2586
|
1 |
4 |
if (idx < 0) return result; |
|
2588
|
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) { |
|
2604
|
1 |
5 |
if (n <= 0) return result; |
|
2607
|
1 |
4 |
if (idx < 0) return result; |
|
2613
|
43 |
4 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
2614
|
25 |
18 |
if (av_len(buffer) + 1 >= n) { |
|
2625
|
18 |
4 |
for (i = 0; i < buf_len; i++) { |
|
2627
|
18 |
0 |
if (sv) { |
|
2661
|
0 |
14 |
if (fd < 0) { |
|
2665
|
13 |
14 |
while ((size_t)written < len) { |
|
2667
|
0 |
13 |
if (n < 0) { |
|
2668
|
0 |
0 |
if (errno == EINTR) continue; |
|
2687
|
0 |
14 |
if (rename(temp_path, path) != 0) { |
|
2693
|
10 |
4 |
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) { |
|
2712
|
14 |
2 |
while (start < end) { |
|
2714
|
10 |
4 |
if (p) { |
|
2718
|
4 |
0 |
if (start < end) { |
|
2736
|
0 |
29 |
if (items != 1) croak("Usage: file::slurp(path)"); |
|
2747
|
0 |
2 |
if (items != 1) croak("Usage: file::slurp_raw(path)"); |
|
2758
|
0 |
85 |
if (items != 2) croak("Usage: file::spew(path, data)"); |
|
2761
|
85 |
0 |
if (file_spew_internal(aTHX_ path, ST(1))) { |
|
2773
|
0 |
2 |
if (items != 2) croak("Usage: file::append(path, data)"); |
|
2776
|
2 |
0 |
if (file_append_internal(aTHX_ path, ST(1))) { |
|
2789
|
0 |
11 |
if (items != 1) croak("Usage: file::size(path)"); |
|
2802
|
0 |
4 |
if (items != 1) croak("Usage: file::mtime(path)"); |
|
2814
|
0 |
21 |
if (items != 1) croak("Usage: file::exists(path)"); |
|
2817
|
14 |
7 |
ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2825
|
0 |
4 |
if (items != 1) croak("Usage: file::is_file(path)"); |
|
2828
|
3 |
1 |
ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2836
|
0 |
7 |
if (items != 1) croak("Usage: file::is_dir(path)"); |
|
2839
|
4 |
3 |
ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2847
|
0 |
2 |
if (items != 1) croak("Usage: file::is_readable(path)"); |
|
2850
|
1 |
1 |
ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2858
|
0 |
3 |
if (items != 1) croak("Usage: file::is_writable(path)"); |
|
2861
|
2 |
1 |
ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2881
|
0 |
7 |
if (items != 1) croak("Usage: file::lines(path)"); |
|
2886
|
1 |
6 |
if (UNLIKELY(fd < 0)) { |
|
2892
|
6 |
0 |
if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) { |
|
|
1 |
5 |
if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) { |
|
2903
|
5 |
5 |
while ((size_t)total_read < file_size) { |
|
2905
|
0 |
5 |
if (UNLIKELY(n < 0)) { |
|
2906
|
0 |
0 |
if (errno == EINTR) continue; |
|
2909
|
0 |
5 |
if (n == 0) break; |
|
2914
|
0 |
5 |
if (UNLIKELY(total_read == 0)) { |
|
2929
|
15 |
0 |
while (p < end) { |
|
2931
|
10 |
5 |
if (LIKELY(p != NULL)) { |
|
2937
|
5 |
0 |
if (line_start < end) { |
|
2957
|
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])"); |
|
2960
|
1 |
15 |
writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0; |
|
|
1 |
0 |
writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0; |
|
2963
|
2 |
14 |
if (idx < 0) { |
|
2982
|
0 |
14 |
if (items != 1) croak("Usage: $mmap->data"); |
|
2984
|
14 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
14 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
2990
|
14 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3002
|
0 |
2 |
if (items != 1) croak("Usage: $mmap->sync"); |
|
3004
|
2 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
2 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3010
|
2 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3022
|
0 |
16 |
if (items != 1) croak("Usage: $mmap->close"); |
|
3024
|
16 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
16 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3030
|
16 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3045
|
0 |
14 |
if (PL_dirty) XSRETURN_EMPTY; |
|
3047
|
14 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
14 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3053
|
14 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3055
|
0 |
14 |
if (idx >= 0) { |
|
3067
|
0 |
18 |
if (items != 1) croak("Usage: file::lines_iter(path)"); |
|
3072
|
1 |
17 |
if (idx < 0) { |
|
3094
|
0 |
153 |
if (items != 1) croak("Usage: $iter->next"); |
|
3097
|
0 |
153 |
if (UNLIKELY(!SvROK(rv))) { |
|
3104
|
153 |
0 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
|
0 |
153 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
3110
|
0 |
153 |
if (UNLIKELY(entry->fd < 0)) { |
|
3118
|
163 |
22 |
if (entry->buf_pos < entry->buf_len) { |
|
3122
|
139 |
24 |
if (newline) { |
|
3132
|
14 |
32 |
if (entry->eof) { |
|
3134
|
11 |
3 |
if (entry->buf_pos < entry->buf_len) { |
|
3146
|
12 |
20 |
if (entry->buf_pos > 0) { |
|
3148
|
10 |
2 |
if (remaining > 0) { |
|
3156
|
1 |
31 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
3164
|
0 |
32 |
if (n < 0) { |
|
3165
|
0 |
0 |
if (errno == EINTR) continue; |
|
3169
|
14 |
18 |
if (n == 0) { |
|
3183
|
0 |
123 |
if (items != 1) croak("Usage: $iter->eof"); |
|
3186
|
0 |
123 |
if (UNLIKELY(!SvROK(rv))) { |
|
3193
|
123 |
0 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
|
0 |
123 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
3199
|
9 |
114 |
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; |
|
3208
|
0 |
18 |
if (items != 1) croak("Usage: $iter->close"); |
|
3211
|
0 |
18 |
if (UNLIKELY(!SvROK(rv))) { |
|
3230
|
0 |
17 |
if (PL_dirty) XSRETURN_EMPTY; |
|
3233
|
0 |
17 |
if (UNLIKELY(!SvROK(rv))) { |
|
3239
|
0 |
17 |
if (idx >= 0) { |
|
3267
|
50 |
10 |
for (i = 0; i < len; i++) { |
|
3268
|
35 |
15 |
if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') { |
|
|
35 |
0 |
if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') { |
|
|
35 |
0 |
if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') { |
|
|
35 |
0 |
if (s[i] != ' ' && s[i] != '\t' && s[i] != '\r' && s[i] != '\n') { |
|
3291
|
27 |
6 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
|
9 |
18 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
|
0 |
18 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
3295
|
18 |
6 |
return len > 0 && *s == '#'; |
|
|
5 |
13 |
return len > 0 && *s == '#'; |
|
3309
|
18 |
0 |
if (PL_dirty) { |
|
3322
|
3 |
18 |
if (g_file_callback_registry) return; |
|
3377
|
0 |
17 |
if (!g_file_callback_registry) return NULL; |
|
3379
|
14 |
3 |
if (svp && SvIOK(*svp)) { |
|
|
14 |
0 |
if (svp && SvIOK(*svp)) { |
|
3406
|
0 |
7 |
if (items != 2) croak("Usage: file::each_line(path, callback)"); |
|
3411
|
7 |
0 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
|
0 |
7 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
3417
|
1 |
6 |
if (idx < 0) { |
|
3423
|
6 |
0 |
old_defsv = DEFSV; |
|
3425
|
6 |
0 |
DEFSV = line_sv; |
|
3428
|
0 |
6 |
PUSH_MULTICALL(block_cv); |
|
3433
|
1024 |
9 |
if (entry->buf_pos < entry->buf_len) { |
|
3437
|
1018 |
6 |
if (newline) { |
|
3451
|
5 |
10 |
if (entry->eof) { |
|
3453
|
3 |
2 |
if (entry->buf_pos < entry->buf_len) { |
|
3467
|
4 |
6 |
if (entry->buf_pos > 0) { |
|
3469
|
3 |
1 |
if (remaining > 0) { |
|
3477
|
0 |
10 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
3485
|
0 |
10 |
if (n < 0) { |
|
3486
|
0 |
0 |
if (errno == EINTR) continue; |
|
3489
|
5 |
5 |
if (n == 0) { |
|
3497
|
5 |
0 |
POP_MULTICALL; |
|
3500
|
5 |
0 |
DEFSV = old_defsv; |
|
3516
|
0 |
17 |
if (items != 2) croak("Usage: file::grep_lines(path, &predicate or $name)"); |
|
3523
|
5 |
12 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
5 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3528
|
1 |
11 |
if (!fcb) { |
|
3534
|
0 |
16 |
if (idx < 0) { |
|
3540
|
11 |
5 |
if (fcb && fcb->predicate) { |
|
|
8 |
3 |
if (fcb && fcb->predicate) { |
|
3541
|
72 |
8 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3542
|
41 |
31 |
if (fcb->predicate(aTHX_ line)) { |
|
3555
|
3 |
5 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3556
|
1057 |
8 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3561
|
0 |
1057 |
PUSHMARK(SP); |
|
3562
|
0 |
1057 |
XPUSHs(line); |
|
3566
|
1057 |
0 |
if (count > 0) { |
|
3571
|
26 |
1031 |
if (matches) { |
|
3595
|
6 |
0 |
if (items < 1 || items > 2) croak("Usage: file::count_lines(path, [&predicate or $name])"); |
|
|
0 |
6 |
if (items < 1 || items > 2) croak("Usage: file::count_lines(path, [&predicate or $name])"); |
|
3600
|
4 |
2 |
if (items == 1) { |
|
3612
|
1 |
3 |
if (UNLIKELY(fd < 0)) { |
|
3620
|
2 |
3 |
while ((n = read(fd, buffer, FILE_BUFFER_SIZE)) > 0) { |
|
3623
|
1008 |
2 |
while ((p = memchr(p, '\n', end - p)) != NULL) { |
|
3634
|
2 |
1 |
if (total_read > 0 && last_char != '\n') { |
|
|
1 |
1 |
if (total_read > 0 && last_char != '\n') { |
|
3645
|
1 |
1 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
1 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3650
|
0 |
1 |
if (!fcb) { |
|
3656
|
0 |
2 |
if (idx < 0) { |
|
3662
|
1 |
1 |
if (fcb && fcb->predicate) { |
|
|
1 |
0 |
if (fcb && fcb->predicate) { |
|
3663
|
9 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3664
|
7 |
2 |
if (fcb->predicate(aTHX_ line)) { |
|
3676
|
0 |
1 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3677
|
9 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3682
|
0 |
9 |
PUSHMARK(SP); |
|
3683
|
0 |
9 |
XPUSHs(line); |
|
3687
|
9 |
0 |
if (n > 0) { |
|
3692
|
8 |
1 |
if (matches) { |
|
3714
|
0 |
5 |
if (items != 2) croak("Usage: file::find_line(path, &predicate or $name)"); |
|
3720
|
4 |
1 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
4 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3725
|
0 |
1 |
if (!fcb) { |
|
3731
|
0 |
5 |
if (idx < 0) { |
|
3736
|
1 |
4 |
if (fcb && fcb->predicate) { |
|
|
1 |
0 |
if (fcb && fcb->predicate) { |
|
3737
|
6 |
0 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3738
|
1 |
5 |
if (fcb->predicate(aTHX_ line)) { |
|
3751
|
0 |
4 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3752
|
21 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3757
|
0 |
21 |
PUSHMARK(SP); |
|
3758
|
0 |
21 |
XPUSHs(line); |
|
3762
|
21 |
0 |
if (n > 0) { |
|
3767
|
3 |
18 |
if (matches) { |
|
3788
|
0 |
4 |
if (items != 2) croak("Usage: file::map_lines(path, &callback)"); |
|
3794
|
4 |
0 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
|
0 |
4 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
3799
|
0 |
4 |
if (idx < 0) { |
|
3806
|
27 |
4 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3810
|
0 |
27 |
PUSHMARK(SP); |
|
3811
|
0 |
27 |
XPUSHs(sv_2mortal(line)); |
|
3815
|
27 |
0 |
if (count > 0) { |
|
3837
|
0 |
4 |
if (items != 2) croak("Usage: file::register_line_callback($name, \\&coderef)"); |
|
3842
|
3 |
1 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
3 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3851
|
1 |
2 |
if (existing) { |
|
3853
|
1 |
0 |
if (existing->perl_callback) { |
|
3881
|
1 |
0 |
if (g_file_callback_registry) { |
|
3883
|
14 |
1 |
while ((entry = hv_iternext(g_file_callback_registry))) { |
|
3902
|
0 |
11 |
if (items != 1) croak("Usage: file::register_read_hook(\\&coderef)"); |
|
3905
|
11 |
0 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
11 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3928
|
0 |
4 |
if (items != 1) croak("Usage: file::register_write_hook(\\&coderef)"); |
|
3931
|
4 |
0 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
4 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3955
|
0 |
40 |
if (items != 1) croak("Usage: file::clear_hooks($phase)"); |
|
3959
|
26 |
14 |
if (strcmp(phase_name, "read") == 0) { |
|
3963
|
14 |
0 |
} else if (strcmp(phase_name, "write") == 0) { |
|
3967
|
0 |
0 |
} else if (strcmp(phase_name, "open") == 0) { |
|
3969
|
0 |
0 |
} else if (strcmp(phase_name, "close") == 0) { |
|
3977
|
15 |
40 |
while (entry) { |
|
3979
|
15 |
0 |
if (entry->perl_callback) { |
|
3997
|
0 |
11 |
if (items != 1) croak("Usage: file::has_hooks($phase)"); |
|
4001
|
6 |
5 |
if (strcmp(phase_name, "read") == 0) { |
|
4003
|
5 |
1 |
has = (g_file_read_hook != NULL) || (g_file_hooks[phase] != NULL); |
|
|
3 |
2 |
has = (g_file_read_hook != NULL) || (g_file_hooks[phase] != NULL); |
|
4004
|
5 |
0 |
} else if (strcmp(phase_name, "write") == 0) { |
|
4006
|
5 |
0 |
has = (g_file_write_hook != NULL) || (g_file_hooks[phase] != NULL); |
|
|
3 |
2 |
has = (g_file_write_hook != NULL) || (g_file_hooks[phase] != NULL); |
|
4007
|
0 |
0 |
} else if (strcmp(phase_name, "open") == 0) { |
|
4010
|
0 |
0 |
} else if (strcmp(phase_name, "close") == 0) { |
|
4017
|
7 |
4 |
ST(0) = has ? &PL_sv_yes : &PL_sv_no; |
|
4025
|
0 |
2 |
if (items != 1) croak("Usage: file::atime(path)"); |
|
4034
|
0 |
2 |
if (items != 1) croak("Usage: file::ctime(path)"); |
|
4043
|
0 |
2 |
if (items != 1) croak("Usage: file::mode(path)"); |
|
4054
|
0 |
4 |
if (items != 1) croak("Usage: File::Raw::stat(path)"); |
|
4057
|
1 |
3 |
if (result == NULL) { |
|
4068
|
0 |
4 |
if (items != 1) croak("Usage: file::is_link(path)"); |
|
4070
|
1 |
3 |
ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4077
|
0 |
0 |
if (items != 1) croak("Usage: file::is_executable(path)"); |
|
4079
|
0 |
0 |
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4087
|
0 |
4 |
if (items != 1) croak("Usage: file::unlink(path)"); |
|
4089
|
2 |
2 |
ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4097
|
0 |
3 |
if (items != 2) croak("Usage: file::copy(src, dst)"); |
|
4100
|
2 |
1 |
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4108
|
0 |
3 |
if (items != 2) croak("Usage: file::move(src, dst)"); |
|
4111
|
2 |
1 |
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4118
|
0 |
2 |
if (items != 1) croak("Usage: file::touch(path)"); |
|
4120
|
2 |
0 |
ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4126
|
0 |
1 |
if (items > 1) croak("Usage: file::clear_stat_cache() or file::clear_stat_cache(path)"); |
|
4128
|
0 |
1 |
if (items == 1 && SvOK(ST(0))) { |
|
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
4143
|
0 |
1 |
if (items != 2) croak("Usage: file::chmod(path, mode)"); |
|
4146
|
1 |
0 |
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4154
|
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])"); |
|
4156
|
0 |
12 |
if (items > 1) mode = SvIV(ST(1)); |
|
4157
|
8 |
4 |
ST(0) = file_mkdir_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4164
|
0 |
6 |
if (items != 1) croak("Usage: file::rmdir(path)"); |
|
4166
|
2 |
4 |
ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4174
|
0 |
5 |
if (items != 1) croak("Usage: file::readdir(path)"); |
|
4185
|
0 |
12 |
if (items != 1) croak("Usage: file::basename(path)"); |
|
4194
|
0 |
10 |
if (items != 1) croak("Usage: file::dirname(path)"); |
|
4203
|
0 |
13 |
if (items != 1) croak("Usage: file::extname(path)"); |
|
4214
|
0 |
7 |
if (items < 1) croak("Usage: file::join(part1, part2, ...)"); |
|
4217
|
17 |
7 |
for (i = 0; i < items; i++) { |
|
4232
|
6 |
0 |
if (items < 1 || items > 2) croak("Usage: file::head(path, [n])"); |
|
|
0 |
6 |
if (items < 1 || items > 2) croak("Usage: file::head(path, [n])"); |
|
4234
|
4 |
2 |
if (items > 1) n = SvIV(ST(1)); |
|
4245
|
6 |
0 |
if (items < 1 || items > 2) croak("Usage: file::tail(path, [n])"); |
|
|
0 |
6 |
if (items < 1 || items > 2) croak("Usage: file::tail(path, [n])"); |
|
4247
|
4 |
2 |
if (items > 1) n = SvIV(ST(1)); |
|
4257
|
0 |
14 |
if (items != 2) croak("Usage: file::atomic_spew(path, data)"); |
|
4259
|
14 |
0 |
ST(0) = file_atomic_spew_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4270
|
0 |
0 |
if (items != 1) croak("Usage: file_slurp($path)"); |
|
4279
|
0 |
0 |
if (items != 2) croak("Usage: file_spew($path, $data)"); |
|
4281
|
0 |
0 |
if (file_spew_internal(aTHX_ path, ST(1))) { |
|
4292
|
0 |
0 |
if (items != 1) croak("Usage: file_exists($path)"); |
|
4294
|
0 |
0 |
ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4301
|
0 |
0 |
if (items != 1) croak("Usage: file_size($path)"); |
|
4310
|
0 |
0 |
if (items != 1) croak("Usage: file_is_file($path)"); |
|
4312
|
0 |
0 |
ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4319
|
0 |
0 |
if (items != 1) croak("Usage: file_is_dir($path)"); |
|
4321
|
0 |
0 |
ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4330
|
0 |
0 |
if (items != 1) croak("Usage: file_lines($path)"); |
|
4334
|
0 |
0 |
if (content == &PL_sv_undef) { |
|
4348
|
0 |
0 |
if (items != 1) croak("Usage: file_unlink($path)"); |
|
4350
|
0 |
0 |
ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4357
|
0 |
0 |
if (items != 1) croak("Usage: file_mkdir($path)"); |
|
4359
|
0 |
0 |
ST(0) = file_mkdir_internal(path, 0755) ? &PL_sv_yes : &PL_sv_no; |
|
4366
|
0 |
0 |
if (items != 1) croak("Usage: file_rmdir($path)"); |
|
4368
|
0 |
0 |
ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4375
|
0 |
0 |
if (items != 1) croak("Usage: file_touch($path)"); |
|
4377
|
0 |
0 |
ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4383
|
0 |
0 |
if (items > 1) croak("Usage: file_clear_stat_cache() or file_clear_stat_cache($path)"); |
|
4385
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
4399
|
0 |
0 |
if (items != 1) croak("Usage: file_basename($path)"); |
|
4408
|
0 |
0 |
if (items != 1) croak("Usage: file_dirname($path)"); |
|
4417
|
0 |
0 |
if (items != 1) croak("Usage: file_extname($path)"); |
|
4426
|
0 |
0 |
if (items != 1) croak("Usage: file_mtime($path)"); |
|
4435
|
0 |
0 |
if (items != 1) croak("Usage: file_atime($path)"); |
|
4444
|
0 |
0 |
if (items != 1) croak("Usage: file_ctime($path)"); |
|
4453
|
0 |
0 |
if (items != 1) croak("Usage: file_mode($path)"); |
|
4462
|
0 |
0 |
if (items != 1) croak("Usage: file_is_link($path)"); |
|
4464
|
0 |
0 |
ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4471
|
0 |
0 |
if (items != 1) croak("Usage: file_is_readable($path)"); |
|
4473
|
0 |
0 |
ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4480
|
0 |
0 |
if (items != 1) croak("Usage: file_is_writable($path)"); |
|
4482
|
0 |
0 |
ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4489
|
0 |
0 |
if (items != 1) croak("Usage: file_is_executable($path)"); |
|
4491
|
0 |
0 |
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4499
|
0 |
0 |
if (items != 1) croak("Usage: file_readdir($path)"); |
|
4509
|
0 |
0 |
if (items != 1) croak("Usage: file_slurp_raw($path)"); |
|
4519
|
0 |
0 |
if (items != 2) croak("Usage: file_copy($src, $dst)"); |
|
4522
|
0 |
0 |
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4530
|
0 |
0 |
if (items != 2) croak("Usage: file_move($src, $dst)"); |
|
4533
|
0 |
0 |
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4541
|
0 |
0 |
if (items != 2) croak("Usage: file_chmod($path, $mode)"); |
|
4544
|
0 |
0 |
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4551
|
0 |
0 |
if (items != 2) croak("Usage: file_append($path, $data)"); |
|
4553
|
0 |
0 |
ST(0) = file_append_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4560
|
0 |
0 |
if (items != 2) croak("Usage: file_atomic_spew($path, $data)"); |
|
4562
|
0 |
0 |
ST(0) = file_atomic_spew_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4615
|
78 |
23 |
if (e->args == 1) { |
|
4624
|
90 |
3 |
for (i = 0; import_funcs[i].name != NULL; i++) { |
|
4636
|
23 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
23 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
23 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
23 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
23 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
23 |
pkg = CopSTASHPV(PL_curcop); |
|
4639
|
17 |
6 |
if (items <= 1) { |
|
4644
|
14 |
3 |
for (i = 1; i < items; i++) { |
|
4649
|
5 |
9 |
if ((len == 4 && strEQ(arg, ":all")) || |
|
|
4 |
1 |
if ((len == 4 && strEQ(arg, ":all")) || |
|
4650
|
4 |
9 |
(len == 6 && strEQ(arg, "import"))) { |
|
|
2 |
2 |
(len == 6 && strEQ(arg, "import"))) { |
|
4656
|
188 |
0 |
for (j = 0; import_funcs[j].name != NULL; j++) { |
|
4657
|
11 |
177 |
if (strEQ(arg, import_funcs[j].name)) { |
|
4664
|
0 |
11 |
if (import_funcs[j].name == NULL) { |