Ancient
view release on metacpan or search on metacpan
xs/file/file.c view on Meta::CPAN
ENTER;
SAVETMPS;
PUSHMARK(SP);
mXPUSHs(newSVpv(path, 0));
mXPUSHs(SvREFCNT_inc(result));
PUTBACK;
count = call_sv(entry->perl_callback, G_SCALAR);
SPAGAIN;
if (count > 0) {
SV *ret = POPs;
if (SvOK(ret)) {
result = newSVsv(ret);
} else {
ctx.cancel = 1;
}
}
PUTBACK;
FREETMPS;
LEAVE;
}
if (!result || ctx.cancel) return NULL;
}
return result;
}
/* ============================================
Custom op support for compile-time optimization
============================================ */
/* Custom op registrations */
static XOP file_slurp_xop;
static XOP file_spew_xop;
static XOP file_exists_xop;
static XOP file_size_xop;
static XOP file_is_file_xop;
static XOP file_is_dir_xop;
static XOP file_lines_xop;
static XOP file_unlink_xop;
static XOP file_mkdir_xop;
static XOP file_rmdir_xop;
static XOP file_basename_xop;
static XOP file_dirname_xop;
static XOP file_extname_xop;
static XOP file_touch_xop;
static XOP file_mtime_xop;
static XOP file_atime_xop;
static XOP file_ctime_xop;
static XOP file_mode_xop;
static XOP file_is_link_xop;
static XOP file_is_readable_xop;
static XOP file_is_writable_xop;
static XOP file_is_executable_xop;
static XOP file_readdir_xop;
static XOP file_slurp_raw_xop;
static XOP file_copy_xop;
static XOP file_move_xop;
static XOP file_chmod_xop;
static XOP file_append_xop;
static XOP file_atomic_spew_xop;
/* Forward declarations for internal functions */
static SV* file_slurp_internal(pTHX_ const char *path);
static SV* file_slurp_raw_internal(pTHX_ const char *path);
static int file_spew_internal(pTHX_ const char *path, SV *data);
static int file_append_internal(pTHX_ const char *path, SV *data);
static IV file_size_internal(const char *path);
static IV file_mtime_internal(const char *path);
static IV file_atime_internal(const char *path);
static IV file_ctime_internal(const char *path);
static IV file_mode_internal(const char *path);
static int file_exists_internal(const char *path);
static int file_is_file_internal(const char *path);
static int file_is_dir_internal(const char *path);
static int file_is_link_internal(const char *path);
static int file_is_readable_internal(const char *path);
static int file_is_writable_internal(const char *path);
static int file_is_executable_internal(const char *path);
static AV* file_split_lines(pTHX_ SV *content);
static int file_unlink_internal(const char *path);
static int file_copy_internal(pTHX_ const char *src, const char *dst);
static int file_move_internal(pTHX_ const char *src, const char *dst);
static int file_mkdir_internal(const char *path, int mode);
static int file_rmdir_internal(const char *path);
static int file_touch_internal(const char *path);
static int file_chmod_internal(const char *path, int mode);
static AV* file_readdir_internal(pTHX_ const char *path);
static int file_atomic_spew_internal(pTHX_ const char *path, SV *data);
static SV* file_basename_internal(pTHX_ const char *path);
static SV* file_dirname_internal(pTHX_ const char *path);
static SV* file_extname_internal(pTHX_ const char *path);
/* Typedef for pp functions */
typedef OP* (*file_ppfunc)(pTHX);
/* ============================================
Custom OP implementations - fastest path
============================================ */
/* pp_file_slurp: single path arg on stack */
static OP* pp_file_slurp(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
SV *result = file_slurp_internal(aTHX_ path);
PUSHs(sv_2mortal(result));
PUTBACK;
return NORMAL;
}
/* pp_file_spew: path and data on stack */
static OP* pp_file_spew(pTHX) {
dSP;
SV *data = POPs;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
if (file_spew_internal(aTHX_ path, data)) {
PUSHs(&PL_sv_yes);
} else {
PUSHs(&PL_sv_no);
}
PUTBACK;
return NORMAL;
}
/* pp_file_exists: single path arg on stack */
static OP* pp_file_exists(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
PUSHs(file_exists_internal(path) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_size: single path arg on stack */
static OP* pp_file_size(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
PUSHs(sv_2mortal(newSViv(file_size_internal(path))));
PUTBACK;
return NORMAL;
}
/* pp_file_is_file: single path arg on stack */
xs/file/file.c view on Meta::CPAN
PUTBACK;
return NORMAL;
}
/* pp_file_is_executable: single path arg on stack */
static OP* pp_file_is_executable(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
PUSHs(file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_readdir: single path arg on stack */
static OP* pp_file_readdir(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
AV *result = file_readdir_internal(aTHX_ path);
PUSHs(sv_2mortal(newRV_noinc((SV*)result)));
PUTBACK;
return NORMAL;
}
/* pp_file_slurp_raw: single path arg on stack (bypasses hooks) */
static OP* pp_file_slurp_raw(pTHX) {
dSP;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
SV *result = file_slurp_raw_internal(aTHX_ path);
PUSHs(sv_2mortal(result));
PUTBACK;
return NORMAL;
}
/* pp_file_copy: src and dst on stack */
static OP* pp_file_copy(pTHX) {
dSP;
SV *dst_sv = POPs;
SV *src_sv = POPs;
const char *src = SvPV_nolen(src_sv);
const char *dst = SvPV_nolen(dst_sv);
PUSHs(file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_move: src and dst on stack */
static OP* pp_file_move(pTHX) {
dSP;
SV *dst_sv = POPs;
SV *src_sv = POPs;
const char *src = SvPV_nolen(src_sv);
const char *dst = SvPV_nolen(dst_sv);
PUSHs(file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_chmod: path and mode on stack */
static OP* pp_file_chmod(pTHX) {
dSP;
SV *mode_sv = POPs;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
int mode = SvIV(mode_sv);
PUSHs(file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_append: path and data on stack */
static OP* pp_file_append(pTHX) {
dSP;
SV *data = POPs;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
PUSHs(file_append_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* pp_file_atomic_spew: path and data on stack */
static OP* pp_file_atomic_spew(pTHX) {
dSP;
SV *data = POPs;
SV *path_sv = POPs;
const char *path = SvPV_nolen(path_sv);
PUSHs(file_atomic_spew_internal(aTHX_ path, data) ? &PL_sv_yes : &PL_sv_no);
PUTBACK;
return NORMAL;
}
/* ============================================
Call checkers for compile-time optimization
============================================ */
/* 1-arg call checker (slurp, exists, size, is_file, is_dir, lines) */
static OP* file_call_checker_1arg(pTHX_ OP *entersubop, GV *namegv, SV *ckobj) {
file_ppfunc ppfunc = (file_ppfunc)SvIVX(ckobj);
OP *pushop, *cvop, *argop;
OP *newop;
PERL_UNUSED_ARG(namegv);
/* Navigate to first child */
pushop = cUNOPx(entersubop)->op_first;
if (!OpHAS_SIBLING(pushop)) {
pushop = cUNOPx(pushop)->op_first;
}
/* Get the args: pushmark -> arg -> cv */
argop = OpSIBLING(pushop);
if (!argop) return entersubop;
cvop = OpSIBLING(argop);
if (!cvop) return entersubop;
/* Verify exactly 1 arg */
if (OpSIBLING(argop) != cvop) return entersubop;
/* Detach arg from tree */
OpMORESIB_set(pushop, cvop);
OpLASTSIB_set(argop, NULL);
/* Create unary custom op with arg as child */
newop = newUNOP(OP_CUSTOM, 0, argop);
xs/file/file.c view on Meta::CPAN
result = 1;
cleanup:
Safefree(buffer);
close(fd_src);
close(fd_dst);
return result;
}
static int file_move_internal(pTHX_ const char *src, const char *dst) {
/* Try rename first (fast path for same filesystem) */
if (rename(src, dst) == 0) {
return 1;
}
/* If EXDEV, copy then delete (cross-device move) */
if (errno == EXDEV) {
if (file_copy_internal(aTHX_ src, dst)) {
return file_unlink_internal(src);
}
}
return 0;
}
static int file_touch_internal(const char *path) {
#ifdef _WIN32
HANDLE h;
FILETIME ft;
SYSTEMTIME st;
int result = 0;
/* Try to open existing file */
h = CreateFileA(path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
return 0;
}
GetSystemTime(&st);
SystemTimeToFileTime(&st, &ft);
result = SetFileTime(h, NULL, &ft, &ft) != 0;
CloseHandle(h);
return result;
#else
int fd;
/* Try to update times on existing file - utime(path, NULL) sets to current time */
if (utime(path, NULL) == 0) {
return 1;
}
/* File doesn't exist, create it */
fd = open(path, O_WRONLY | O_CREAT, 0644);
if (fd < 0) return 0;
close(fd);
return 1;
#endif
}
static int file_chmod_internal(const char *path, int mode) {
#ifdef _WIN32
return _chmod(path, mode) == 0;
#else
return chmod(path, mode) == 0;
#endif
}
static int file_mkdir_internal(const char *path, int mode) {
#ifdef _WIN32
PERL_UNUSED_VAR(mode);
return _mkdir(path) == 0;
#else
return mkdir(path, mode) == 0;
#endif
}
static int file_rmdir_internal(const char *path) {
#ifdef _WIN32
return _rmdir(path) == 0;
#else
return rmdir(path) == 0;
#endif
}
/* ============================================
Directory listing
============================================ */
static AV* file_readdir_internal(pTHX_ const char *path) {
AV *result = newAV();
#ifdef _WIN32
WIN32_FIND_DATAA fd;
HANDLE h;
char pattern[MAX_PATH];
size_t len = strlen(path);
if (len + 3 > MAX_PATH) return result;
memcpy(pattern, path, len);
if (len > 0 && path[len-1] != '\\' && path[len-1] != '/') {
pattern[len++] = '\\';
}
pattern[len++] = '*';
pattern[len] = '\0';
h = FindFirstFileA(pattern, &fd);
if (h == INVALID_HANDLE_VALUE) return result;
do {
/* Skip . and .. */
if (strcmp(fd.cFileName, ".") != 0 && strcmp(fd.cFileName, "..") != 0) {
av_push(result, newSVpv(fd.cFileName, 0));
}
} while (FindNextFileA(h, &fd));
FindClose(h);
#else
DIR *dir;
struct dirent *entry;
dir = opendir(path);
if (!dir) return result;
xs/file/file.c view on Meta::CPAN
static XS(xs_is_link) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::is_link(path)");
path = SvPV_nolen(ST(0));
ST(0) = file_is_link_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_is_executable) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::is_executable(path)");
path = SvPV_nolen(ST(0));
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
/* File manipulation functions */
static XS(xs_unlink) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::unlink(path)");
path = SvPV_nolen(ST(0));
ST(0) = file_unlink_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_copy) {
dXSARGS;
const char *src;
const char *dst;
if (items != 2) croak("Usage: file::copy(src, dst)");
src = SvPV_nolen(ST(0));
dst = SvPV_nolen(ST(1));
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_move) {
dXSARGS;
const char *src;
const char *dst;
if (items != 2) croak("Usage: file::move(src, dst)");
src = SvPV_nolen(ST(0));
dst = SvPV_nolen(ST(1));
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_touch) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::touch(path)");
path = SvPV_nolen(ST(0));
ST(0) = file_touch_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_chmod) {
dXSARGS;
const char *path;
int mode;
if (items != 2) croak("Usage: file::chmod(path, mode)");
path = SvPV_nolen(ST(0));
mode = SvIV(ST(1));
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_mkdir) {
dXSARGS;
const char *path;
int mode = 0755;
if (items < 1 || items > 2) croak("Usage: file::mkdir(path, [mode])");
path = SvPV_nolen(ST(0));
if (items > 1) mode = SvIV(ST(1));
ST(0) = file_mkdir_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_rmdir) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::rmdir(path)");
path = SvPV_nolen(ST(0));
ST(0) = file_rmdir_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
static XS(xs_readdir) {
dXSARGS;
const char *path;
AV *result;
if (items != 1) croak("Usage: file::readdir(path)");
path = SvPV_nolen(ST(0));
result = file_readdir_internal(aTHX_ path);
ST(0) = sv_2mortal(newRV_noinc((SV*)result));
XSRETURN(1);
}
/* Path manipulation functions */
static XS(xs_basename) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::basename(path)");
path = SvPV_nolen(ST(0));
ST(0) = sv_2mortal(file_basename_internal(aTHX_ path));
XSRETURN(1);
}
static XS(xs_dirname) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::dirname(path)");
path = SvPV_nolen(ST(0));
ST(0) = sv_2mortal(file_dirname_internal(aTHX_ path));
XSRETURN(1);
}
static XS(xs_extname) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file::extname(path)");
path = SvPV_nolen(ST(0));
ST(0) = sv_2mortal(file_extname_internal(aTHX_ path));
XSRETURN(1);
xs/file/file.c view on Meta::CPAN
XS_EXTERNAL(XS_file_func_is_writable) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file_is_writable($path)");
path = SvPV_nolen(ST(0));
ST(0) = file_is_writable_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_is_executable) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file_is_executable($path)");
path = SvPV_nolen(ST(0));
ST(0) = file_is_executable_internal(path) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_readdir) {
dXSARGS;
const char *path;
AV *result;
if (items != 1) croak("Usage: file_readdir($path)");
path = SvPV_nolen(ST(0));
result = file_readdir_internal(aTHX_ path);
ST(0) = sv_2mortal(newRV_noinc((SV*)result));
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_slurp_raw) {
dXSARGS;
const char *path;
if (items != 1) croak("Usage: file_slurp_raw($path)");
path = SvPV_nolen(ST(0));
ST(0) = sv_2mortal(file_slurp_raw_internal(aTHX_ path));
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_copy) {
dXSARGS;
const char *src;
const char *dst;
if (items != 2) croak("Usage: file_copy($src, $dst)");
src = SvPV_nolen(ST(0));
dst = SvPV_nolen(ST(1));
ST(0) = file_copy_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_move) {
dXSARGS;
const char *src;
const char *dst;
if (items != 2) croak("Usage: file_move($src, $dst)");
src = SvPV_nolen(ST(0));
dst = SvPV_nolen(ST(1));
ST(0) = file_move_internal(aTHX_ src, dst) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_chmod) {
dXSARGS;
const char *path;
int mode;
if (items != 2) croak("Usage: file_chmod($path, $mode)");
path = SvPV_nolen(ST(0));
mode = SvIV(ST(1));
ST(0) = file_chmod_internal(path, mode) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_append) {
dXSARGS;
const char *path;
if (items != 2) croak("Usage: file_append($path, $data)");
path = SvPV_nolen(ST(0));
ST(0) = file_append_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
XS_EXTERNAL(XS_file_func_atomic_spew) {
dXSARGS;
const char *path;
if (items != 2) croak("Usage: file_atomic_spew($path, $data)");
path = SvPV_nolen(ST(0));
ST(0) = file_atomic_spew_internal(aTHX_ path, ST(1)) ? &PL_sv_yes : &PL_sv_no;
XSRETURN(1);
}
/* file::import - import function-style accessors with custom ops */
XS_EXTERNAL(XS_file_import) {
dXSARGS;
const char *pkg;
int i;
bool want_import = FALSE;
/* Get caller's package */
pkg = CopSTASHPV(PL_curcop);
/* Check for 'import' in args */
for (i = 1; i < items; i++) {
STRLEN len;
const char *arg = SvPV(ST(i), len);
if (len == 6 && strEQ(arg, "import")) {
want_import = TRUE;
}
}
if (want_import) {
/* Install 1-arg functions with custom op optimization */
install_file_func_1arg(aTHX_ pkg, "file_slurp", XS_file_func_slurp, pp_file_slurp);
install_file_func_1arg(aTHX_ pkg, "file_exists", XS_file_func_exists, pp_file_exists);
install_file_func_1arg(aTHX_ pkg, "file_size", XS_file_func_size, pp_file_size);
install_file_func_1arg(aTHX_ pkg, "file_is_file", XS_file_func_is_file, pp_file_is_file);
install_file_func_1arg(aTHX_ pkg, "file_is_dir", XS_file_func_is_dir, pp_file_is_dir);
install_file_func_1arg(aTHX_ pkg, "file_lines", XS_file_func_lines, pp_file_lines);
/* New 1-arg functions with custom op optimization */
install_file_func_1arg(aTHX_ pkg, "file_unlink", XS_file_func_unlink, pp_file_unlink);
install_file_func_1arg(aTHX_ pkg, "file_mkdir", XS_file_func_mkdir, pp_file_mkdir);
install_file_func_1arg(aTHX_ pkg, "file_rmdir", XS_file_func_rmdir, pp_file_rmdir);
install_file_func_1arg(aTHX_ pkg, "file_touch", XS_file_func_touch, pp_file_touch);
install_file_func_1arg(aTHX_ pkg, "file_basename", XS_file_func_basename, pp_file_basename);
install_file_func_1arg(aTHX_ pkg, "file_dirname", XS_file_func_dirname, pp_file_dirname);
install_file_func_1arg(aTHX_ pkg, "file_extname", XS_file_func_extname, pp_file_extname);
/* Stat functions */
install_file_func_1arg(aTHX_ pkg, "file_mtime", XS_file_func_mtime, pp_file_mtime);
install_file_func_1arg(aTHX_ pkg, "file_atime", XS_file_func_atime, pp_file_atime);
install_file_func_1arg(aTHX_ pkg, "file_ctime", XS_file_func_ctime, pp_file_ctime);
install_file_func_1arg(aTHX_ pkg, "file_mode", XS_file_func_mode, pp_file_mode);
/* Type check functions */
install_file_func_1arg(aTHX_ pkg, "file_is_link", XS_file_func_is_link, pp_file_is_link);
install_file_func_1arg(aTHX_ pkg, "file_is_readable", XS_file_func_is_readable, pp_file_is_readable);
install_file_func_1arg(aTHX_ pkg, "file_is_writable", XS_file_func_is_writable, pp_file_is_writable);
install_file_func_1arg(aTHX_ pkg, "file_is_executable", XS_file_func_is_executable, pp_file_is_executable);
/* Directory operations */
install_file_func_1arg(aTHX_ pkg, "file_readdir", XS_file_func_readdir, pp_file_readdir);
/* Slurp raw */
install_file_func_1arg(aTHX_ pkg, "file_slurp_raw", XS_file_func_slurp_raw, pp_file_slurp_raw);
/* 2-arg functions */
install_file_func_2arg(aTHX_ pkg, "file_spew", XS_file_func_spew, pp_file_spew);
install_file_func_2arg(aTHX_ pkg, "file_copy", XS_file_func_copy, pp_file_copy);
install_file_func_2arg(aTHX_ pkg, "file_move", XS_file_func_move, pp_file_move);
install_file_func_2arg(aTHX_ pkg, "file_chmod", XS_file_func_chmod, pp_file_chmod);
install_file_func_2arg(aTHX_ pkg, "file_append", XS_file_func_append, pp_file_append);
install_file_func_2arg(aTHX_ pkg, "file_atomic_spew", XS_file_func_atomic_spew, pp_file_atomic_spew);
}
XSRETURN_EMPTY;
}
/* ============================================
Boot
============================================ */
XS_EXTERNAL(boot_file) {
dXSBOOTARGSXSAPIVERCHK;
PERL_UNUSED_VAR(items);
file_init(aTHX);
/* Register custom ops */
XopENTRY_set(&file_slurp_xop, xop_name, "file_slurp");
XopENTRY_set(&file_slurp_xop, xop_desc, "file slurp");
Perl_custom_op_register(aTHX_ pp_file_slurp, &file_slurp_xop);
XopENTRY_set(&file_spew_xop, xop_name, "file_spew");
XopENTRY_set(&file_spew_xop, xop_desc, "file spew");
Perl_custom_op_register(aTHX_ pp_file_spew, &file_spew_xop);
XopENTRY_set(&file_exists_xop, xop_name, "file_exists");
XopENTRY_set(&file_exists_xop, xop_desc, "file exists");
Perl_custom_op_register(aTHX_ pp_file_exists, &file_exists_xop);
XopENTRY_set(&file_size_xop, xop_name, "file_size");
XopENTRY_set(&file_size_xop, xop_desc, "file size");
Perl_custom_op_register(aTHX_ pp_file_size, &file_size_xop);
XopENTRY_set(&file_is_file_xop, xop_name, "file_is_file");
XopENTRY_set(&file_is_file_xop, xop_desc, "file is_file");
Perl_custom_op_register(aTHX_ pp_file_is_file, &file_is_file_xop);
XopENTRY_set(&file_is_dir_xop, xop_name, "file_is_dir");
XopENTRY_set(&file_is_dir_xop, xop_desc, "file is_dir");
Perl_custom_op_register(aTHX_ pp_file_is_dir, &file_is_dir_xop);
XopENTRY_set(&file_lines_xop, xop_name, "file_lines");
XopENTRY_set(&file_lines_xop, xop_desc, "file lines");
Perl_custom_op_register(aTHX_ pp_file_lines, &file_lines_xop);
XopENTRY_set(&file_unlink_xop, xop_name, "file_unlink");
XopENTRY_set(&file_unlink_xop, xop_desc, "file unlink");
Perl_custom_op_register(aTHX_ pp_file_unlink, &file_unlink_xop);
XopENTRY_set(&file_mkdir_xop, xop_name, "file_mkdir");
XopENTRY_set(&file_mkdir_xop, xop_desc, "file mkdir");
Perl_custom_op_register(aTHX_ pp_file_mkdir, &file_mkdir_xop);
XopENTRY_set(&file_rmdir_xop, xop_name, "file_rmdir");
XopENTRY_set(&file_rmdir_xop, xop_desc, "file rmdir");
Perl_custom_op_register(aTHX_ pp_file_rmdir, &file_rmdir_xop);
XopENTRY_set(&file_touch_xop, xop_name, "file_touch");
XopENTRY_set(&file_touch_xop, xop_desc, "file touch");
xs/file/file.c view on Meta::CPAN
XopENTRY_set(&file_basename_xop, xop_name, "file_basename");
XopENTRY_set(&file_basename_xop, xop_desc, "file basename");
Perl_custom_op_register(aTHX_ pp_file_basename, &file_basename_xop);
XopENTRY_set(&file_dirname_xop, xop_name, "file_dirname");
XopENTRY_set(&file_dirname_xop, xop_desc, "file dirname");
Perl_custom_op_register(aTHX_ pp_file_dirname, &file_dirname_xop);
XopENTRY_set(&file_extname_xop, xop_name, "file_extname");
XopENTRY_set(&file_extname_xop, xop_desc, "file extname");
Perl_custom_op_register(aTHX_ pp_file_extname, &file_extname_xop);
XopENTRY_set(&file_mtime_xop, xop_name, "file_mtime");
XopENTRY_set(&file_mtime_xop, xop_desc, "file mtime");
Perl_custom_op_register(aTHX_ pp_file_mtime, &file_mtime_xop);
XopENTRY_set(&file_atime_xop, xop_name, "file_atime");
XopENTRY_set(&file_atime_xop, xop_desc, "file atime");
Perl_custom_op_register(aTHX_ pp_file_atime, &file_atime_xop);
XopENTRY_set(&file_ctime_xop, xop_name, "file_ctime");
XopENTRY_set(&file_ctime_xop, xop_desc, "file ctime");
Perl_custom_op_register(aTHX_ pp_file_ctime, &file_ctime_xop);
XopENTRY_set(&file_mode_xop, xop_name, "file_mode");
XopENTRY_set(&file_mode_xop, xop_desc, "file mode");
Perl_custom_op_register(aTHX_ pp_file_mode, &file_mode_xop);
XopENTRY_set(&file_is_link_xop, xop_name, "file_is_link");
XopENTRY_set(&file_is_link_xop, xop_desc, "file is_link");
Perl_custom_op_register(aTHX_ pp_file_is_link, &file_is_link_xop);
XopENTRY_set(&file_is_readable_xop, xop_name, "file_is_readable");
XopENTRY_set(&file_is_readable_xop, xop_desc, "file is_readable");
Perl_custom_op_register(aTHX_ pp_file_is_readable, &file_is_readable_xop);
XopENTRY_set(&file_is_writable_xop, xop_name, "file_is_writable");
XopENTRY_set(&file_is_writable_xop, xop_desc, "file is_writable");
Perl_custom_op_register(aTHX_ pp_file_is_writable, &file_is_writable_xop);
XopENTRY_set(&file_is_executable_xop, xop_name, "file_is_executable");
XopENTRY_set(&file_is_executable_xop, xop_desc, "file is_executable");
Perl_custom_op_register(aTHX_ pp_file_is_executable, &file_is_executable_xop);
XopENTRY_set(&file_readdir_xop, xop_name, "file_readdir");
XopENTRY_set(&file_readdir_xop, xop_desc, "file readdir");
Perl_custom_op_register(aTHX_ pp_file_readdir, &file_readdir_xop);
XopENTRY_set(&file_slurp_raw_xop, xop_name, "file_slurp_raw");
XopENTRY_set(&file_slurp_raw_xop, xop_desc, "file slurp_raw");
Perl_custom_op_register(aTHX_ pp_file_slurp_raw, &file_slurp_raw_xop);
XopENTRY_set(&file_copy_xop, xop_name, "file_copy");
XopENTRY_set(&file_copy_xop, xop_desc, "file copy");
Perl_custom_op_register(aTHX_ pp_file_copy, &file_copy_xop);
XopENTRY_set(&file_move_xop, xop_name, "file_move");
XopENTRY_set(&file_move_xop, xop_desc, "file move");
Perl_custom_op_register(aTHX_ pp_file_move, &file_move_xop);
XopENTRY_set(&file_chmod_xop, xop_name, "file_chmod");
XopENTRY_set(&file_chmod_xop, xop_desc, "file chmod");
Perl_custom_op_register(aTHX_ pp_file_chmod, &file_chmod_xop);
XopENTRY_set(&file_append_xop, xop_name, "file_append");
XopENTRY_set(&file_append_xop, xop_desc, "file append");
Perl_custom_op_register(aTHX_ pp_file_append, &file_append_xop);
XopENTRY_set(&file_atomic_spew_xop, xop_name, "file_atomic_spew");
XopENTRY_set(&file_atomic_spew_xop, xop_desc, "file atomic_spew");
Perl_custom_op_register(aTHX_ pp_file_atomic_spew, &file_atomic_spew_xop);
/* Install functions with call checker for custom op optimization */
{
CV *cv;
SV *ckobj;
/* 1-arg functions with call checker */
cv = newXS("file::size", xs_size, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_size));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::mtime", xs_mtime, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_mtime));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::atime", xs_atime, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_atime));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::ctime", xs_ctime, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_ctime));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::mode", xs_mode, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_mode));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::exists", xs_exists, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_exists));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_file", xs_is_file, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_is_file));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_dir", xs_is_dir, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_is_dir));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_link", xs_is_link, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_is_link));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_readable", xs_is_readable, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_is_readable));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_writable", xs_is_writable, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_is_writable));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::is_executable", xs_is_executable, __FILE__);
xs/file/file.c view on Meta::CPAN
ckobj = newSViv(PTR2IV(pp_file_unlink));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::mkdir", xs_mkdir, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_mkdir));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::rmdir", xs_rmdir, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_rmdir));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::touch", xs_touch, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_touch));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::basename", xs_basename, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_basename));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::dirname", xs_dirname, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_dirname));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::extname", xs_extname, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_extname));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::slurp", xs_slurp, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_slurp));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::slurp_raw", xs_slurp_raw, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_slurp_raw));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::lines", xs_lines, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_lines));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
cv = newXS("file::readdir", xs_readdir, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_readdir));
cv_set_call_checker(cv, file_call_checker_1arg, ckobj);
/* 2-arg functions with call checker */
cv = newXS("file::spew", xs_spew, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_spew));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
cv = newXS("file::append", xs_append, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_append));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
cv = newXS("file::copy", xs_copy, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_copy));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
cv = newXS("file::move", xs_move, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_move));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
cv = newXS("file::chmod", xs_chmod, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_chmod));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
cv = newXS("file::atomic_spew", xs_atomic_spew, __FILE__);
ckobj = newSViv(PTR2IV(pp_file_atomic_spew));
cv_set_call_checker(cv, file_call_checker_2arg, ckobj);
}
/* Functions without custom op optimization */
newXS("file::join", xs_join, __FILE__);
newXS("file::each_line", xs_each_line, __FILE__);
newXS("file::grep_lines", xs_grep_lines, __FILE__);
newXS("file::count_lines", xs_count_lines, __FILE__);
newXS("file::find_line", xs_find_line, __FILE__);
newXS("file::map_lines", xs_map_lines, __FILE__);
newXS("file::register_line_callback", xs_register_line_callback, __FILE__);
newXS("file::list_line_callbacks", xs_list_line_callbacks, __FILE__);
/* File hooks */
newXS("file::register_read_hook", xs_register_read_hook, __FILE__);
newXS("file::register_write_hook", xs_register_write_hook, __FILE__);
newXS("file::clear_hooks", xs_clear_hooks, __FILE__);
newXS("file::has_hooks", xs_has_hooks, __FILE__);
/* Head and tail */
newXS("file::head", xs_head, __FILE__);
newXS("file::tail", xs_tail, __FILE__);
/* Import function */
newXS("file::import", XS_file_import, __FILE__);
/* Memory-mapped files */
newXS("file::mmap_open", xs_mmap_open, __FILE__);
newXS("file::mmap::data", xs_mmap_data, __FILE__);
newXS("file::mmap::sync", xs_mmap_sync, __FILE__);
newXS("file::mmap::close", xs_mmap_close, __FILE__);
newXS("file::mmap::DESTROY", xs_mmap_DESTROY, __FILE__);
/* Line iterators */
newXS("file::lines_iter", xs_lines_iter, __FILE__);
newXS("file::lines::next", xs_lines_iter_next, __FILE__);
newXS("file::lines::eof", xs_lines_iter_eof, __FILE__);
newXS("file::lines::close", xs_lines_iter_close, __FILE__);
newXS("file::lines::DESTROY", xs_lines_iter_DESTROY, __FILE__);
/* Register cleanup for global destruction */
Perl_call_atexit(aTHX_ file_cleanup_callback_registry, NULL);
Perl_xs_boot_epilog(aTHX_ ax);
}
( run in 1.698 second using v1.01-cache-2.11-cpan-99c4e6809bf )