-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathusoundutils.h
63 lines (54 loc) · 2.09 KB
/
usoundutils.h
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
#ifndef UTILS_H
#define UTILS_H
#include <QDateTime>
#include <QDir>
#endif // UTILS_H
#include<thread>
#include<defaults.h>
#include <QDebug>
static std::string generateTimeStamp(){
QDateTime currentDateTime = QDateTime::currentDateTime();
return QDateTime::currentDateTime().toString("yyyy_MM_dd_hh_mm_ss_zzz").toLatin1().data();
}
static void mssleep(int ms){
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
static void createDirectories(){
qDebug() << "Initializing Directories . . .";
QDir qdir;
// App Dir
if (!qdir.exists(DIRECTORIES::APPDIR)) {
qDebug() << "Creating Application directory at "+DIRECTORIES::APPDIR;
qdir.mkpath(DIRECTORIES::APPDIR);
}
if (!qdir.exists(DIRECTORIES::APPDIR+"/"+DIRECTORIES::DATADIR)) {
qDebug() << "Creating Data directory at "+DIRECTORIES::APPDIR+"/"+DIRECTORIES::DATADIR;
qdir.mkpath(DIRECTORIES::APPDIR+"/"+DIRECTORIES::DATADIR);
}
}
static void initializeDirectoriesForDevice(QString deviceName){
qDebug() << "Initializing Directories for "+deviceName;
QDir qdir;
// App Dir
QString deviceDir = DIRECTORIES::APPDIR+"/"+DIRECTORIES::DATADIR+"/"+deviceName;
if (!qdir.exists(deviceDir)) {
qDebug() << "Creating device directory at "+deviceDir;
qdir.mkpath(deviceDir);
}
// Images
if (!qdir.exists(deviceDir+DIRECTORIES::IMAGESAVEDIR)) {
qDebug() << "Creating Image directory at "+deviceDir+DIRECTORIES::IMAGESAVEDIR;
qdir.mkpath(deviceDir+DIRECTORIES::IMAGESAVEDIR);
}
// Video
if (!qdir.exists(deviceDir+DIRECTORIES::VIDEOSAVEDIR)) {
qDebug() << "Creating Video directory at "+deviceDir+DIRECTORIES::VIDEOSAVEDIR;
qdir.mkpath(deviceDir+DIRECTORIES::VIDEOSAVEDIR);
}
}
static QString getImageSavePathForDevice(QString deviceName){
return DIRECTORIES::APPDIR+ "/" + DIRECTORIES::DATADIR+"/"+deviceName+DIRECTORIES::IMAGESAVEDIR;
}
static QString getVideoSavePathForDevice(QString deviceName){
return DIRECTORIES::APPDIR+ "/" + DIRECTORIES::DATADIR+"/"+deviceName+DIRECTORIES::VIDEOSAVEDIR;
}