本文整理汇总了C++中chflags函数的典型用法代码示例。如果您正苦于以下问题:C++ chflags函数的具体用法?C++ chflags怎么用?C++ chflags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chflags函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dosetattr
static void
dosetattr(const char *filename, int fd, struct jattr *jattr)
{
if (fd >= 0) {
if (jattr->uid != (uid_t)-1 && jattr->gid != (gid_t)-1)
fchown(fd, jattr->uid, jattr->gid);
else if (jattr->uid != (uid_t)-1)
fchown(fd, jattr->uid, -1);
else if (jattr->gid != (gid_t)-1)
fchown(fd, -1, jattr->gid);
if (jattr->modes != (mode_t)-1)
fchmod(fd, jattr->modes);
if (jattr->fflags != -1)
fchflags(fd, jattr->fflags);
if (jattr->size != -1)
ftruncate(fd, jattr->size);
} else {
if (jattr->uid != (uid_t)-1 && jattr->gid != (gid_t)-1)
lchown(filename, jattr->uid, jattr->gid);
else if (jattr->uid != (uid_t)-1)
lchown(filename, jattr->uid, -1);
else if (jattr->gid != (gid_t)-1)
lchown(filename, -1, jattr->gid);
if (jattr->modes != (mode_t)-1)
lchmod(filename, jattr->modes);
if (jattr->fflags != -1)
chflags(filename, jattr->fflags);
if (jattr->size != -1)
truncate(filename, jattr->size);
}
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:33,代码来源:dump_mirror.c
示例2: getUTF8ByteArray
/*
* Class: org_eclipse_core_internal_filesystem_local_LocalFileNatives
* Method: internalCopyAttributesW
* Signature: ([C[CZ)Z
*/
JNIEXPORT jboolean JNICALL Java_org_eclipse_core_internal_filesystem_local_LocalFileNatives_internalCopyAttributesW
(JNIEnv *env, jclass clazz, jcharArray source, jcharArray destination, jboolean copyLastModified) {
struct stat info;
struct utimbuf ut;
int code;
char *sourceFile= (char*) getUTF8ByteArray(env, source);
char *destinationFile= (char*) getUTF8ByteArray(env, destination);
code= stat(sourceFile, &info);
if (code != 0) goto fail;
code= chmod(destinationFile, info.st_mode);
if (code != 0) goto fail;
chflags(destinationFile, info.st_flags); // ignore return code
if (copyLastModified) {
ut.actime= info.st_atime;
ut.modtime= info.st_mtime;
code= utime(destinationFile, &ut);
}
fail:
free(sourceFile);
free(destinationFile);
return code == 0;
}
开发者ID:Jiemamy,项目名称:eclipse-headless-builder,代码行数:31,代码来源:localfile.c
示例3: setfile
static void
setfile(const char *name, struct stat *fs)
{
static struct timeval tv[2];
fs->st_mode &= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim);
if (utimes(name, tv))
cwarn("utimes: %s", name);
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (chown(name, fs->st_uid, fs->st_gid)) {
if (errno != EPERM)
cwarn("chown: %s", name);
fs->st_mode &= ~(S_ISUID|S_ISGID);
}
if (chmod(name, fs->st_mode) && errno != EOPNOTSUPP)
cwarn("chmod: %s", name);
if (chflags(name, fs->st_flags) && errno != EOPNOTSUPP)
cwarn("chflags: %s", name);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:29,代码来源:compress.c
示例4: setdirmodes
/*
* Set the mode, owner, and times for all new or changed directories
*/
void
setdirmodes(int flags)
{
FILE *mf;
struct modeinfo node;
struct entry *ep;
char *cp;
const char *tmpdir;
vprintf(stdout, "Set directory mode, owner, and times.\n");
if ((tmpdir = getenv("TMPDIR")) == NULL || tmpdir[0] == '\0')
tmpdir = _PATH_TMP;
if (command == 'r' || command == 'R')
sprintf(modefile, "%s/rstmode%ld", tmpdir, (long)dumpdate);
if (modefile[0] == '#') {
panic("modefile not defined\n");
fprintf(stderr, "directory mode, owner, and times not set\n");
return;
}
mf = fopen(modefile, "r");
if (mf == NULL) {
fprintf(stderr, "fopen: %s\n", strerror(errno));
fprintf(stderr, "cannot open mode file %s\n", modefile);
fprintf(stderr, "directory mode, owner, and times not set\n");
return;
}
clearerr(mf);
for (;;) {
fread((char *)&node, 1, sizeof(struct modeinfo), mf);
if (feof(mf))
break;
ep = lookupino(node.ino);
if (command == 'i' || command == 'x') {
if (ep == NULL)
continue;
if ((flags & FORCE) == 0 && ep->e_flags & EXISTED) {
ep->e_flags &= ~NEW;
continue;
}
if (node.ino == ROOTINO &&
reply("set owner/mode for '.'") == FAIL)
continue;
}
if (ep == NULL) {
panic("cannot find directory inode %d\n", node.ino);
} else {
cp = myname(ep);
if (!Nflag) {
chown(cp, node.uid, node.gid);
chmod(cp, node.mode);
utimes(cp, node.timep);
chflags(cp, node.flags);
}
ep->e_flags &= ~NEW;
}
}
if (ferror(mf))
panic("error setting directory modes\n");
fclose(mf);
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:63,代码来源:dirs.c
示例5: setdirmodes
/*
* Set the mode, owner, and times for all new or changed directories
*/
void
setdirmodes(int flags)
{
FILE *mf;
struct modeinfo node;
struct entry *ep;
char *cp;
Vprintf(stdout, "Set directory mode, owner, and times.\n");
if (command == 'r' || command == 'R')
(void)snprintf(modefile, sizeof(modefile), "%s/rstmode%d",
tmpdir, dumpdate);
if (modefile[0] == '#') {
panic("modefile not defined\n");
fputs("directory mode, owner, and times not set\n", stderr);
return;
}
mf = fopen(modefile, "r");
if (mf == NULL) {
warn("fopen");
fprintf(stderr, "cannot open mode file %s\n", modefile);
fprintf(stderr, "directory mode, owner, and times not set\n");
return;
}
clearerr(mf);
for (;;) {
(void)fread((char *)&node, 1, sizeof(struct modeinfo), mf);
if (feof(mf))
break;
ep = lookupino(node.ino);
if (command == 'i' || command == 'x') {
if (ep == NULL)
continue;
if ((flags & FORCE) == 0 && ep->e_flags & EXISTED) {
ep->e_flags &= ~NEW;
continue;
}
if (node.ino == ROOTINO &&
reply("set owner/mode for '.'") == FAIL)
continue;
}
if (ep == NULL) {
panic("cannot find directory inode %d\n", node.ino);
} else {
if (!Nflag) {
cp = myname(ep);
(void)chown(cp, node.uid, node.gid);
(void)chmod(cp, node.mode);
(void)chflags(cp, node.flags);
(void)utimes(cp, node.ctimep);
(void)utimes(cp, node.mtimep);
}
ep->e_flags &= ~NEW;
}
}
if (ferror(mf))
panic("error setting directory modes\n");
(void)fclose(mf);
}
开发者ID:sofuture,项目名称:bitrig,代码行数:62,代码来源:dirs.c
示例6: setfile
/*
* Function: setfile
*
* Purpose:
* Set the owner/group/permissions for the "to" file to the information
* in the stat structure. If fd is zero, also call set_utimes() to set
* the mod/access times. If fd is non-zero, the caller must do a utimes
* itself after close(fd).
*/
int
setfile(struct stat *fs, int fd)
{
int rval;
#if HAVE_MEMBER_STRUCT_STAT_ST_FLAGS_SYS_STAT_H
int islink;
#endif
rval = 0;
#if HAVE_MEMBER_STRUCT_STAT_ST_FLAGS_SYS_STAT_H
islink = S_ISLNK(fs->st_mode);
#endif
fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
lchown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISUID | S_ISGID);
}
if (fd ? fchmod(fd, fs->st_mode) : lchmod(to.p_path, fs->st_mode)) {
warn("chmod: %s", to.p_path);
rval = 1;
}
#if HAVE_MEMBER_STRUCT_STAT_ST_FLAGS_SYS_STAT_H
if (!islink && !Nflag) {
unsigned long fflags = fs->st_flags;
/*
* XXX
* NFS doesn't support chflags; ignore errors unless
* there's reason to believe we're losing bits.
* (Note, this still won't be right if the server
* supports flags and we were trying to *remove* flags
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
if ((fd ? fchflags(fd, fflags) :
chflags(to.p_path, fflags)) == -1)
if (errno != EOPNOTSUPP || fs->st_flags != 0) {
warn("chflags: %s", to.p_path);
rval = 1;
}
}
#endif /* HAVE_MEMBER_STRUCT_STAT_ST_FLAGS_SYS_STAT_H */
/* if fd is non-zero, caller must call set_utimes() after close() */
if (fd == 0 && set_utimes(to.p_path, fs))
rval = 1;
return (rval);
}
开发者ID:cheusov,项目名称:nbase,代码行数:68,代码来源:utils.c
示例7: vfswrap_chflags
static int vfswrap_chflags(vfs_handle_struct *handle, const char *path, int flags)
{
#ifdef HAVE_CHFLAGS
return chflags(path, flags);
#else
errno = ENOSYS;
return -1;
#endif
}
开发者ID:edwacode,项目名称:r6300v2,代码行数:9,代码来源:vfs_default.c
示例8: clone
// Clone User, Owner and Mode, and "User Defined" flags if supported
void clone(struct stat *source, char *dpath) {
err_wrap(chmod(dpath, source->st_mode), "while changing mode" );
err_wrap(chown(dpath, source->st_uid, source->st_gid), "while changing ownership");
// Does this os/fs support "user-defined" flags
// via stat->st_flags
#if defined(__APPLE__) || defined(FreeBSD)
err_wrap(chflags(dpath, source->st_flags), "while changing user-defined flags");
#endif
}
开发者ID:yourabi,项目名称:chlone,代码行数:11,代码来源:chlone.c
示例9: set_chflags
/*
* set_chflags()
* Set 4.4BSD file flags
*/
void
set_chflags(char *fnm, u_int32_t flags)
{
#if 0
if (chflags(fnm, flags) < 0 && errno != EOPNOTSUPP)
syswarn(1, errno, "Cannot set file flags on %s", fnm);
#endif
return;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:14,代码来源:file_subs.c
示例10: setfile
/**
* set the stat() data of a file
**/
int setfile(const char *path, struct stat *fs)
{
DBG_IN();
struct utimbuf ut;
int rval;
rval = 0;
fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
ut.actime = fs->st_atime;
ut.modtime = fs->st_mtime;
if (utime(path, &ut)) {
usyslog(LOG_WARNING, "utimes: %s", path);
rval = 1;
}
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (chown(path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
usyslog(LOG_WARNING, "chown: %s", path);
rval = 1;
}
fs->st_mode &= ~(S_ISTXT | S_ISUID | S_ISGID);
}
if (chmod(path, fs->st_mode)) {
usyslog(LOG_WARNING, "chown: %s", path);
rval = 1;
}
#ifdef HAVE_CHFLAGS
/*
* XXX
* NFS doesn't support chflags; ignore errors unless there's reason
* to believe we're losing bits. (Note, this still won't be right
* if the server supports flags and we were trying to *remove* flags
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
if (chflags(path, fs->st_flags)) {
if (errno != EOPNOTSUPP || fs->st_flags != 0) {
usyslog(LOG_WARNING, "chflags: %s", path);
rval = 1;
}
return (rval);
}
#endif
return 0;
}
开发者ID:ystk,项目名称:debian-unionfs-fuse,代码行数:57,代码来源:cow_utils.c
示例11: xar_flags_extract
int32_t xar_flags_extract(xar_t x, xar_file_t f, const char *file, char *buffer, size_t len) {
#ifdef HAVE_CHFLAGS
char *tmp;
u_int flags = 0;
if( xar_prop_get(f, XAR_FLAG_FORK, NULL) )
return 0;
#ifdef UF_NODUMP
if( x_getprop(f, "UserNoDump", (char **)&tmp) == 0 )
flags |= UF_NODUMP;
#endif
#ifdef UF_IMMUTABLE
if( x_getprop(f, "UserImmutable", (char **)&tmp) == 0 )
flags |= UF_IMMUTABLE;
#endif
#ifdef UF_APPEND
if( x_getprop(f, "UserAppend", (char **)&tmp) == 0 )
flags |= UF_APPEND;
#endif
#ifdef UF_OPAQUE
if( x_getprop(f, "UserOpaque", (char **)&tmp) == 0 )
flags |= UF_OPAQUE;
#endif
#ifdef SF_ARCHIVED
if( x_getprop(f, "SystemArchived", (char **)&tmp) == 0 )
flags |= SF_ARCHIVED;
#endif
#ifdef SF_IMMUTABLE
if( x_getprop(f, "SystemImmutable", (char **)&tmp) == 0 )
flags |= SF_IMMUTABLE;
#endif
#ifdef SF_APPEND
if( x_getprop(f, "SystemAppend", (char **)&tmp) == 0 )
flags |= SF_APPEND;
#endif
if( !flags )
return 0;
if( chflags(file, flags) != 0 ) {
char e[1024];
memset(e, 0, sizeof(e));
snprintf(e, sizeof(e)-1, "chflags: %s", strerror(errno));
xar_err_new(x);
xar_err_set_file(x, f);
xar_err_set_string(x, e);
xar_err_callback(x, XAR_SEVERITY_NONFATAL, XAR_ERR_ARCHIVE_EXTRACTION);
return -1;
}
#endif
return 0;
}
开发者ID:ALEXGUOQ,项目名称:DocSets-for-iOS,代码行数:54,代码来源:stat.c
示例12: fsetflags
int fsetflags (const char * name, unsigned long flags)
{
#if HAVE_CHFLAGS && !(APPLE_DARWIN && HAVE_EXT2_IOCTLS)
unsigned long bsd_flags = 0;
#ifdef UF_IMMUTABLE
if (flags & EXT2_IMMUTABLE_FL)
bsd_flags |= UF_IMMUTABLE;
#endif
#ifdef UF_APPEND
if (flags & EXT2_APPEND_FL)
bsd_flags |= UF_APPEND;
#endif
#ifdef UF_NODUMP
if (flags & EXT2_NODUMP_FL)
bsd_flags |= UF_NODUMP;
#endif
return chflags (name, bsd_flags);
#else /* !HAVE_CHFLAGS || (APPLE_DARWIN && HAVE_EXT2_IOCTLS) */
#if HAVE_EXT2_IOCTLS
int fd, r, f, save_errno = 0;
struct stat buf;
if (!lstat(name, &buf) &&
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
goto notsupp;
}
#if !APPLE_DARWIN
fd = open (name, OPEN_FLAGS);
if (fd == -1)
return -1;
f = (int) flags;
r = ioctl (fd, EXT2_IOC_SETFLAGS, &f);
if (r == -1)
save_errno = errno;
close (fd);
if (save_errno)
errno = save_errno;
#else /* APPLE_DARWIN */
f = (int) flags;
return syscall(SYS_fsctl, name, EXT2_IOC_SETFLAGS, &f, 0);
#endif /* !APPLE_DARWIN */
return r;
notsupp:
#endif /* HAVE_EXT2_IOCTLS */
#endif
errno = EOPNOTSUPP;
return -1;
}
开发者ID:AOSP-JF,项目名称:platform_external_e2fsprogs,代码行数:51,代码来源:fsetflags.c
示例13: rm_file
rm_file(char **argv)
#endif
{
struct stat sb;
int df, rval;
char *f;
df = dflag;
/*
* Remove a file. POSIX 1003.2 states that, by default, attempting
* to remove a directory is an error, so must always stat the file.
*/
while ((f = *argv++) != NULL) {
/* Assume if can't stat the file, can't unlink it. */
if (lstat(f, &sb)) {
if (!fflag || errno != ENOENT) {
warn("%s", f);
eval = 1;
}
continue;
}
if (S_ISDIR(sb.st_mode) && !df) {
warnx("%s: is a directory", f);
eval = 1;
continue;
}
if (!fflag && !check(f, f, &sb))
continue;
rval = 0;
#ifndef __GNO__
if (!uid &&
(sb.st_flags & (UF_APPEND|UF_IMMUTABLE)) &&
!(sb.st_flags & (SF_APPEND|SF_IMMUTABLE)))
rval = chflags(f, sb.st_flags & ~(UF_APPEND|UF_IMMUTABLE));
#endif
if (!rval) {
if (S_ISDIR(sb.st_mode))
rval = rmdir(f);
else {
if (Pflag)
rm_overwrite(f, &sb);
rval = unlink(f);
}
}
if (rval && (!fflag || errno != ENOENT)) {
warn("%s", f);
eval = 1;
}
}
}
开发者ID:GnoConsortium,项目名称:gno,代码行数:50,代码来源:rm.c
示例14: setfile
int
setfile(struct stat *fs, int fd)
{
static struct timeval tv[2];
int rval;
rval = 0;
fs->st_mode &= S_ISTXT | S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atimespec);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtimespec);
if (utimes(to.p_path, tv)) {
warn("utimes: %s", to.p_path);
rval = 1;
}
/*
* Changing the ownership probably won't succeed, unless we're root
* or POSIX_CHOWN_RESTRICTED is not set. Set uid/gid before setting
* the mode; current BSD behavior is to remove all setuid bits on
* chown. If chown fails, lose setuid/setgid bits.
*/
if (fd ? fchown(fd, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid)) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISTXT | S_ISUID | S_ISGID);
}
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
warn("chmod: %s", to.p_path);
rval = 1;
}
/*
* XXX
* NFS doesn't support chflags; ignore errors unless there's reason
* to believe we're losing bits. (Note, this still won't be right
* if the server supports flags and we were trying to *remove* flags
* on a file that we copied, i.e., that we didn't create.)
*/
errno = 0;
if (fd ? fchflags(fd, fs->st_flags) : chflags(to.p_path, fs->st_flags))
if (errno != EOPNOTSUPP || fs->st_flags != 0) {
warn("chflags: %s", to.p_path);
rval = 1;
}
return (rval);
}
开发者ID:jyin0813,项目名称:OpenBSD-src,代码行数:49,代码来源:utils.c
示例15: fsetflags
int fsetflags (const char * name, unsigned long flags)
{
struct stat buf;
#if HAVE_CHFLAGS
unsigned long bsd_flags = 0;
#ifdef UF_IMMUTABLE
if (flags & EXT2_IMMUTABLE_FL)
bsd_flags |= UF_IMMUTABLE;
#endif
#ifdef UF_APPEND
if (flags & EXT2_APPEND_FL)
bsd_flags |= UF_APPEND;
#endif
#ifdef UF_NODUMP
if (flags & EXT2_NODUMP_FL)
bsd_flags |= UF_NODUMP;
#endif
return chflags (name, bsd_flags);
#else
#if HAVE_EXT2_IOCTLS
int fd = 0, r, f, save_errno = 0;
if (!stat(name, &buf) &&
!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode)) {
close(fd);
goto notsupp;
}
fd = open (name, OPEN_FLAGS);
if (fd == -1)
return -1;
f = (int) flags;
r = ioctl (fd, EXT2_IOC_SETFLAGS, &f);
if (r == -1)
save_errno = errno;
close (fd);
if (save_errno)
errno = save_errno;
return r;
#endif /* HAVE_EXT2_IOCTLS */
#endif
notsupp:
errno = EOPNOTSUPP;
return -1;
}
开发者ID:DentonGentry,项目名称:gfiber-gfrg100,代码行数:46,代码来源:fsetflags.c
示例16: setfile
int setfile(struct stat *fs, int fd) {
static struct timeval tv[2];
struct stat ts;
int rval, gotstat, islink, fdval;
rval = 0;
fdval = fd != -1;
islink = !fdval && S_ISLNK(fs->st_mode);
fs->st_mode &= S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO;
TIMESPEC_TO_TIMEVAL(&tv[0], &fs->st_atim);
TIMESPEC_TO_TIMEVAL(&tv[1], &fs->st_mtim);
if (islink ? lutimes(to.p_path, tv) : utimes(to.p_path, tv)) {
warn("%sutimes: %s", islink ? "l" : "", to.p_path);
rval = 1;
}
if (fdval ? fstat(fd, &ts) : (islink ? lstat(to.p_path, &ts) : stat(to.p_path, &ts)))
gotstat = 0;
else {
gotstat = 1;
ts.st_mode &= S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO;
}
if (!gotstat || fs->st_uid != ts.st_uid || fs->st_gid != ts.st_gid)
if (fdval ? fchown(fd, fs->st_uid, fs->st_gid) : (islink ? lchown(to.p_path, fs->st_uid, fs->st_gid) :
chown(to.p_path, fs->st_uid, fs->st_gid))) {
if (errno != EPERM) {
warn("chown: %s", to.p_path);
rval = 1;
}
fs->st_mode &= ~(S_ISUID | S_ISGID);
}
if (!gotstat || fs->st_mode != ts.st_mode)
if (fdval ? fchmod(fd, fs->st_mode) : (islink ? lchmod(to.p_path, fs->st_mode) :
chmod(to.p_path, fs->st_mode))) {
warn("chmod: %s", to.p_path);
rval = 1;
}
if (!gotstat || fs->st_flags != ts.st_flags)
if (fdval ? fchflags(fd, fs->st_flags) : (islink ? lchflags(to.p_path, fs->st_flags) :
chflags(to.p_path, fs->st_flags))) {
warn("chflags: %s", to.p_path);
rval = 1;
}
return (rval);
}
开发者ID:jhbsz,项目名称:OSI-OS,代码行数:44,代码来源:utils.c
示例17: NS_ASSERTION
nsresult
nsXREDirProvider::SetProfile(nsIFile* aDir, nsIFile* aLocalDir)
{
NS_ASSERTION(aDir && aLocalDir, "We don't support no-profile apps yet!");
nsresult rv;
rv = EnsureDirectoryExists(aDir);
if (NS_FAILED(rv))
return rv;
rv = EnsureDirectoryExists(aLocalDir);
if (NS_FAILED(rv))
return rv;
#ifdef XP_MACOSX
bool same;
if (NS_SUCCEEDED(aDir->Equals(aLocalDir, &same)) && !same) {
// Ensure that the cache directory is not indexed by Spotlight
// (bug 718910). At least on OS X, the cache directory (under
// ~/Library/Caches/) is always the "local" user profile
// directory. This is confusing, since *both* user profile
// directories are "local" (they both exist under the user's
// home directory). But this usage dates back at least as far
// as the patch for bug 291033, where "local" seems to mean
// "suitable for temporary storage". Don't hide the cache
// directory if by some chance it and the "non-local" profile
// directory are the same -- there are bad side effects from
// hiding a profile directory under /Library/Application Support/
// (see bug 801883).
nsAutoCString cacheDir;
if (NS_SUCCEEDED(aLocalDir->GetNativePath(cacheDir))) {
if (chflags(cacheDir.get(), UF_HIDDEN)) {
NS_WARNING("Failed to set Cache directory to HIDDEN.");
}
}
}
#endif
mProfileDir = aDir;
mProfileLocalDir = aLocalDir;
return NS_OK;
}
开发者ID:ChaOSChriS,项目名称:gecko-dev,代码行数:43,代码来源:nsXREDirProvider.cpp
示例18: login_protect
static void
login_protect(const char *table, char *pattern, int mask, uid_t uid, gid_t gid)
{
glob_t gl;
char *path;
unsigned int i;
if (glob(pattern, GLOB_NOSORT, NULL, &gl) != 0)
return;
for (i = 0; i < gl.gl_pathc; i++) {
path = gl.gl_pathv[i];
/* clear flags of the device */
if (chflags(path, 0) && errno != ENOENT && errno != EOPNOTSUPP)
syslog(LOG_ERR, "%s: chflags(%s): %m", table, path);
if (chmod(path, mask) && errno != ENOENT)
syslog(LOG_ERR, "%s: chmod(%s): %m", table, path);
if (chown(path, uid, gid) && errno != ENOENT)
syslog(LOG_ERR, "%s: chown(%s): %m", table, path);
}
globfree(&gl);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:21,代码来源:login_fbtab.c
示例19: ATF_TC_BODY
ATF_TC_BODY(stat_chflags, tc)
{
struct stat sa, sb;
int fd;
(void)memset(&sa, 0, sizeof(struct stat));
(void)memset(&sb, 0, sizeof(struct stat));
fd = open(path, O_RDONLY | O_CREAT);
ATF_REQUIRE(fd != -1);
ATF_REQUIRE(stat(path, &sa) == 0);
ATF_REQUIRE(chflags(path, UF_NODUMP) == 0);
ATF_REQUIRE(stat(path, &sb) == 0);
if (sa.st_flags == sb.st_flags)
atf_tc_fail("stat(2) did not detect chflags(2)");
ATF_REQUIRE(close(fd) == 0);
ATF_REQUIRE(unlink(path) == 0);
}
开发者ID:Lxg1582,项目名称:freebsd,代码行数:21,代码来源:t_stat.c
示例20: fsetflags
int fsetflags (const char * name, unsigned long flags)
{
#if HAVE_CHFLAGS
unsigned long bsd_flags = 0;
#ifdef UF_IMMUTABLE
if (flags & EXT2_IMMUTABLE_FL)
bsd_flags |= UF_IMMUTABLE;
#endif
#ifdef UF_APPEND
if (flags & EXT2_APPEND_FL)
bsd_flags |= UF_APPEND;
#endif
#ifdef UF_NODUMP
if (flags & EXT2_NODUMP_FL)
bsd_flags |= UF_NODUMP;
#endif
return chflags (name, bsd_flags);
#else
#if HAVE_EXT2_IOCTLS
int fd, r, f;
fd = open (name, OPEN_FLAGS);
if (fd == -1)
return -1;
f = (int) flags;
r = ioctl (fd, EXT2_IOC_SETFLAGS, &f);
close (fd);
return r;
#else /* ! HAVE_EXT2_IOCTLS */
// extern int errno;
errno = EOPNOTSUPP;
return -1;
#endif /* ! HAVE_EXT2_IOCTLS */
#endif
}
开发者ID:crossmeta,项目名称:linux,代码行数:37,代码来源:fsetflags.c
注:本文中的chflags函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论