/* Only call this if the on-disk node kind is a file. */ static svn_error_t * add_file(const char *local_abspath, svn_magic__cookie_t *magic_cookie, svn_client_ctx_t *ctx, apr_pool_t *pool) { apr_hash_t* properties; apr_hash_index_t *hi; const char *mimetype; svn_node_kind_t kind; svn_boolean_t is_special; /* Check to see if this is a special file. */ SVN_ERR(svn_io_check_special_path(local_abspath, &kind, &is_special, pool)); if (is_special) mimetype = NULL; else /* Get automatic properties */ /* This may fail on write-only files: we open them to estimate file type. That's why we postpone the add until after this step. */ SVN_ERR(svn_client__get_auto_props(&properties, &mimetype, local_abspath, magic_cookie, ctx, pool)); /* Add the file */ SVN_ERR(svn_wc_add_from_disk(ctx->wc_ctx, local_abspath, NULL, NULL, pool)); if (is_special) /* This must be a special file. */ SVN_ERR(svn_wc_prop_set4(ctx->wc_ctx, local_abspath, SVN_PROP_SPECIAL, svn_string_create(SVN_PROP_BOOLEAN_TRUE, pool), svn_depth_empty, FALSE, NULL, NULL, NULL /* cancellation */, NULL, NULL /* notification */, pool)); else if (properties) { /* loop through the hashtable and add the properties */ for (hi = apr_hash_first(pool, properties); hi != NULL; hi = apr_hash_next(hi)) { const char *pname = svn__apr_hash_index_key(hi); const svn_string_t *pval = svn__apr_hash_index_val(hi); svn_error_t *err; /* It's probably best to pass 0 for force, so that if the autoprops say to set some weird combination, we just error and let the user sort it out. */ err = svn_wc_prop_set4(ctx->wc_ctx, local_abspath, pname, pval, svn_depth_empty, FALSE, NULL, NULL, NULL /* cancellation */, NULL, NULL /* notification */, pool); if (err) { /* Don't leave the job half-done. If we fail to set a property, * (try to) un-add the file. */ svn_error_clear(svn_wc_revert4(ctx->wc_ctx, local_abspath, svn_depth_empty, FALSE /* use_commit_times */, NULL /* changelists */, NULL, NULL, NULL, NULL, pool)); return svn_error_trace(err); } } } /* Report the addition to the caller. */ if (ctx->notify_func2 != NULL) { svn_wc_notify_t *notify = svn_wc_create_notify(local_abspath, svn_wc_notify_add, pool); notify->kind = svn_node_file; notify->mime_type = mimetype; (*ctx->notify_func2)(ctx->notify_baton2, notify, pool); } return SVN_NO_ERROR; }
static svn_error_t * add_file(const char *path, svn_client_ctx_t *ctx, svn_wc_adm_access_t *adm_access, apr_pool_t *pool) { apr_hash_t* properties; apr_hash_index_t *hi; const char *mimetype; svn_node_kind_t kind; svn_boolean_t is_special; /* Check to see if this is a special file. */ SVN_ERR(svn_io_check_special_path(path, &kind, &is_special, pool)); if (is_special) mimetype = NULL; else /* Get automatic properties */ /* This may fail on write-only files: we open them to estimate file type. That's why we postpone the add until after this step. */ SVN_ERR(svn_client__get_auto_props(&properties, &mimetype, path, ctx, pool)); /* Add the file */ SVN_ERR(svn_wc_add2(path, adm_access, NULL, SVN_INVALID_REVNUM, ctx->cancel_func, ctx->cancel_baton, NULL, NULL, pool)); if (is_special) /* This must be a special file. */ SVN_ERR(svn_wc_prop_set2 (SVN_PROP_SPECIAL, svn_string_create(SVN_PROP_BOOLEAN_TRUE, pool), path, adm_access, FALSE, pool)); else if (properties) { /* loop through the hashtable and add the properties */ for (hi = apr_hash_first(pool, properties); hi != NULL; hi = apr_hash_next(hi)) { const void *pname; void *pval; apr_hash_this(hi, &pname, NULL, &pval); /* It's probably best to pass 0 for force, so that if the autoprops say to set some weird combination, we just error and let the user sort it out. */ SVN_ERR(svn_wc_prop_set2(pname, pval, path, adm_access, FALSE, pool)); } } /* Report the addition to the caller. */ if (ctx->notify_func2 != NULL) { svn_wc_notify_t *notify = svn_wc_create_notify(path, svn_wc_notify_add, pool); notify->kind = svn_node_file; notify->mime_type = mimetype; (*ctx->notify_func2)(ctx->notify_baton2, notify, pool); } return SVN_NO_ERROR; }