Changeset 17343 for trunk/FACT++


Ignore:
Timestamp:
11/23/13 12:58:48 (11 years ago)
Author:
tbretz
Message:
Removed DimWriteStatistics::CreateDirectory - can be replaced by boost::filesystem::create_directories (we loose the ability to set permissions explicitly, but linux users are used to get inherited permission for directory creation anyway
Location:
trunk/FACT++/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/DataProcessorImp.cc

    r17330 r17343  
    11#include "DataProcessorImp.h"
     2
     3#include <boost/filesystem.hpp>
    24
    35#include "HeadersFAD.h"
    46#include "EventBuilder.h"
    57#include "tools.h"
    6 
    7 #include "DimWriteStatistics.h" // weird dependency
    88
    99using namespace std;
     
    3232    try
    3333    {
    34         DimWriteStatistics::CreateDirectory(name.str());
     34        boost::filesystem::create_directories(name);
    3535    }
    3636    catch (const runtime_error &)
  • trunk/FACT++/src/DimWriteStatistics.cc

    r16742 r17343  
    132132// --------------------------------------------------------------------------
    133133//
    134 //! Check if a given path exists
    135 //! @param path the path to be checked
    136 //! @return whether or not the creation has been successfull
    137 //
    138 void DimWriteStatistics::CreateDirectory(string path)
    139 {
    140     namespace fs = boost::filesystem;
    141 
    142     //remove last '/', if present
    143     if (path[path.size()-1] == '/')
    144         path = path.substr(0, path.size()-1);
    145 
    146     //create boost path
    147     const fs::path fullPath = fs::system_complete(fs::path(path));
    148 
    149     //if path does not exist, check if upper levels exist already
    150     if (fs::exists(fullPath))
    151     {
    152         //if path already exist, make sure it does not designate a file (filenames cannot be checked if they do not exist)
    153         if (fs::is_directory(fullPath))
    154             return;
    155 
    156         throw runtime_error("Path to be created is a file  '" + path + "'");
    157     }
    158 
    159     // we're hitting "/", which SHOULD have existed...
    160     if (path.size() <= 1)
    161         throw runtime_error("Path to be created looks suspicious '"+path+"'");
    162 
    163     if (path.find_last_of('/')!=string::npos)
    164         CreateDirectory(path.substr(0, path.find_last_of('/')));
    165 
    166     //path does not exist, and upper level have been created already by recusrion.
    167     const mode_t rightsMask = S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH; //everybody read, owner writes
    168 
    169     if (mkdir(path.c_str(), rightsMask)==0)
    170         return;
    171 
    172     ostringstream str;
    173     str << "mkdir() failed for '" << path << "': " << strerror(errno) << " [errno=" << errno << "]";
    174     throw runtime_error(str.str());
    175 }
    176 
    177 // --------------------------------------------------------------------------
    178 //
    179134//! Sets the current folder
    180135//! @param folder the path to the folder
  • trunk/FACT++/src/DimWriteStatistics.h

    r11975 r17343  
    8282
    8383    static bool DoesPathExist(std::string path, MessageImp &log);
    84 
    85     static void CreateDirectory(std::string path);
    8684};
    8785
  • trunk/FACT++/src/datalogger.cc

    r17342 r17343  
    368368    void TrimOldRunNumbers();
    369369    ///Create a given directory
    370     bool CreateDirectory(string path);
     370    bool CreateDirectory(const string &path);
    371371    /***************************************************
    372372    * INHERITED FROM DimServiceInfoList
     
    509509//! @return whether or not the creation has been successfull
    510510//
    511 bool DataLogger::CreateDirectory(string path)
     511bool DataLogger::CreateDirectory(const string &path)
    512512{
    513513    try
    514514    {
    515         DimWriteStatistics::CreateDirectory(path);
     515        boost::filesystem::create_directories(path);
    516516        return true;
    517517    }
     
    532532    return DimWriteStatistics::DoesPathExist(path, *this);
    533533}
    534 
    535534
    536535void DataLogger::AddServer(const string& server)
Note: See TracChangeset for help on using the changeset viewer.