In connection to this thread:
http://svn.haxx.se/dev/archive-2006-02/0631.shtml
Now, I'm not sure about the log message, but I'm sure that we will fix
that.
On another note the name of the function isn't really true anymore, but
what should the name be instead? And is it worth the rev'ing of this API?
[[[
Use simple implementation of svn_io_set_file_read_[write|only]
* subversion/libsvn_subr/io.c
(svn_io_set_file_read_write_carefully): Replace complex logic for
trying to do the right thing on systems with unix style permissions
with simple calls to svn_io_set_file_read_[write|only] instead.
]]]
/Andreas
Index: subversion/libsvn_subr/io.c
===================================================================
--- subversion/libsvn_subr/io.c (revision 18521)
+++ subversion/libsvn_subr/io.c (arbetskopia)
@@ -1018,93 +1018,11 @@
svn_boolean_t ignore_enoent,
apr_pool_t *pool)
{
- apr_status_t status;
- const char *path_apr;
- apr_finfo_t finfo;
- apr_fileperms_t perms_to_set;
-
- SVN_ERR(svn_path_cstring_from_utf8(&path_apr, path, pool));
-
- /* Try to change only a minimal amount of the perms first
- by getting the current perms and adding execute bits
- only on where read perms are granted. If this fails
- fall through to the svn_io_set_file* calls. */
- status = apr_stat(&finfo, path_apr, APR_FINFO_PROT, pool);
- if (status)
- {
- if (ignore_enoent && APR_STATUS_IS_ENOENT(status))
- return SVN_NO_ERROR;
- else if (status != APR_ENOTIMPL)
- return svn_error_wrap_apr(status,
- _("Can't change read-write perms of "
- "file '%s'"),
- svn_path_local_style(path, pool));
- }
+ if (enable_write)
+ SVN_ERR(svn_io_set_file_read_write(path, ignore_enoent, pool));
else
- {
- perms_to_set = finfo.protection;
- if (enable_write) /* Make read-write. */
- SVN_ERR(get_default_file_perms(path, &perms_to_set,
- pool));
- else /* Make read-only. */
- {
- if (finfo.protection & APR_UREAD)
- perms_to_set &= ~APR_UWRITE;
- if (finfo.protection & APR_GREAD)
- perms_to_set &= ~APR_GWRITE;
- if (finfo.protection & APR_WREAD)
- perms_to_set &= ~APR_WWRITE;
- }
+ SVN_ERR(svn_io_set_file_read_only(path, ignore_enoent, pool));
- /* If we aren't changing anything then just return, this save
- some system calls and helps with shared working copies */
- if (perms_to_set == finfo.protection)
- return SVN_NO_ERROR;
-
- status = apr_file_perms_set(path_apr, perms_to_set);
- if (status)
- {
- if (APR_STATUS_IS_EPERM(status))
- {
- /* We don't have permissions to change the
- permissions! Try a move, copy, and delete
- workaround to see if we can get the file owned by
- us. If these succeed, try the permissions set
- again.
-
- Note that we only attempt this in the
- stat-available path. This assumes that the
- move-copy workaround will only be helpful on
- platforms that implement apr_stat. */
- SVN_ERR(reown_file(path_apr, pool));
- status = apr_file_perms_set(path_apr, perms_to_set);
- }
-
- if (status)
- {
- if (ignore_enoent && APR_STATUS_IS_ENOENT(status))
- return SVN_NO_ERROR;
- else if (status == APR_ENOTIMPL) /* on win32, for example. */
- {
- if (enable_write)
- SVN_ERR(svn_io_set_file_read_write(path, ignore_enoent,
- pool));
-
- else
- SVN_ERR(svn_io_set_file_read_only(path, ignore_enoent,
- pool));
- }
- else
- return svn_error_wrap_apr
- (status, _("Can't change read-write perms of file '%s'"),
- svn_path_local_style(path, pool));
- }
- else
- return SVN_NO_ERROR;
- }
- else
- return SVN_NO_ERROR;
- }
return SVN_NO_ERROR;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Feb 20 18:28:58 2006