On 2013/01/20 17:24, Ben Boeckel <maths...@gmail.com> wrote:
> On Sun, Jan 20, 2013 at 17:14:12 +0100, Max Kellermann wrote:
> > - slightly disagree with Ben (but thanks for pointing out that
> >   potential problem): there should be some way to specify whether
> >   symbolic links shall be followed.  Some callers may want to follow
> >   symlinks, some do not, and the database update has that configurable
> >   at runtime.
> 
> Maybe have a CheckFileExists (stat) and a CheckPathExists (lstat)?

I think that's too obscure.  And doesn't scale: what about
CheckIsDirectory()?  You can't apply the same solution here.

What about a bool parameter:

 bool IsRegularFile(Path, bool follow_symlinks=true)

The compiler will make the stat/lstat choice disappear when a constant
value is passed.  May use another wrapper:

 static inline bool
 StatFile(const Path &path, struct stat &st, bool follow_symlinks=true)
 {
   return follow_symlinks ? stat(path.c_str(), &st) : lstat(path.c_str(), &st);
 }

(use native WIN32 functions on Windows)

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnmore_123012
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to