UnQLite
view release on metacpan or search on metacpan
unqlite/unqlite.c view on Meta::CPAN
zPath = jx9_value_to_string(apArg[0], 0);
/* Extract the mode */
iMode = jx9_value_to_int(apArg[1]);
/* Perform the requested operation */
rc = pVfs->xChmod(zPath, iMode);
/* IO return value */
jx9_result_bool(pCtx, rc == JX9_OK);
return JX9_OK;
}
/*
* bool chown(string $filename, string $user)
* Attempts to change the owner of the file filename to user user.
* Parameters
* $filename
* Path to the file.
* $user
* Username.
* Return
* TRUE on success or FALSE on failure.
*/
static int jx9Vfs_chown(jx9_context *pCtx, int nArg, jx9_value **apArg)
{
const char *zPath, *zUser;
jx9_vfs *pVfs;
int rc;
if( nArg < 2 || !jx9_value_is_string(apArg[0]) ){
/* Missing/Invalid arguments, return FALSE */
jx9_result_bool(pCtx, 0);
return JX9_OK;
}
/* Point to the underlying vfs */
unqlite/unqlite.c view on Meta::CPAN
{
#ifndef JX9_UNIX_STATIC_BUILD
struct passwd *pwd;
uid_t uid;
int rc;
pwd = getpwnam(zUser); /* Try getting UID for username */
if (pwd == 0) {
return -1;
}
uid = pwd->pw_uid;
rc = chown(zPath, uid, -1);
return rc == 0 ? JX9_OK : -1;
#else
SXUNUSED(zPath);
SXUNUSED(zUser);
return -1;
#endif /* JX9_UNIX_STATIC_BUILD */
}
/* int (*xChgrp)(const char *, const char *) */
static int UnixVfs_Chgrp(const char *zPath, const char *zGroup)
{
#ifndef JX9_UNIX_STATIC_BUILD
struct group *group;
gid_t gid;
int rc;
group = getgrnam(zGroup);
if (group == 0) {
return -1;
}
gid = group->gr_gid;
rc = chown(zPath, -1, gid);
return rc == 0 ? JX9_OK : -1;
#else
SXUNUSED(zPath);
SXUNUSED(zGroup);
return -1;
#endif /* JX9_UNIX_STATIC_BUILD */
}
/* int (*xIsfile)(const char *) */
static int UnixVfs_isfile(const char *zPath)
{
unqlite/unqlite.c view on Meta::CPAN
{"rmdir", jx9Vfs_rmdir },
{"is_dir", jx9Vfs_is_dir },
{"mkdir", jx9Vfs_mkdir },
{"rename", jx9Vfs_rename },
{"realpath", jx9Vfs_realpath},
{"sleep", jx9Vfs_sleep },
{"usleep", jx9Vfs_usleep },
{"unlink", jx9Vfs_unlink },
{"delete", jx9Vfs_unlink },
{"chmod", jx9Vfs_chmod },
{"chown", jx9Vfs_chown },
{"chgrp", jx9Vfs_chgrp },
{"disk_free_space", jx9Vfs_disk_free_space },
{"disk_total_space", jx9Vfs_disk_total_space},
{"file_exists", jx9Vfs_file_exists },
{"filesize", jx9Vfs_file_size },
{"fileatime", jx9Vfs_file_atime },
{"filemtime", jx9Vfs_file_mtime },
{"filectime", jx9Vfs_file_ctime },
{"is_file", jx9Vfs_is_file },
{"is_link", jx9Vfs_is_link },
( run in 0.517 second using v1.01-cache-2.11-cpan-5511b514fd6 )