TemporaryDirectory::TemporaryDirectory(const std::string& aDirPath) { theDirPath = aDirPath; boost::filesystem::path myDirectory(theDirPath); if(!boost::filesystem::exists(myDirectory)) { std::string myError("Directory "); myError += theDirPath; myError += " does not exist"; throw std::runtime_error(myError); } if ( ! boost::filesystem::is_directory(myDirectory) ) { std::string myError = theDirPath; myError += " is not a directory"; throw std::runtime_error(myError); } boost::filesystem::directory_iterator myEndIter; boost::filesystem::directory_iterator myDirIter(myDirectory); for(/*void*/; myDirIter != myEndIter; ++myDirIter) { TemporaryFile * myFile = new TemporaryFile(theDirPath + "/" + myDirIter->leaf() ); theFiles.insert(std::make_pair(myFile->getFileName(), myFile)); } }
void TemporaryDirectory::createAndAddFile(int aFilesize) { TemporaryFile *myFile = new TemporaryFile(aFilesize, theDirPath); theFiles.insert(std::make_pair(myFile->getFileName(), myFile)); }