#include <boost/utility/enable_if.hpp>
template <class T, bool alt = false>
struct Shablon
{
template <bool C>
typename boost::enable_if_c<C>::type doSomething() {
((T*)this)->m_member.foo();
((T*)this)->someFoo();
}
template <bool C>
typename boost::disable_if_c<C>::type doSomething() {
}
void foo()
{
doSomething<alt>();
((T*)this)->foo2();
}
};
#include <string>
#include <iostream>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
int main()
{
std::string const path = "/home/Work/cpp/";
std::string name;
std::cout << "Input project name: ";
std::cin >> name;
if (name.empty())
{
std::cerr << "Empty file name" << std::endl;
return EXIT_FAILURE;
}
std::string const dir = path + name;
if (mkdir(dir.c_str(), 0755) == -1)
{
perror("Cannot create directory");
return EXIT_FAILURE;
}
std::cerr << dir << " created" << std::endl;
return EXIT_SUCCESS;
}
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <linux/limits.h>
#define QUOTE_H(W) #W
#define QUOTE(W) QUOTE_H(W)
int main()
{
char name[NAME_MAX+1] = "";
char path[PATH_MAX] = "/home/Work/cpp/";
printf("Input project name: ");
if (scanf("%s"QUOTE(NAME_MAX), name) == -1)
{
fprintf(stderr, "Empty file name");
return EXIT_FAILURE;
}
size_t const max_name_len = PATH_MAX - 1 - strlen(path);
if (strlen(name) > max_name_len)
{
fprintf(stderr, "File name too long");
return EXIT_FAILURE;
}
strncat(path, name, max_name_len);
if (mkdir(path, 0755) == -1)
perror("Cannot create directory");
else
printf("'%s' created\n", path);
return EXIT_SUCCESS;
}