[dss-commits] r8885 - in dss/trunk/core: . metering sim web

dss-commits at forum.digitalstrom.org dss-commits at forum.digitalstrom.org
Thu Nov 5 09:58:35 CET 2009


Author: jwinkelmann
Date: 2009-11-05 09:58:35 +0100 (Thu, 05 Nov 2009)
New Revision: 8885

Modified:
   dss/trunk/core/base.cpp
   dss/trunk/core/base.h
   dss/trunk/core/event.cpp
   dss/trunk/core/eventinterpreterplugins.cpp
   dss/trunk/core/metering/metering.cpp
   dss/trunk/core/model.cpp
   dss/trunk/core/sim/dssim.cpp
   dss/trunk/core/web/webserverplugin.cpp
   dss/trunk/core/webserver.cpp
   dss/trunk/core/xmlwrapper.cpp
Log:
remove fileExists() from base.{cpp,h}

Modified: dss/trunk/core/base.cpp
===================================================================
--- dss/trunk/core/base.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/base.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -311,30 +311,6 @@
     return result;
   } // cRC16
 
-  //================================================== File utilities
-
-  bool fileExists( const std::string& _fileName ) {
-    return fileExists(_fileName.c_str());
-  } // fileExists
-
-  bool fileExists( const char* _fileName ) {
-    #ifdef WIN32
-      return (FileAge( _fileName ) != -1);
-    #else
-      #ifdef __GNU__
-        return euidaccess( _fileName, F_OK ) == 0;
-      #else
-        struct stat buf;
-        if( lstat( _fileName, &buf ) != -1 ) {
-          int fileType = (buf.st_mode & S_IFMT);
-          return fileType  == S_IFREG;
-        } else {
-          return false;
-        }
-      #endif
-    #endif
-  } // fileExists
-
   //================================================== System utilities
 
   void sleepSeconds( const unsigned int _seconds ) {

Modified: dss/trunk/core/base.h
===================================================================
--- dss/trunk/core/base.h	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/base.h	2009-11-05 08:58:35 UTC (rev 8885)
@@ -98,9 +98,6 @@
 
   //============================================= Encoding helpers
 
-  bool fileExists( const char* _fileName );
-  bool fileExists( const std::string& _fileName );
-
   uint16_t crc16(unsigned const char* _data, const int _size);
   uint16_t update_crc(uint16_t _crc, const unsigned char& c);
 

Modified: dss/trunk/core/event.cpp
===================================================================
--- dss/trunk/core/event.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/event.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -33,6 +33,8 @@
 #include <set>
 #include <iostream>
 
+#include <boost/filesystem.hpp>
+
 using std::set;
 using std::cout;
 
@@ -300,7 +302,7 @@
     const int apartmentConfigVersion = 1;
     Logger::getInstance()->log(string("EventInterpreter: Loading subscriptions from '") + _fileName + "'");
 
-    if(fileExists(_fileName)) {
+    if(boost::filesystem::exists(_fileName)) {
       XMLDocumentFileReader reader(_fileName);
 
       XMLNode rootNode = reader.getDocument().getRootNode();

Modified: dss/trunk/core/eventinterpreterplugins.cpp
===================================================================
--- dss/trunk/core/eventinterpreterplugins.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/eventinterpreterplugins.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -29,6 +29,7 @@
 #include "scripting/modeljs.h"
 
 #include <boost/scoped_ptr.hpp>
+#include <boost/filesystem.hpp>
 
 namespace dss {
 
@@ -72,7 +73,7 @@
   void EventInterpreterPluginJavascript::handleEvent(Event& _event, const EventSubscription& _subscription) {
     if(_subscription.getOptions().hasParameter("filename")) {
       string scriptName = _subscription.getOptions().getParameter("filename");
-      if(fileExists(scriptName)) {
+      if(boost::filesystem::exists(scriptName)) {
 
         if(!m_Environment.isInitialized()) {
           m_Environment.initialize();
@@ -106,7 +107,7 @@
           ScriptObject subscriptionObj(*ctx, NULL);
           raisedEvent.setProperty("subscription", &subscriptionObj);
           subscriptionObj.setProperty<const std::string&>("name", _subscription.getEventName());
-          
+
           ctx->evaluateScript<void>(scriptName);
 
           if(ctx->getKeepContext()) {

Modified: dss/trunk/core/metering/metering.cpp
===================================================================
--- dss/trunk/core/metering/metering.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/metering/metering.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -28,6 +28,8 @@
 #include "seriespersistence.h"
 #include "core/foreach.h"
 
+#include <boost/filesystem.hpp>
+
 namespace dss {
 
   //================================================== Metering
@@ -90,7 +92,7 @@
         // Load series from file
         std::string fileName = m_MeteringStorageLocation + (*ipModulator)->getDSID().toString() + "_" + _config->getFilenameSuffix(iConfig) + ".xml";
         log("Metering::checkModulators: Trying to load series from '" + fileName + "'");
-        if(fileExists(fileName)) {
+        if(boost::filesystem::exists(fileName)) {
           Timestamp startedLoadingSingle;
           boost::shared_ptr<Series<CurrentValue> > s = boost::shared_ptr<Series<CurrentValue> >(reader.readFromXML(fileName));
 #ifdef LOG_TIMING

Modified: dss/trunk/core/model.cpp
===================================================================
--- dss/trunk/core/model.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/model.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -33,6 +33,8 @@
 
 #include <fstream>
 
+#include <boost/filesystem.hpp>
+
 #include <Poco/DOM/Document.h>
 #include <Poco/DOM/Element.h>
 #include <Poco/DOM/Attr.h>
@@ -1080,7 +1082,7 @@
 
     // load devices/modulators/etc. from a config-file
     std::string configFileName = DSS::getInstance()->getPropertySystem().getStringValue(getConfigPropertyBasePath() + "configfile");
-    if(!fileExists(configFileName)) {
+    if(!boost::filesystem::exists(configFileName)) {
       Logger::getInstance()->log(string("Apartment::execute: Could not open config-file for apartment: '") + configFileName + "'", lsWarning);
     } else {
       readConfigurationFromXML(configFileName);

Modified: dss/trunk/core/sim/dssim.cpp
===================================================================
--- dss/trunk/core/sim/dssim.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/sim/dssim.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -98,7 +98,7 @@
         if(scriptFileNode != NULL) {
           if(simIDNode != NULL) {
             std::string scriptFile = scriptFileNode->getAsString();
-            if(!fileExists(scriptFile)) {
+            if(!boost::filesystem::exists(scriptFile)) {
               log("DSSim::initialize: cannot find script file '" + scriptFile + "', skipping", lsError);
               continue;
             }

Modified: dss/trunk/core/web/webserverplugin.cpp
===================================================================
--- dss/trunk/core/web/webserverplugin.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/web/webserverplugin.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -30,6 +30,8 @@
 
 #include <dlfcn.h>
 
+#include <boost/filesystem.hpp>
+
 namespace dss {
 
   WebServerPlugin::WebServerPlugin(const std::string& _uri, const std::string& _file)
@@ -46,7 +48,7 @@
   void WebServerPlugin::load() {
     assert(m_Handle == NULL);
     Logger::getInstance()->log("WebServerPlugin::load(): Trying to load \"" + m_File + "\"", lsInfo);
-    if(!fileExists(m_File)) {
+    if(!boost::filesystem::exists(m_File)) {
       throw std::runtime_error(std::string("Plugin '") + m_File + "' does not exist.");
     }
     m_Handle = dlopen(m_File.c_str(), RTLD_LAZY);

Modified: dss/trunk/core/webserver.cpp
===================================================================
--- dss/trunk/core/webserver.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/webserver.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -41,6 +41,7 @@
 #include <sstream>
 
 #include <boost/shared_ptr.hpp>
+#include <boost/filesystem.hpp>
 
 namespace dss {
   //============================================= WebServer
@@ -1781,7 +1782,7 @@
         } else {
           seriesPath = storageLocation + deviceDSIDString + "_" + fileSuffix + ".xml";
           log("_Trying to load series from " + seriesPath);
-          if(fileExists(seriesPath)) {
+          if(boost::filesystem::exists(seriesPath)) {
             SeriesReader<CurrentValue> reader;
             boost::shared_ptr<Series<CurrentValue> > s = boost::shared_ptr<Series<CurrentValue> >(reader.readFromXML(seriesPath));
             std::deque<CurrentValue>* values = s->getExpandedValues();

Modified: dss/trunk/core/xmlwrapper.cpp
===================================================================
--- dss/trunk/core/xmlwrapper.cpp	2009-11-05 08:58:31 UTC (rev 8884)
+++ dss/trunk/core/xmlwrapper.cpp	2009-11-05 08:58:35 UTC (rev 8885)
@@ -23,6 +23,8 @@
 
 #include <fstream>
 
+#include <boost/filesystem.hpp>
+
 namespace dss {
   //============================================= XMLNode
 
@@ -240,7 +242,7 @@
   }
 
   XMLDocument& XMLDocumentFileReader::getDocument() {
-    if(!fileExists(m_URI.c_str())) {
+    if(!boost::filesystem::exists(m_URI.c_str())) {
       throw XMLException(std::string("XMLDocumentFileReader::getDocument: File '") + m_URI + "' does not exist");
     }
 



More information about the dss-commits mailing list