[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: apr_copy_file and apr_transfer_file_contents

From: Philip Martin <philip_at_codematters.co.uk>
Date: 2002-01-28 22:15:23 CET

Karl Fogel <kfogel@newton.ch.collab.net> writes:

> Philip Martin <philip@codematters.co.uk> writes:
> Therefore, not only is the comment wrong, but the APR_FINFO_MIN flag
> is wrong. Don't we want APR_FINFO_PROT instead? Here are their
> definitions in apr_file_info.h:
>
> #define APR_FINFO_MIN 0x00008170 /**< type, mtime, ctime, atime, size */
> #define APR_FINFO_PROT 0x00700000 /**< all protections */
>
> Am I missing something here?

Yes, it looks like a bug. Hidden by the fact that the Unix
implementation of apr_stat doesn't check that bit, it always returns
the permissions.

>
> > Is copying the file permissions a good idea? When a file is created
> > it can be created with permissions APR_OS_DEFAULT. apr_copy_file and
> > apr_transfer_file_contents will create a file if necessary but always
> > set the permissions to match those of the source file. There is no
> > easy way to restore the default permissions on the destination file.
> >
> > I can see that at times it might be necessary to atomically copy and
> > set permissions, so simply removing the permission copying is not a
> > good idea. I am not sure what the interface should be: perhaps two
> > functions apr_copy_file and apr_copy_file_contents, or perhaps one
> > function with a flag.
>
> Maybe apr_copy_file() and its helper should take a flag that indicates
> either the perms to use for the new file, or to use the same perms as
> the old file (we could add a new flag value for that if necessary).

Possibilites
 - create destination, use given permissions.
 - create destination, use OS default permissions
 - create destination, copy source permissions
 - existing destination, use given permissions
 - existing destination, use OS default permissions
 - existing destination, keep exiting destination permissions
 - existing destination, copy source permissions

That means adding two more magic values to the apr_file_open's perm
parameter. This flag is getting overloaded!

Perhaps apr_copy_file should take a const char *src and an open
apr_file_t *dst and leave permissions to the application? Then, as a
bonus, apr_file_append is unnecessary, it's the same as apr_file_copy.

-- 
Philip
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:37:00 2006

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.