| line |
true |
false |
branch |
|
145
|
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) { |
|
150
|
32 |
206 |
if (stat(path, st) < 0) { |
|
157
|
206 |
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
|
10 |
14 |
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
|
170 |
0 |
if (!OpHAS_SIBLING(pushop)) { |
|
958
|
170 |
0 |
argop = OpSIBLING(pushop); |
|
959
|
0 |
170 |
if (!argop) return entersubop; |
|
961
|
169 |
1 |
cvop = OpSIBLING(argop); |
|
962
|
1 |
169 |
if (!cvop) return entersubop; |
|
965
|
169 |
0 |
if (OpSIBLING(argop) != cvop) return entersubop; |
|
|
0 |
169 |
if (OpSIBLING(argop) != cvop) return entersubop; |
|
994
|
46 |
0 |
if (!OpHAS_SIBLING(pushop)) { |
|
999
|
46 |
0 |
pathop = OpSIBLING(pushop); |
|
1000
|
0 |
46 |
if (!pathop) return entersubop; |
|
1002
|
46 |
0 |
dataop = OpSIBLING(pathop); |
|
1003
|
0 |
46 |
if (!dataop) return entersubop; |
|
1005
|
46 |
0 |
cvop = OpSIBLING(dataop); |
|
1006
|
0 |
46 |
if (!cvop) return entersubop; |
|
1009
|
46 |
0 |
if (OpSIBLING(dataop) != cvop) return entersubop; |
|
|
0 |
46 |
if (OpSIBLING(dataop) != cvop) return entersubop; |
|
1117
|
0 |
18 |
if (file_initialized) return; |
|
1120
|
0 |
18 |
Newxz(g_mmaps, g_mmaps_size, MmapEntry); |
|
1122
|
0 |
18 |
Newxz(g_free_mmaps, g_free_mmaps_size, IV); |
|
1125
|
0 |
18 |
Newxz(g_iters, g_iters_size, LineIterEntry); |
|
1127
|
0 |
18 |
Newxz(g_free_iters, g_free_iters_size, IV); |
|
1159
|
2 |
42 |
if (fd < 0 && errno == EPERM) { |
|
|
0 |
2 |
if (fd < 0 && errno == EPERM) { |
|
1163
|
2 |
42 |
if (fd < 0) { |
|
1167
|
0 |
42 |
if (fstat(fd, &st) < 0) { |
|
1176
|
42 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
|
37 |
5 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
1179
|
0 |
37 |
if (st.st_size >= MMAP_SLURP_THRESHOLD) { |
|
1181
|
0 |
0 |
if (map != MAP_FAILED) { |
|
1206
|
37 |
37 |
while (total < st.st_size) { |
|
1208
|
0 |
37 |
if (n < 0) { |
|
1209
|
0 |
0 |
if (errno == EINTR) continue; |
|
1214
|
0 |
37 |
if (n == 0) break; |
|
1228
|
0 |
5 |
if (total >= (ssize_t)capacity - 1) { |
|
1230
|
0 |
0 |
SvGROW(result, capacity); |
|
|
0 |
0 |
SvGROW(result, capacity); |
|
1235
|
0 |
5 |
if (n < 0) { |
|
1236
|
0 |
0 |
if (errno == EINTR) continue; |
|
1241
|
5 |
0 |
if (n == 0) break; |
|
1253
|
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]) { |
|
1255
|
0 |
9 |
if (!hooked) { |
|
1259
|
9 |
0 |
if (hooked != result) { |
|
1291
|
0 |
3 |
if (fd < 0 && errno == EPERM) { |
|
|
0 |
0 |
if (fd < 0 && errno == EPERM) { |
|
1295
|
0 |
3 |
if (fd < 0) { |
|
1299
|
0 |
3 |
if (fstat(fd, &st) < 0) { |
|
1307
|
3 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
|
3 |
0 |
if (S_ISREG(st.st_mode) && st.st_size > 0) { |
|
1310
|
0 |
3 |
if (st.st_size >= MMAP_SLURP_THRESHOLD) { |
|
1312
|
0 |
0 |
if (map != MAP_FAILED) { |
|
1334
|
3 |
3 |
while (total < st.st_size) { |
|
1336
|
0 |
3 |
if (n < 0) { |
|
1337
|
0 |
0 |
if (errno == EINTR) continue; |
|
1342
|
0 |
3 |
if (n == 0) break; |
|
1355
|
0 |
0 |
if (total >= (ssize_t)capacity - 1) { |
|
1357
|
0 |
0 |
SvGROW(result, capacity); |
|
|
0 |
0 |
SvGROW(result, capacity); |
|
1362
|
0 |
0 |
if (n < 0) { |
|
1363
|
0 |
0 |
if (errno == EINTR) continue; |
|
1368
|
0 |
0 |
if (n == 0) break; |
|
1402
|
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])) { |
|
1404
|
0 |
5 |
if (!hooked) { |
|
1407
|
5 |
0 |
if (hooked != data) { |
|
1416
|
0 |
156 |
if (UNLIKELY(fd < 0)) { |
|
1417
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1423
|
4 |
152 |
if (len >= 65536) { |
|
1430
|
156 |
0 |
if (LIKELY(n == (ssize_t)len)) { |
|
1432
|
5 |
151 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1434
|
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) { |
|
1441
|
0 |
0 |
if (n < 0) { |
|
1442
|
0 |
0 |
if (errno != EINTR) { |
|
1444
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1453
|
0 |
0 |
while ((size_t)written < len) { |
|
1455
|
0 |
0 |
if (n < 0) { |
|
1456
|
0 |
0 |
if (errno == EINTR) continue; |
|
1458
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1466
|
0 |
0 |
if (free_write_data) SvREFCNT_dec(write_data); |
|
1468
|
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) { |
|
1492
|
0 |
4 |
if (UNLIKELY(fd < 0)) { |
|
1498
|
4 |
0 |
if (LIKELY(n == (ssize_t)len)) { |
|
1501
|
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) { |
|
1508
|
0 |
0 |
if (n < 0) { |
|
1509
|
0 |
0 |
if (errno != EINTR) { |
|
1519
|
0 |
0 |
while ((size_t)written < len) { |
|
1521
|
0 |
0 |
if (n < 0) { |
|
1522
|
0 |
0 |
if (errno == EINTR) continue; |
|
1532
|
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) { |
|
1543
|
0 |
4 |
if (needed >= g_mmaps_size) { |
|
1544
|
0 |
0 |
IV new_size = g_mmaps_size ? g_mmaps_size * 2 : 16; |
|
1546
|
0 |
0 |
while (new_size <= needed) new_size *= 2; |
|
1547
|
0 |
0 |
Renew(g_mmaps, new_size, MmapEntry); |
|
1548
|
0 |
0 |
for (i = g_mmaps_size; i < new_size; i++) { |
|
1566
|
10 |
4 |
if (g_free_mmaps_count > 0) { |
|
1579
|
14 |
0 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1595
|
14 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
|
14 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
1598
|
14 |
0 |
if (entry->fd >= 0) { |
|
1607
|
0 |
14 |
if (g_free_mmaps_count >= g_free_mmaps_size) { |
|
1609
|
0 |
0 |
Renew(g_free_mmaps, g_free_mmaps_size, IV); |
|
1669
|
1 |
15 |
int flags = writable ? O_RDWR : O_RDONLY; |
|
1670
|
1 |
15 |
int prot = writable ? (PROT_READ | PROT_WRITE) : PROT_READ; |
|
1673
|
1 |
15 |
if (fd < 0) { |
|
1677
|
0 |
15 |
if (fstat(fd, &st) < 0) { |
|
1682
|
1 |
14 |
if (st.st_size == 0) { |
|
1691
|
0 |
14 |
if (addr == MAP_FAILED) { |
|
1710
|
14 |
0 |
if (idx < 0 || idx >= g_mmaps_count) { |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) { |
|
1720
|
14 |
0 |
if (!entry->addr || entry->addr == MAP_FAILED) { |
|
|
0 |
14 |
if (!entry->addr || entry->addr == MAP_FAILED) { |
|
1727
|
14 |
0 |
SvUPGRADE(sv, SVt_PV); |
|
1739
|
14 |
2 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
14 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1743
|
14 |
0 |
if (entry->refcount <= 0) { |
|
1752
|
2 |
0 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
|
0 |
2 |
if (idx < 0 || idx >= g_mmaps_count) return; |
|
1760
|
2 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
|
2 |
0 |
if (entry->addr && entry->addr != MAP_FAILED) { |
|
1771
|
0 |
7 |
if (needed >= g_iters_size) { |
|
1772
|
0 |
0 |
IV new_size = g_iters_size ? g_iters_size * 2 : 16; |
|
1774
|
0 |
0 |
while (new_size <= needed) new_size *= 2; |
|
1775
|
0 |
0 |
Renew(g_iters, new_size, LineIterEntry); |
|
1776
|
0 |
0 |
for (i = g_iters_size; i < new_size; i++) { |
|
1793
|
51 |
7 |
if (g_free_iters_count > 0) { |
|
1806
|
57 |
0 |
if (idx < 0 || idx >= g_iters_count) return; |
|
|
0 |
57 |
if (idx < 0 || idx >= g_iters_count) return; |
|
1809
|
57 |
0 |
if (entry->fd >= 0) { |
|
1812
|
57 |
0 |
if (entry->buffer) { |
|
1815
|
57 |
0 |
if (entry->path) { |
|
1828
|
0 |
57 |
if (g_free_iters_count >= g_free_iters_size) { |
|
1830
|
0 |
0 |
Renew(g_free_iters, g_free_iters_size, IV); |
|
1847
|
4 |
58 |
if (fd < 0) { |
|
1877
|
1291 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
|
0 |
1291 |
if (idx < 0 || idx >= g_iters_count) { |
|
1882
|
0 |
1291 |
if (entry->fd < 0) { |
|
1888
|
1268 |
84 |
if (entry->buf_pos < entry->buf_len) { |
|
1892
|
1256 |
12 |
if (newline) { |
|
1901
|
35 |
61 |
if (entry->eof) { |
|
1903
|
6 |
29 |
if (entry->buf_pos < entry->buf_len) { |
|
1913
|
26 |
35 |
if (entry->buf_pos > 0) { |
|
1915
|
6 |
20 |
if (remaining > 0) { |
|
1923
|
0 |
61 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
1931
|
0 |
61 |
if (n < 0) { |
|
1932
|
0 |
0 |
if (errno == EINTR) continue; |
|
1935
|
29 |
32 |
if (n == 0) { |
|
1947
|
0 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
|
0 |
0 |
if (idx < 0 || idx >= g_iters_count) { |
|
1952
|
0 |
0 |
return entry->eof && entry->buf_pos >= entry->buf_len; |
|
|
0 |
0 |
return entry->eof && entry->buf_pos >= entry->buf_len; |
|
1957
|
57 |
1 |
if (idx < 0 || idx >= g_iters_count) return; |
|
|
0 |
57 |
if (idx < 0 || idx >= g_iters_count) return; |
|
1961
|
57 |
0 |
if (entry->refcount <= 0) { |
|
1973
|
2 |
63 |
if (cached_stat(path, &st) < 0) { |
|
1988
|
2 |
31 |
if (cached_stat(path, &st) < 0) return 0; |
|
1995
|
7 |
31 |
if (cached_stat(path, &st) < 0) return 0; |
|
2012
|
1 |
30 |
if (cached_stat(path, &st) < 0) { |
|
2021
|
1 |
7 |
if (cached_stat(path, &st) < 0) { |
|
2030
|
1 |
7 |
if (cached_stat(path, &st) < 0) { |
|
2039
|
1 |
4 |
if (cached_stat(path, &st) < 0) { |
|
2050
|
1 |
3 |
if (cached_stat(path, &st) < 0) { |
|
2060
|
2 |
1 |
hv_store(result, "is_file", 7, S_ISREG(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0); |
|
2061
|
1 |
2 |
hv_store(result, "is_dir", 6, S_ISDIR(st.st_mode) ? &PL_sv_yes : &PL_sv_no, 0); |
|
2080
|
1 |
9 |
if (lstat(path, &st) < 0) return 0; |
|
2115
|
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) { |
|
2140
|
1 |
3 |
if (fd_src < 0) return 0; |
|
2142
|
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)) { |
|
2148
|
0 |
3 |
if (fd_dst < 0) { |
|
2154
|
2 |
3 |
while (offset < st.st_size) { |
|
2156
|
0 |
2 |
if (sent < 0) { |
|
2157
|
0 |
0 |
if (errno == EINTR) continue; |
|
2158
|
0 |
0 |
if (errno == EINVAL || errno == ENOSYS) { |
|
|
0 |
0 |
if (errno == EINVAL || errno == ENOSYS) { |
|
2170
|
0 |
0 |
if (n_read < 0) { |
|
2171
|
0 |
0 |
if (errno == EINTR) continue; |
|
2174
|
0 |
0 |
if (n_read == 0) { result = 1; break; } |
|
2177
|
0 |
0 |
while (written < n_read) { |
|
2179
|
0 |
0 |
if (n_written < 0) { |
|
2180
|
0 |
0 |
if (errno == EINTR) continue; |
|
2190
|
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) { |
|
2199
|
0 |
2 |
if (sent == 0) break; |
|
2205
|
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) { |
|
2276
|
2 |
1 |
if (rename(src, dst) == 0) { |
|
2280
|
0 |
1 |
else if (errno == EXDEV) { |
|
2281
|
0 |
0 |
if (file_copy_internal(aTHX_ src, dst)) { |
|
2291
|
1 |
1 |
if (g_stat_cache.valid) { |
|
2292
|
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) { |
|
2322
|
1 |
2 |
if (utime(path, NULL) == 0) { |
|
2327
|
0 |
2 |
if (fd < 0) { |
|
2335
|
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) { |
|
2350
|
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) { |
|
2366
|
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) { |
|
2381
|
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) { |
|
2425
|
2 |
5 |
if (!dir) return result; |
|
2427
|
27 |
5 |
while ((entry = readdir(dir)) != NULL) { |
|
2429
|
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) { |
|
2448
|
2 |
81 |
if (len == 0) return newSVpvs(""); |
|
2451
|
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] == '\\')) { |
|
2454
|
3 |
78 |
if (len == 0) return newSVpvs(""); |
|
2458
|
732 |
3 |
while (p > path && *p != '/' && *p != '\\') { |
|
|
657 |
75 |
while (p > path && *p != '/' && *p != '\\') { |
|
|
657 |
0 |
while (p > path && *p != '/' && *p != '\\') { |
|
2461
|
3 |
75 |
if (*p == '/' || *p == '\\') p++; |
|
|
0 |
3 |
if (*p == '/' || *p == '\\') p++; |
|
2470
|
1 |
19 |
if (len == 0) return newSVpvs("."); |
|
2474
|
19 |
2 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
|
2 |
17 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
|
0 |
17 |
while (end > path && (*end == '/' || *end == '\\')) { |
|
2479
|
131 |
6 |
while (end > path && *end != '/' && *end != '\\') { |
|
|
118 |
13 |
while (end > path && *end != '/' && *end != '\\') { |
|
|
118 |
0 |
while (end > path && *end != '/' && *end != '\\') { |
|
2483
|
6 |
13 |
if (end == path) { |
|
2484
|
2 |
4 |
if (*end == '/' || *end == '\\') { |
|
|
0 |
2 |
if (*end == '/' || *end == '\\') { |
|
2491
|
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) == '\\')) { |
|
2503
|
1 |
48 |
if (len == 0) return newSVpvs(""); |
|
2507
|
440 |
12 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
|
404 |
36 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
|
404 |
0 |
while (basename > path && *basename != '/' && *basename != '\\') { |
|
2510
|
12 |
36 |
if (*basename == '/' || *basename == '\\') basename++; |
|
|
0 |
12 |
if (*basename == '/' || *basename == '\\') basename++; |
|
2514
|
44 |
4 |
if (!dot || dot == basename) return newSVpvs(""); |
|
|
2 |
42 |
if (!dot || dot == basename) return newSVpvs(""); |
|
2527
|
0 |
12 |
if (len == 0) return newSVpvs(""); |
|
2530
|
28 |
12 |
for (i = 0; i < len; i++) { |
|
2532
|
28 |
0 |
if (sv && SvPOK(*sv)) { |
|
|
28 |
0 |
if (sv && SvPOK(*sv)) { |
|
2543
|
28 |
12 |
for (i = 0; i < len; i++) { |
|
2545
|
28 |
0 |
if (sv && SvPOK(*sv)) { |
|
|
28 |
0 |
if (sv && SvPOK(*sv)) { |
|
2549
|
1 |
27 |
if (part_len == 0) continue; |
|
2552
|
29 |
0 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
|
9 |
20 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
|
0 |
20 |
while (part_len > 0 && (*part == '/' || *part == '\\')) { |
|
2553
|
9 |
0 |
if (!need_sep && p == buf) break; /* Keep root slash */ |
|
|
7 |
2 |
if (!need_sep && p == buf) break; /* Keep root slash */ |
|
2558
|
12 |
15 |
if (need_sep && part_len > 0) { |
|
|
12 |
0 |
if (need_sep && part_len > 0) { |
|
2566
|
27 |
0 |
if (part_len > 0) { |
|
2571
|
24 |
3 |
need_sep = (*(p-1) != '/' && *(p-1) != '\\'); |
|
|
24 |
0 |
need_sep = (*(p-1) != '/' && *(p-1) != '\\'); |
|
2591
|
1 |
5 |
if (n <= 0) return result; |
|
2594
|
1 |
4 |
if (idx < 0) return result; |
|
2596
|
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) { |
|
2612
|
1 |
5 |
if (n <= 0) return result; |
|
2615
|
1 |
4 |
if (idx < 0) return result; |
|
2621
|
43 |
4 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
2622
|
25 |
18 |
if (av_len(buffer) + 1 >= n) { |
|
2633
|
18 |
4 |
for (i = 0; i < buf_len; i++) { |
|
2635
|
18 |
0 |
if (sv) { |
|
2669
|
0 |
14 |
if (fd < 0) { |
|
2673
|
13 |
14 |
while ((size_t)written < len) { |
|
2675
|
0 |
13 |
if (n < 0) { |
|
2676
|
0 |
0 |
if (errno == EINTR) continue; |
|
2695
|
0 |
14 |
if (rename(temp_path, path) != 0) { |
|
2701
|
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) { |
|
2720
|
14 |
2 |
while (start < end) { |
|
2722
|
10 |
4 |
if (p) { |
|
2726
|
4 |
0 |
if (start < end) { |
|
2744
|
0 |
29 |
if (items != 1) croak("Usage: file::slurp(path)"); |
|
2755
|
0 |
2 |
if (items != 1) croak("Usage: file::slurp_raw(path)"); |
|
2766
|
0 |
85 |
if (items != 2) croak("Usage: file::spew(path, data)"); |
|
2769
|
85 |
0 |
if (file_spew_internal(aTHX_ path, ST(1))) { |
|
2781
|
0 |
2 |
if (items != 2) croak("Usage: file::append(path, data)"); |
|
2784
|
2 |
0 |
if (file_append_internal(aTHX_ path, ST(1))) { |
|
2797
|
0 |
11 |
if (items != 1) croak("Usage: file::size(path)"); |
|
2810
|
0 |
4 |
if (items != 1) croak("Usage: file::mtime(path)"); |
|
2822
|
0 |
21 |
if (items != 1) croak("Usage: file::exists(path)"); |
|
2825
|
14 |
7 |
ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2833
|
0 |
4 |
if (items != 1) croak("Usage: file::is_file(path)"); |
|
2836
|
3 |
1 |
ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2844
|
0 |
7 |
if (items != 1) croak("Usage: file::is_dir(path)"); |
|
2847
|
4 |
3 |
ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2855
|
0 |
2 |
if (items != 1) croak("Usage: file::is_readable(path)"); |
|
2858
|
1 |
1 |
ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2866
|
0 |
3 |
if (items != 1) croak("Usage: file::is_writable(path)"); |
|
2869
|
2 |
1 |
ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
2889
|
0 |
7 |
if (items != 1) croak("Usage: file::lines(path)"); |
|
2894
|
1 |
6 |
if (UNLIKELY(fd < 0)) { |
|
2900
|
6 |
0 |
if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) { |
|
|
1 |
5 |
if (UNLIKELY(fstat(fd, &st) < 0 || st.st_size == 0)) { |
|
2911
|
5 |
5 |
while ((size_t)total_read < file_size) { |
|
2913
|
0 |
5 |
if (UNLIKELY(n < 0)) { |
|
2914
|
0 |
0 |
if (errno == EINTR) continue; |
|
2917
|
0 |
5 |
if (n == 0) break; |
|
2922
|
0 |
5 |
if (UNLIKELY(total_read == 0)) { |
|
2937
|
15 |
0 |
while (p < end) { |
|
2939
|
10 |
5 |
if (LIKELY(p != NULL)) { |
|
2945
|
5 |
0 |
if (line_start < end) { |
|
2965
|
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])"); |
|
2968
|
1 |
15 |
writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0; |
|
|
1 |
0 |
writable = (items > 1 && SvTRUE(ST(1))) ? 1 : 0; |
|
2971
|
2 |
14 |
if (idx < 0) { |
|
2990
|
0 |
14 |
if (items != 1) croak("Usage: $mmap->data"); |
|
2992
|
14 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
14 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
2998
|
14 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3010
|
0 |
2 |
if (items != 1) croak("Usage: $mmap->sync"); |
|
3012
|
2 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
2 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3018
|
2 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3030
|
0 |
16 |
if (items != 1) croak("Usage: $mmap->close"); |
|
3032
|
16 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
16 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3038
|
16 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3053
|
0 |
14 |
if (PL_dirty) XSRETURN_EMPTY; |
|
3055
|
14 |
0 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
|
0 |
14 |
if (!SvROK(ST(0)) || SvTYPE(SvRV(ST(0))) != SVt_PVHV) { |
|
3061
|
14 |
0 |
idx = idx_sv ? SvIV(*idx_sv) : -1; |
|
3063
|
0 |
14 |
if (idx >= 0) { |
|
3075
|
0 |
18 |
if (items != 1) croak("Usage: file::lines_iter(path)"); |
|
3080
|
1 |
17 |
if (idx < 0) { |
|
3102
|
0 |
153 |
if (items != 1) croak("Usage: $iter->next"); |
|
3105
|
0 |
153 |
if (UNLIKELY(!SvROK(rv))) { |
|
3112
|
153 |
0 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
|
0 |
153 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
3118
|
0 |
153 |
if (UNLIKELY(entry->fd < 0)) { |
|
3126
|
163 |
22 |
if (entry->buf_pos < entry->buf_len) { |
|
3130
|
139 |
24 |
if (newline) { |
|
3140
|
14 |
32 |
if (entry->eof) { |
|
3142
|
11 |
3 |
if (entry->buf_pos < entry->buf_len) { |
|
3154
|
12 |
20 |
if (entry->buf_pos > 0) { |
|
3156
|
10 |
2 |
if (remaining > 0) { |
|
3164
|
1 |
31 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
3172
|
0 |
32 |
if (n < 0) { |
|
3173
|
0 |
0 |
if (errno == EINTR) continue; |
|
3177
|
14 |
18 |
if (n == 0) { |
|
3191
|
0 |
123 |
if (items != 1) croak("Usage: $iter->eof"); |
|
3194
|
0 |
123 |
if (UNLIKELY(!SvROK(rv))) { |
|
3201
|
123 |
0 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
|
0 |
123 |
if (UNLIKELY(idx < 0 || idx >= g_iters_count)) { |
|
3207
|
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; |
|
3216
|
0 |
18 |
if (items != 1) croak("Usage: $iter->close"); |
|
3219
|
0 |
18 |
if (UNLIKELY(!SvROK(rv))) { |
|
3238
|
0 |
17 |
if (PL_dirty) XSRETURN_EMPTY; |
|
3241
|
0 |
17 |
if (UNLIKELY(!SvROK(rv))) { |
|
3247
|
0 |
17 |
if (idx >= 0) { |
|
3275
|
50 |
10 |
for (i = 0; i < len; i++) { |
|
3276
|
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') { |
|
3299
|
27 |
6 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
|
9 |
18 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
|
0 |
18 |
while (len > 0 && (*s == ' ' || *s == '\t')) { |
|
3303
|
18 |
6 |
return len > 0 && *s == '#'; |
|
|
5 |
13 |
return len > 0 && *s == '#'; |
|
3317
|
18 |
0 |
if (PL_dirty) { |
|
3330
|
3 |
18 |
if (g_file_callback_registry) return; |
|
3385
|
0 |
17 |
if (!g_file_callback_registry) return NULL; |
|
3387
|
14 |
3 |
if (svp && SvIOK(*svp)) { |
|
|
14 |
0 |
if (svp && SvIOK(*svp)) { |
|
3414
|
0 |
7 |
if (items != 2) croak("Usage: file::each_line(path, callback)"); |
|
3419
|
7 |
0 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
|
0 |
7 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
3425
|
1 |
6 |
if (idx < 0) { |
|
3431
|
6 |
0 |
old_defsv = DEFSV; |
|
3433
|
6 |
0 |
DEFSV = line_sv; |
|
3436
|
0 |
6 |
PUSH_MULTICALL(block_cv); |
|
3441
|
1024 |
9 |
if (entry->buf_pos < entry->buf_len) { |
|
3445
|
1018 |
6 |
if (newline) { |
|
3459
|
5 |
10 |
if (entry->eof) { |
|
3461
|
3 |
2 |
if (entry->buf_pos < entry->buf_len) { |
|
3475
|
4 |
6 |
if (entry->buf_pos > 0) { |
|
3477
|
3 |
1 |
if (remaining > 0) { |
|
3485
|
0 |
10 |
if (entry->buf_len >= entry->buf_size - 1) { |
|
3493
|
0 |
10 |
if (n < 0) { |
|
3494
|
0 |
0 |
if (errno == EINTR) continue; |
|
3497
|
5 |
5 |
if (n == 0) { |
|
3505
|
5 |
0 |
POP_MULTICALL; |
|
3508
|
5 |
0 |
DEFSV = old_defsv; |
|
3524
|
0 |
17 |
if (items != 2) croak("Usage: file::grep_lines(path, &predicate or $name)"); |
|
3531
|
5 |
12 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
5 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3536
|
1 |
11 |
if (!fcb) { |
|
3542
|
0 |
16 |
if (idx < 0) { |
|
3548
|
11 |
5 |
if (fcb && fcb->predicate) { |
|
|
8 |
3 |
if (fcb && fcb->predicate) { |
|
3549
|
72 |
8 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3550
|
41 |
31 |
if (fcb->predicate(aTHX_ line)) { |
|
3563
|
3 |
5 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3564
|
1057 |
8 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3569
|
0 |
1057 |
PUSHMARK(SP); |
|
3570
|
0 |
1057 |
XPUSHs(line); |
|
3574
|
1057 |
0 |
if (count > 0) { |
|
3579
|
26 |
1031 |
if (matches) { |
|
3603
|
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])"); |
|
3608
|
4 |
2 |
if (items == 1) { |
|
3620
|
1 |
3 |
if (UNLIKELY(fd < 0)) { |
|
3628
|
2 |
3 |
while ((n = read(fd, buffer, FILE_BUFFER_SIZE)) > 0) { |
|
3631
|
1008 |
2 |
while ((p = memchr(p, '\n', end - p)) != NULL) { |
|
3642
|
2 |
1 |
if (total_read > 0 && last_char != '\n') { |
|
|
1 |
1 |
if (total_read > 0 && last_char != '\n') { |
|
3653
|
1 |
1 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
1 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3658
|
0 |
1 |
if (!fcb) { |
|
3664
|
0 |
2 |
if (idx < 0) { |
|
3670
|
1 |
1 |
if (fcb && fcb->predicate) { |
|
|
1 |
0 |
if (fcb && fcb->predicate) { |
|
3671
|
9 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3672
|
7 |
2 |
if (fcb->predicate(aTHX_ line)) { |
|
3684
|
0 |
1 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3685
|
9 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3690
|
0 |
9 |
PUSHMARK(SP); |
|
3691
|
0 |
9 |
XPUSHs(line); |
|
3695
|
9 |
0 |
if (n > 0) { |
|
3700
|
8 |
1 |
if (matches) { |
|
3722
|
0 |
5 |
if (items != 2) croak("Usage: file::find_line(path, &predicate or $name)"); |
|
3728
|
4 |
1 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
|
4 |
0 |
if (SvROK(predicate) && SvTYPE(SvRV(predicate)) == SVt_PVCV) { |
|
3733
|
0 |
1 |
if (!fcb) { |
|
3739
|
0 |
5 |
if (idx < 0) { |
|
3744
|
1 |
4 |
if (fcb && fcb->predicate) { |
|
|
1 |
0 |
if (fcb && fcb->predicate) { |
|
3745
|
6 |
0 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3746
|
1 |
5 |
if (fcb->predicate(aTHX_ line)) { |
|
3759
|
0 |
4 |
SV *cb_sv = fcb ? fcb->perl_callback : (SV*)block_cv; |
|
3760
|
21 |
1 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3765
|
0 |
21 |
PUSHMARK(SP); |
|
3766
|
0 |
21 |
XPUSHs(line); |
|
3770
|
21 |
0 |
if (n > 0) { |
|
3775
|
3 |
18 |
if (matches) { |
|
3796
|
0 |
4 |
if (items != 2) croak("Usage: file::map_lines(path, &callback)"); |
|
3802
|
4 |
0 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
|
0 |
4 |
if (!SvROK(callback) || SvTYPE(SvRV(callback)) != SVt_PVCV) { |
|
3807
|
0 |
4 |
if (idx < 0) { |
|
3814
|
27 |
4 |
while ((line = file_lines_next(aTHX_ idx)) != &PL_sv_undef) { |
|
3818
|
0 |
27 |
PUSHMARK(SP); |
|
3819
|
0 |
27 |
XPUSHs(sv_2mortal(line)); |
|
3823
|
27 |
0 |
if (count > 0) { |
|
3845
|
0 |
4 |
if (items != 2) croak("Usage: file::register_line_callback($name, \\&coderef)"); |
|
3850
|
3 |
1 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
3 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3859
|
1 |
2 |
if (existing) { |
|
3861
|
1 |
0 |
if (existing->perl_callback) { |
|
3889
|
1 |
0 |
if (g_file_callback_registry) { |
|
3891
|
14 |
1 |
while ((entry = hv_iternext(g_file_callback_registry))) { |
|
3910
|
0 |
11 |
if (items != 1) croak("Usage: file::register_read_hook(\\&coderef)"); |
|
3913
|
11 |
0 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
11 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3936
|
0 |
4 |
if (items != 1) croak("Usage: file::register_write_hook(\\&coderef)"); |
|
3939
|
4 |
0 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
|
0 |
4 |
if (!SvROK(coderef) || SvTYPE(SvRV(coderef)) != SVt_PVCV) { |
|
3963
|
0 |
40 |
if (items != 1) croak("Usage: file::clear_hooks($phase)"); |
|
3967
|
26 |
14 |
if (strcmp(phase_name, "read") == 0) { |
|
3971
|
14 |
0 |
} else if (strcmp(phase_name, "write") == 0) { |
|
3975
|
0 |
0 |
} else if (strcmp(phase_name, "open") == 0) { |
|
3977
|
0 |
0 |
} else if (strcmp(phase_name, "close") == 0) { |
|
3985
|
15 |
40 |
while (entry) { |
|
3987
|
15 |
0 |
if (entry->perl_callback) { |
|
4005
|
0 |
11 |
if (items != 1) croak("Usage: file::has_hooks($phase)"); |
|
4009
|
6 |
5 |
if (strcmp(phase_name, "read") == 0) { |
|
4011
|
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); |
|
4012
|
5 |
0 |
} else if (strcmp(phase_name, "write") == 0) { |
|
4014
|
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); |
|
4015
|
0 |
0 |
} else if (strcmp(phase_name, "open") == 0) { |
|
4018
|
0 |
0 |
} else if (strcmp(phase_name, "close") == 0) { |
|
4025
|
7 |
4 |
ST(0) = has ? &PL_sv_yes : &PL_sv_no; |
|
4033
|
0 |
2 |
if (items != 1) croak("Usage: file::atime(path)"); |
|
4042
|
0 |
2 |
if (items != 1) croak("Usage: file::ctime(path)"); |
|
4051
|
0 |
2 |
if (items != 1) croak("Usage: file::mode(path)"); |
|
4062
|
0 |
4 |
if (items != 1) croak("Usage: File::Raw::stat(path)"); |
|
4065
|
1 |
3 |
if (result == NULL) { |
|
4076
|
0 |
4 |
if (items != 1) croak("Usage: file::is_link(path)"); |
|
4078
|
1 |
3 |
ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4085
|
0 |
0 |
if (items != 1) croak("Usage: file::is_executable(path)"); |
|
4087
|
0 |
0 |
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4095
|
0 |
4 |
if (items != 1) croak("Usage: file::unlink(path)"); |
|
4097
|
2 |
2 |
ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4105
|
0 |
3 |
if (items != 2) croak("Usage: file::copy(src, dst)"); |
|
4108
|
2 |
1 |
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4116
|
0 |
3 |
if (items != 2) croak("Usage: file::move(src, dst)"); |
|
4119
|
2 |
1 |
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4126
|
0 |
2 |
if (items != 1) croak("Usage: file::touch(path)"); |
|
4128
|
2 |
0 |
ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4134
|
0 |
1 |
if (items > 1) croak("Usage: file::clear_stat_cache() or file::clear_stat_cache(path)"); |
|
4136
|
0 |
1 |
if (items == 1 && SvOK(ST(0))) { |
|
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
4151
|
0 |
1 |
if (items != 2) croak("Usage: file::chmod(path, mode)"); |
|
4154
|
1 |
0 |
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4162
|
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])"); |
|
4164
|
0 |
12 |
if (items > 1) mode = SvIV(ST(1)); |
|
4165
|
8 |
4 |
ST(0) = file_mkdir_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4172
|
0 |
6 |
if (items != 1) croak("Usage: file::rmdir(path)"); |
|
4174
|
2 |
4 |
ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4182
|
0 |
5 |
if (items != 1) croak("Usage: file::readdir(path)"); |
|
4193
|
0 |
12 |
if (items != 1) croak("Usage: file::basename(path)"); |
|
4202
|
0 |
10 |
if (items != 1) croak("Usage: file::dirname(path)"); |
|
4211
|
0 |
13 |
if (items != 1) croak("Usage: file::extname(path)"); |
|
4222
|
0 |
11 |
if (items < 1) croak("Usage: file::join(part1, part2, ...)"); |
|
4225
|
26 |
11 |
for (i = 0; i < items; i++) { |
|
4243
|
0 |
1 |
if (items != 1) croak("Usage: file_mkpath(path)"); |
|
4245
|
0 |
1 |
if (path_len >= sizeof(buf)) croak("Path too long"); |
|
4247
|
35 |
1 |
for (i = 0; i <= path_len; i++) { |
|
4248
|
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] == '\\') { |
|
4249
|
1 |
4 |
if (i == 0) { |
|
4259
|
0 |
4 |
if (i == 2 && buf[1] == ':') continue; |
|
|
0 |
0 |
if (i == 2 && buf[1] == ':') continue; |
|
4261
|
2 |
2 |
if (!file_is_dir_internal(buf)) { |
|
4262
|
2 |
0 |
if (file_mkdir_internal(buf, 0755)) |
|
4268
|
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; |
|
4277
|
0 |
2 |
if (!file_is_dir_internal(path)) { |
|
4284
|
1 |
2 |
for (i = 0; i < len; i++) { |
|
4286
|
1 |
0 |
if (sv) { |
|
4296
|
1 |
0 |
if (file_is_dir_internal(child)) { |
|
4314
|
0 |
1 |
if (items != 1) croak("Usage: file_rm_rf(path)"); |
|
4327
|
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])"); |
|
4329
|
4 |
2 |
if (items > 1) n = SvIV(ST(1)); |
|
4340
|
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])"); |
|
4342
|
4 |
2 |
if (items > 1) n = SvIV(ST(1)); |
|
4352
|
0 |
14 |
if (items != 2) croak("Usage: file::atomic_spew(path, data)"); |
|
4354
|
14 |
0 |
ST(0) = file_atomic_spew_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4365
|
0 |
0 |
if (items != 1) croak("Usage: file_slurp($path)"); |
|
4374
|
0 |
0 |
if (items != 2) croak("Usage: file_spew($path, $data)"); |
|
4376
|
0 |
0 |
if (file_spew_internal(aTHX_ path, ST(1))) { |
|
4387
|
0 |
0 |
if (items != 1) croak("Usage: file_exists($path)"); |
|
4389
|
0 |
0 |
ST(0) = file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4396
|
0 |
0 |
if (items != 1) croak("Usage: file_size($path)"); |
|
4405
|
0 |
0 |
if (items != 1) croak("Usage: file_is_file($path)"); |
|
4407
|
0 |
0 |
ST(0) = file_is_file_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4414
|
0 |
0 |
if (items != 1) croak("Usage: file_is_dir($path)"); |
|
4416
|
0 |
0 |
ST(0) = file_is_dir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4425
|
0 |
0 |
if (items != 1) croak("Usage: file_lines($path)"); |
|
4429
|
0 |
0 |
if (content == &PL_sv_undef) { |
|
4443
|
0 |
0 |
if (items != 1) croak("Usage: file_unlink($path)"); |
|
4445
|
0 |
0 |
ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4452
|
0 |
0 |
if (items != 1) croak("Usage: file_mkdir($path)"); |
|
4454
|
0 |
0 |
ST(0) = file_mkdir_internal(path, 0755) ? &PL_sv_yes : &PL_sv_no; |
|
4461
|
0 |
0 |
if (items != 1) croak("Usage: file_rmdir($path)"); |
|
4463
|
0 |
0 |
ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4470
|
0 |
0 |
if (items != 1) croak("Usage: file_touch($path)"); |
|
4472
|
0 |
0 |
ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4478
|
0 |
0 |
if (items > 1) croak("Usage: file_clear_stat_cache() or file_clear_stat_cache($path)"); |
|
4480
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
|
0 |
0 |
if (items == 1 && SvOK(ST(0))) { |
|
4494
|
0 |
0 |
if (items != 1) croak("Usage: file_basename($path)"); |
|
4503
|
0 |
0 |
if (items != 1) croak("Usage: file_dirname($path)"); |
|
4512
|
0 |
0 |
if (items != 1) croak("Usage: file_extname($path)"); |
|
4521
|
0 |
0 |
if (items != 1) croak("Usage: file_mtime($path)"); |
|
4530
|
0 |
0 |
if (items != 1) croak("Usage: file_atime($path)"); |
|
4539
|
0 |
0 |
if (items != 1) croak("Usage: file_ctime($path)"); |
|
4548
|
0 |
0 |
if (items != 1) croak("Usage: file_mode($path)"); |
|
4557
|
0 |
0 |
if (items != 1) croak("Usage: file_is_link($path)"); |
|
4559
|
0 |
0 |
ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4566
|
0 |
0 |
if (items != 1) croak("Usage: file_is_readable($path)"); |
|
4568
|
0 |
0 |
ST(0) = file_is_readable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4575
|
0 |
0 |
if (items != 1) croak("Usage: file_is_writable($path)"); |
|
4577
|
0 |
0 |
ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4584
|
0 |
0 |
if (items != 1) croak("Usage: file_is_executable($path)"); |
|
4586
|
0 |
0 |
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no; |
|
4594
|
0 |
0 |
if (items != 1) croak("Usage: file_readdir($path)"); |
|
4604
|
0 |
0 |
if (items != 1) croak("Usage: file_slurp_raw($path)"); |
|
4614
|
0 |
0 |
if (items != 2) croak("Usage: file_copy($src, $dst)"); |
|
4617
|
0 |
0 |
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4625
|
0 |
0 |
if (items != 2) croak("Usage: file_move($src, $dst)"); |
|
4628
|
0 |
0 |
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no; |
|
4636
|
0 |
0 |
if (items != 2) croak("Usage: file_chmod($path, $mode)"); |
|
4639
|
0 |
0 |
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no; |
|
4646
|
0 |
0 |
if (items != 2) croak("Usage: file_append($path, $data)"); |
|
4648
|
0 |
0 |
ST(0) = file_append_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4655
|
0 |
0 |
if (items != 2) croak("Usage: file_atomic_spew($path, $data)"); |
|
4657
|
0 |
0 |
ST(0) = file_atomic_spew_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no; |
|
4714
|
15 |
132 |
if (e->args == 0) { |
|
4719
|
103 |
29 |
} else if (e->args == 1) { |
|
4728
|
132 |
4 |
for (i = 0; import_funcs[i].name != NULL; i++) { |
|
4740
|
25 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
25 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
25 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
25 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
25 |
0 |
pkg = CopSTASHPV(PL_curcop); |
|
|
0 |
25 |
pkg = CopSTASHPV(PL_curcop); |
|
4743
|
17 |
8 |
if (items <= 1) { |
|
4748
|
19 |
4 |
for (i = 1; i < items; i++) { |
|
4753
|
7 |
12 |
if ((len == 4 && strEQ(arg, ":all")) || |
|
|
5 |
2 |
if ((len == 4 && strEQ(arg, ":all")) || |
|
4754
|
6 |
11 |
(len == 6 && strEQ(arg, "import"))) { |
|
|
2 |
4 |
(len == 6 && strEQ(arg, "import"))) { |
|
4760
|
290 |
0 |
for (j = 0; import_funcs[j].name != NULL; j++) { |
|
4761
|
15 |
275 |
if (strEQ(arg, import_funcs[j].name)) { |
|
4768
|
0 |
15 |
if (import_funcs[j].name == NULL) { |