-
Notifications
You must be signed in to change notification settings - Fork 1
/
createdir.cpp
85 lines (76 loc) · 2.12 KB
/
createdir.cpp
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "createdir.h"
#include <QDebug>
#include <QDir>
#include <QMessageBox>
// Global vars
QString rootDir;
QDir dir;
void Createdir::rootDirCreator(QString &driveLetter, QString &year,
QString &semester, QString labOrTheory) {
// Checking the year
if (year == "1")
year += "st";
else if (year == "2")
year += "nd";
else if (year == "3")
year += "rd";
else
year += "th";
// Checking the semester
if (semester == "1")
semester += "st";
else if (semester == "2")
semester += "nd";
else if (semester == "3")
semester += "rd";
else
semester += "th";
// Creating the folders
rootDir = driveLetter + "University Study/Study Materials/" + year +
" Year/" + semester + " Semester/" + labOrTheory + "/";
dir.setPath(rootDir);
dir.mkpath(rootDir);
if (dir.exists()) {
qDebug() << "Root folders created successfully";
} else {
qDebug() << "Could not create root folders";
}
// if (dir.exists()){
// qDebug()<<"Folder already exixts";
// }
// else
// {
// dir.mkpath(rootDir);
// qDebug()<<"Root Directory created";
// }
}
// Return Lab or Theory depending on what user has selected
QString Createdir::labOrtheory(bool isLabSelected, bool isTheorySelected) {
if (isLabSelected)
return "Lab";
else if (isTheorySelected)
return "Theory";
else
return 0;
}
// Creates Subject folders based on user's given names & adds mid-term &
// final-term folders inside each sub folder
void Createdir::subFolderCreator(QString *subNameHolder, int labSubNo) {
for (int i = 0; i < labSubNo; i++) {
dir.mkpath(rootDir + subNameHolder[i] + "/Mid-Term/Lessons");
dir.mkpath(rootDir + subNameHolder[i] + "/Final-Term/Lessons");
}
// Checking if the subject folders have been created or not
dir.setPath(rootDir + subNameHolder[0]);
if (dir.exists())
qDebug() << "Subject folders created successfully";
else
qDebug() << "Could not created subject folders";
}
bool Createdir::isdDirCreationSuccessfull() {
dir.setPath(rootDir);
if (dir.exists())
return true;
else
return false;
}