Example #1
0
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));
    }
}
Example #2
0
TemporaryDirectory::~TemporaryDirectory()
{
    Files::iterator myIter = theFiles.begin();
    Files::const_iterator myEnd = theFiles.end();
    for(/*void*/; myIter != myEnd; ++myIter)
    {
        delete myIter->second;
    }

    boost::filesystem::path myDirectory(theDirPath);

    boost::filesystem::remove(myDirectory);
}
Example #3
0
void testApp::saveImages(){
	
	
	// create a directory for each recording
	
	ofDirectory myDirectory( ofToString(recordingCount));
	if (!myDirectory.exists()){
		myDirectory.create();
	} else {
		myDirectory.listDir();
		for (int i = 0; i < myDirectory.size(); i++){
		
			ofFile temp(myDirectory.getPath(i));
			temp.remove(true);
		}
	}
	
	// save these images to that directory
	for (int i = 0; i < imgs.size(); i++){
		imgs[i]->saveImage(ofToString(recordingCount) + "/frame_" + ofToString(i) + ".png");
		delete imgs[i];
        	}
		
	imgs.clear();
	dir.reset();
	
	
	// clear the playing images
	
	for (int i = 0; i < data.size(); i++){
		delete data[i];
	}
	data.clear();
	
	// reload images
	
	ofDirectory dir;
	dir.listDir(ofToString(recordingCount) );
	for (int i = 0; i < dir.size(); i++){
		string fileName = dir.getPath(i);
		ofImage * temp = new ofImage;
		temp->loadImage(dir.getPath(i));
		data.push_back(temp);
	}
	
	recordingCount++;
		
}