#include "wangpan.h"
#include "version.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cstring>
#include <cstdlib>
using namespace std;
#if WANGPAN == _1_0_0
wang::wang()
{
this->name = string();
}
wang::wang(string Name) : name(Name)
{
}
wang::wang(char* Name) : name(Name)
{
}
int wang::menu()
{
cout << "========================================" << endl;
cout << "============1.使用路径打开文件=============" << endl;
cout << "===============2.新建文件夹===============" << endl;
cout << "===============3.新建文件================" << endl;
cout << "========================================" << endl;;
int n;
cin >> n;
return n;
}
void wang::display(string Name)
{
ifstream fin("./" + this->name + Name);
string s;
while(getline(fin,s))
{
cout << s << endl;
}
}
void wang::new_dir(string Url)
{
string s = "mkdir -p ./";
system(strcat(const_cast<char*>(s.c_str()), strcat(const_cast<char*>(this->name.c_str()),Url.c_str())));
}
void wang::new_file(string Url)
{
ofstream fout("./" + name + Url);
fout.close();
}
void wang::run()
{
int n;
while(true)
{
n = this->menu();
if(n == 1)
{
cout << "请输入文件名:";
getchar();
string s1;
getline(cin,s1);
this->display(s1);
continue;
}
if(n == 2)
{
cout << "请输入文件夹路径:";
getchar();
string dir;
getline(cin,dir);
this->new_dir(dir);
continue;
}
if(n == 3)
{
cout << "请输入文件夹路径:";
getchar();
string file;
getline(cin,file);
this->new_file(file);
continue;
}
}
}
void new_wang(wang &w,string name)
{
string s = "mkdir -p ./";
system(strcat(const_cast<char*>(s.c_str()),name.c_str()));
wang a(name);
w = a;
}
#endif