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

Re: svn_client_ls - how can I tell file from dir

From: Ben Reser <ben_at_reser.org>
Date: 2004-03-25 01:58:23 CET

On Thu, Mar 25, 2004 at 12:00:51AM +0000, Barry Scott wrote:
> If I call svn_client_ls with a path of "foo" I will
> get back "foo" if its a file or the contents of "foo" if
> its a dir. How can I tell which of the two cases happened?

Well svn_client_ls fills a hash of svn_dirent_t's.

Since svn_client_ls only takes one target you can safely assume that if
the hash has more than one entry you got a directory.

If you get one entry in the hash the entry could be a reply to a file or
a directory target. You'll need to look at the svn_dirent_t listing for
the kind entry for the single hash entry. That'll give you your answer
there.

You can find out the number of entries in the hash with apr_hash_count.

> In svncpp we want to return the expanded path of all
> the files returned. In the file case this will return "foo"
> and in the dir case we return "foo/file-in-foo".
>
> The problem is the code is returning "foo/foo" in the file
> case and I'm not sure how to fix this for wc paths and URLs.
> For wc paths I can use svn_wc_entry() to get the kind of the
> path. But what would I do for URLs?

Why? svn_client_ls is already giving you the type in the kind entry in
the svn_dirent_t struct.

-- 
Ben Reser <ben@reser.org>
http://ben.reser.org
"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Mar 25 01:58:43 2004

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.