From: Timo Sirainen Date: Fri, 13 Sep 2013 21:26:45 +0000 (+0300) Subject: lib-fs: If backend doesn't implement exists(), emulate it with stat(). X-Git-Tag: 2.2.6~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b6ecc96ac80d70e25a5e83d14383e2b8e17d29dd;p=thirdparty%2Fdovecot%2Fcore.git lib-fs: If backend doesn't implement exists(), emulate it with stat(). --- diff --git a/src/lib-fs/fs-api.c b/src/lib-fs/fs-api.c index 5fb99584dd..899d1ed172 100644 --- a/src/lib-fs/fs-api.c +++ b/src/lib-fs/fs-api.c @@ -536,8 +536,16 @@ void fs_unlock(struct fs_lock **_lock) int fs_exists(struct fs_file *file) { + struct stat st; int ret; + if (file->fs->v.exists == NULL) { + /* fallback to stat() */ + if (fs_stat(file, &st) == 0) + return 1; + else + return errno == ENOENT ? 0 : -1; + } T_BEGIN { ret = file->fs->v.exists(file); } T_END;