예제 #1
0
/// \brief TODOCUMENT
bool options_block::is_acceptable_output_file(const path &arg_output_file ///< TODOCUMENT
                                              ) {
	if (exists(arg_output_file) && !is_regular_file(arg_output_file)) {
		return false;
	}
	if (arg_output_file.has_parent_path() && !is_directory(arg_output_file.parent_path())) {
		return false;
	}
	return true;
}
예제 #2
0
void HTMLEditor::Save(const path & path)
{
    if (path.empty())
    {
        throw runtime_error("Path cannot be empty!");
    }

    if (path.has_parent_path())
    {
        create_directories(path.parent_path());
    }

    std::ofstream file(path.generic_string());

    if (!file.is_open())
    {
        throw runtime_error("Invalid path specified" + path.generic_string());
    }

    file << "<!DOCTYPE html>\n<html>\n<head>\n\t<title>" << EncodeHtmlStr(m_document.GetTitle()) << "</title>\n</head>\n"
        << "<body>\n" << CreateBody(path) << "</body>\n</html>";
    file.close();
}
예제 #3
0
static bool create_directory_if_missing_recursive(const path& dirpath)
{
	DBG_FS << "creating recursive directory: " << dirpath.string() << '\n';

	if (dirpath.empty())
		return false;
	error_code ec;
	bfs::file_status fs = bfs::status(dirpath);
	if (error_except_not_found(ec)) {
		ERR_FS << "Failed to retrieve file status for " << dirpath.string() << ": " << ec.message() << '\n';
		return false;
	} else if (bfs::is_directory(fs)) {
		return true;
	} else if (bfs::exists(fs)) {
		return false;
	}

	if (!dirpath.has_parent_path() || create_directory_if_missing_recursive(dirpath.parent_path())) {
		return create_directory_if_missing(dirpath);
	} else {
		ERR_FS << "Could not create parents to " << dirpath.string() << '\n';
		return false;
	}
}