-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_dir.cpp
More file actions
27 lines (24 loc) · 769 Bytes
/
create_dir.cpp
File metadata and controls
27 lines (24 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <unistd.h>
#include <iostream>
#include <sys/stat.h>
using namespace std;
void create_dir(string foldername, string folderlocation){
string filelocation;
if(folderlocation[folderlocation.length()-1] =='/'){
filelocation = folderlocation+foldername;
} else
filelocation = folderlocation + "/" + foldername;
int k = mkdir(filelocation.c_str(), S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IXOTH);
if(k==0){
cout << "Folder created succesfully." << endl;
} else {
cout << "Folder could not be created." << endl;
}
}
int main(int argc, char const *argv[])
{
string foldername = argv[1];
string folderlocation = argv[2];
create_dir(foldername, folderlocation);
return 0;
}