Example #1
0
        /////////////////////////////////////////

        /// <summary>Gets the repository Uri of a path, or <c>null</c> if path is not versioned</summary>
        /// <remarks>See also <see cref="SvnTools.GetUriFromWorkingCopy" /></remarks>
        public unsafe Uri GetUriFromWorkingCopy(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (!IsNotUri(path))
            {
                throw new ArgumentException(SharpSvnStrings.ArgumentMustBeAPathNotAUri, nameof(path));
            }

            var pool  = new AprPool(_pool);
            var store = new NoArgsStore(this, pool);

            try
            {
                sbyte *url = null;

                svn_error_t err = svn_client.svn_client_url_from_path2(
                    &url,
                    pool.AllocAbsoluteDirent(path),
                    CtxHandle,
                    pool.Handle,
                    pool.Handle);

                if (err == null && url != null)
                {
                    return(Utf8_PtrToUri(url, Directory.Exists(path) ? SvnNodeKind.Directory : SvnNodeKind.File));
                }
                if (err != null)
                {
                    svn_error.svn_error_clear(err);
                }

                return(null);
            }
            finally
            {
                store.Dispose();
                pool.Dispose();
            }
        }