~ps-jenkins/mediascanner2/trusty-proposed

« back to all changes in this revision

Viewing changes to src/daemon/util.cc

  • Committer: CI bot
  • Author(s): Jussi Pakkanen
  • Date: 2014-04-03 10:00:00 UTC
  • mfrom: (222.2.2 mediascanner)
  • Revision ID: ps-jenkins@lists.canonical.com-20140403100000-u99sz6i0g2ag8fep
The output value of stat is undefined when the stat call fails. So don't use it. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include "util.h"
21
21
 
22
22
#include<sys/stat.h>
 
23
#include<cstring>
23
24
 
24
25
using namespace std;
25
26
 
26
27
static bool dir_exists(const string &path) {
27
28
    struct stat statbuf;
28
 
    stat(path.c_str(), &statbuf);
 
29
    if(stat(path.c_str(), &statbuf) < 0) {
 
30
        if(errno != ENOENT) {
 
31
            printf("Error while trying to determine state of dir %s: %s\n", path.c_str(), strerror(errno));
 
32
        }
 
33
        return false;
 
34
    }
29
35
    return S_ISDIR(statbuf.st_mode) ;
30
36
}
31
37