Prima
view release on metacpan or search on metacpan
unix/file.c view on Meta::CPAN
apc_fs_link( const char* oldname, Bool is_old_utf8, const char * newname, Bool is_new_utf8 )
{
return link(oldname, newname) == 0;
}
Bool
apc_fs_mkdir( const char* path, Bool is_utf8, int mode)
{
return mkdir(path, mode) == 0;
}
Bool
apc_fs_opendir( const char* path, PDirHandleRec dh)
{
return (dh->handle = opendir(path)) != NULL;
}
int
apc_fs_open_file( const char* path, Bool is_utf8, int flags, int mode)
{
return open(path, flags, mode);
}
Bool
apc_fs_readdir( PDirHandleRec dh, char * entry)
{
struct dirent *de;
if ( !( de = readdir(dh->handle)))
return false;
strlcpy( entry, de->d_name, PATH_MAX_UTF8);
return true;
}
Bool
apc_fs_rename( const char* oldname, Bool is_old_utf8, const char * newname, Bool is_new_utf8 )
{
return rename(oldname, newname) == 0;
}
Bool
apc_fs_rewinddir( PDirHandleRec dh )
{
rewinddir(dh->handle);
return true;
}
Bool
apc_fs_rmdir( const char* path, Bool is_utf8 )
{
return rmdir(path) == 0;
}
Bool
apc_fs_seekdir( PDirHandleRec dh, long position )
{
seekdir(dh->handle, position);
return true;
}
Bool
apc_fs_setenv(const char * varname, Bool is_name_utf8, const char * value, Bool is_value_utf8)
{
Perl_my_setenv(aTHX_ varname, value);
return true;
}
Bool
apc_fs_stat(const char *name, Bool is_utf8, Bool link, PStatRec statrec)
{
struct stat statbuf;
if ( link ) {
if ( lstat(name, &statbuf) < 0 )
return 0;
} else {
if ( stat(name, &statbuf) < 0 )
return 0;
}
statrec-> dev = statbuf. st_dev;
statrec-> ino = statbuf. st_ino;
statrec-> mode = statbuf. st_mode;
statrec-> nlink = statbuf. st_nlink;
statrec-> uid = statbuf. st_uid;
statrec-> gid = statbuf. st_gid;
statrec-> rdev = statbuf. st_rdev;
statrec-> size = statbuf. st_size;
statrec-> blksize = statbuf. st_blksize;
statrec-> blocks = statbuf. st_blocks;
#ifdef __APPLE__
#define ST_F(a) st_##a##timespec
#else
#define ST_F(a) st_##a##tim
#endif
statrec-> atim = (float) statbuf.ST_F(a).tv_sec + (float) statbuf.ST_F(a).tv_nsec / 1000000000.0;
statrec-> mtim = (float) statbuf.ST_F(m).tv_sec + (float) statbuf.ST_F(m).tv_nsec / 1000000000.0;
statrec-> ctim = (float) statbuf.ST_F(c).tv_sec + (float) statbuf.ST_F(c).tv_nsec / 1000000000.0;
#undef ST_F
return 1;
}
long
apc_fs_telldir( PDirHandleRec dh )
{
return telldir(dh-> handle);
}
Bool
apc_fs_unlink( const char* path, Bool is_utf8 )
{
return unlink(path) == 0;
}
Bool
apc_fs_utime( double atime, double mtime, const char* path, Bool is_utf8 )
{
struct timeval tv[2];
tv[0].tv_sec = (long) atime;
tv[0].tv_usec = (atime - (float) tv[0].tv_sec) * 1000000;
tv[1].tv_sec = (long) mtime;
tv[1].tv_usec = (mtime - (float) tv[1].tv_sec) * 1000000;
return utimes(path, tv) == 0;
}
( run in 0.851 second using v1.01-cache-2.11-cpan-39bf76dae61 )