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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.