Testing if file exists?

Cesc Santa cesc.santa at gmail.com
Thu Jun 14 10:40:46 CEST 2007


what about opening (read mode, no create) and if no error, the file
exists? then close it, of course :)

On 6/14/07, Mikael Svensson <minisip at mikaelsvensson.info> wrote:
> Hello
>
> I "need" a function that tests whether or not a certain file exists and
> I got a lovely such function off the Internet. It works just fine under
>   Linux, but I'm guessing it won't work as smoothly under Windows.
>
> #include <string>
> #include <sys/stat.h>
> bool fileExist (std::string filename) {
>         struct stat buffer;
>         if (stat(filename.c_str(), &buffer)) {
>                 return false;
>         }
>         return true;
> }
>
>
> So...
>
> 1. Is there already a cross-platform "file existence tester" in Minisip?
>
> 2. If not, how could one implement such a function? (I could of course
> Google for one, but perhaps one of you already have an idea...)
>
> Regards
> Mikael
> _______________________________________________
> Minisip-devel mailing list
> Minisip-devel at minisip.org
> http://lists.minisip.org/mailman/listinfo/minisip-devel
>


More information about the Minisip-devel mailing list