--- a/src/hugin_cpfind/cpfind/PanoDetector.cpp
+++ b/src/hugin_cpfind/cpfind/PanoDetector.cpp
@@ -31,6 +31,7 @@
 #include "zthread/PoolExecutor.h"
 #include "Utils.h"
 #include "Tracer.h"
+#include "hugin_base/hugin_utils/platform.h"
 
 #include <algorithms/nona/ComputeImageROI.h>
 #include <nona/RemappedPanoImage.h>
@@ -112,7 +113,7 @@
     _writeAllKeyPoints(false), _verbose(1),
     _sieve1Width(10), _sieve1Height(10), _sieve1Size(100),
     _kdTreeSearchSteps(200), _kdTreeSecondDistance(0.25), _ransacIters(1000), _ransacDistanceThres(50),
-    _sieve2Width(5), _sieve2Height(5),_sieve2Size(1), _test(false), _cores(utils::getCPUCount()),
+    _sieve2Width(5), _sieve2Height(5),_sieve2Size(1), _test(false), _cores(hugin_utils::getCPUCount()),
     _minimumMatches(6), _linearMatchLen(1), _downscale(true), _cache(false), _cleanup(false),
     _keypath(""), _outputFile("default.pto"), _outputGiven(false), _celeste(false), _celesteThreshold(0.5), _celesteRadius(20), 
     _matchingStrategy(ALLPAIRS)
@@ -844,8 +845,7 @@
         // Specify if the image has an associated keypoint file
 
         aImgData._keyfilename = getKeyfilenameFor(_keypath,aImgData._name);
-        ifstream keyfile(aImgData._keyfilename.c_str());
-        aImgData._hasakeyfile = keyfile.good();
+        aImgData._hasakeyfile = hugin_utils::FileExists(aImgData._keyfilename);
         if(aImgData._hasakeyfile)
         {
             imgWithKeyfile++;