Пример #1
0
void ThreadedFileManager::setDirectoryPath(std::string directory_path)
{
	if(!directory_path_.empty())
	{
		throw FileManagerException("Directory has already been set to " + directory_path_.string() + ".");
	}
	else
	{
		directory_path_ = directory_path;
	}

	if(!fs::is_directory(directory_path_))		// check existance
	{
		DEBUG("The specified mailspooldirectory [ "
				<< directory_path_.string().c_str()
				<< " ] is not a valid directory.");

		throw FileManagerException("Not a directory.");
	}

	if(access(directory_path_.string().c_str(), R_OK | W_OK) == -1) // check permissions
	{
		DEBUG("You don't have sufficient(rw) permissions for the specified directory [ "
				<< directory_path_.string().c_str()
				<< " ].");

		throw FileManagerException("Missing permissions.");
	}

	DEBUG("The mailspooldirectory is at " << directory_path_ << ".");
}
Пример #2
0
void FileManager::add(seqan::CharString pattern, seqan::CharString filename) {
    fmapping_t::iterator it = mFilenameMapping.find(filename);
    if (it == mFilenameMapping.end()) {
    
        mMapping[pattern] = mOutfiles.size();
        mFilenameMapping[filename] = mMapping[pattern];
        std::ofstream * out = new std::ofstream(seqan::toCString(filename));
        mOutfiles.push_back(out);

        if(! out->good()) {
            seqan::CharString msg = "cannot open file ";
            msg += filename;
            throw FileManagerException(seqan::toCString(msg));
        }
        // get the sequence and its reverse complement
        // pointing to the output file
        seqan::CharString rc = pattern;
        seqan::reverseComplement(rc);
        mMapping[rc] = mMapping[pattern];
    } else {
        mMapping[pattern] = it->second;
        seqan::CharString rc = pattern;
        seqan::reverseComplement(rc);
        mMapping[rc] = mMapping[pattern];
    }
}
Пример #3
0
FileManager::FileManager(std::map<seqan::CharString, seqan::CharString>& mapping){
    std::map<seqan::CharString, seqan::CharString>::iterator it;
    for (it = mapping.begin(); it != mapping.end(); it++) {
        if(seqan::empty(it->second)) {
            throw FileManagerException("You must have a file associated with every pattern");
        }
        add(it->first, it->second);
    }
    noDelete = false;
}
Пример #4
0
void FileManager::add(seqan::CharString pattern) {
        mMapping[pattern] = mOutfiles.size();
        std::ostream * out = new std::ofstream();
        out->rdbuf(std::cout.rdbuf());
        mOutfiles.push_back(out);

        if(! out->good()) {
            seqan::CharString msg = "cannot bind cout";
            throw FileManagerException(seqan::toCString(msg));
        }
        // get the sequence and its reverse complement
        // pointing to the output file
        seqan::CharString rc = pattern;
        seqan::reverseComplement(rc);
        mMapping[rc] = mMapping[pattern];
    noDelete = true;
}