-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFunctions.cpp
More file actions
157 lines (148 loc) · 4.41 KB
/
Copy pathFunctions.cpp
File metadata and controls
157 lines (148 loc) · 4.41 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include <iostream>
#include <string>
#include <windows.h>
#include <locale>
#include <fstream>
#include "Functions.h"
#include "PlayList.h"
using namespace std;
wstring cd(string command, string &path)
{
if(!path.empty() && command.find("C:") && command.find("D:"))
{
path.pop_back();
cout<<path<<endl;
if(command.find("..")==0)
{
path.pop_back();
path=path.substr(0, path.rfind("\\"));
}
else
{
path+=command;
}
}
else
{
path=command;
}
path+="\\";
cout<<path<<endl;
path.push_back('*');
return wstring(path.begin(), path.end());
}
void ls(WIN32_FIND_DATA winFileData, HANDLE hFile)
{
if(hFile!=INVALID_HANDLE_VALUE)
{
while (FindNextFile(hFile,&winFileData)!=0) wcout<<winFileData.cFileName<<endl;
FindClose(hFile);
}
}
void playlist_create(string command, WIN32_FIND_DATA &winFileData, HANDLE &hFile)
{
string name_list=command.substr(0, command.find(" "));
//command=command.substr(command.find(" ")+1);
PlayList fplaylist(name_list);
fplaylist.out("#EXTM3U\n");
if(command.find(" ")<MAX_PATH)
{
string path=command.substr(command.find(" ")+1).append("\\*.mp3");
wstring wide_string=wstring(path.begin(), path.end());
hFile= FindFirstFile(wide_string.c_str(),&winFileData);
if (hFile!=INVALID_HANDLE_VALUE)
{
tags header;
//wcout<<winFileData.cFileName<<endl;
do {
fplaylist.out("#EXTINF: ");
FILE *file1;
wstring test(&winFileData.cFileName[0]);
string test2(test.begin(), test.end());
path=command.substr(command.find(" ")+1).append("\\")+test2;
cout<<path<<endl;
file1 = fopen(path.c_str(), "rb");
fseek(file1, -128, SEEK_END);
fread(&header,sizeof(header),1,file1);
fplaylist.out(header.name); fplaylist.out(" - ");
fplaylist.out(header.artist); fplaylist.out(" - ");
fplaylist.out(header.year); fplaylist.out("\n");
fplaylist.out(path.c_str()); fplaylist.out("\n");
fclose(file1);
}
while (FindNextFile(hFile, &winFileData)!=0);
FindClose(hFile);
}
}
cout<<"Was created!"<<endl;
}
void playlist_add_folder(string command, WIN32_FIND_DATA &winFileData, HANDLE &hFile)
{
string name_list=command.substr(0, command.find(" "));
string path=command.substr(command.find(" ")+1).append("\\*.mp3");
PlayList fplaylist(name_list, 0);
wstring wide_string=wstring(path.begin(), path.end());
hFile= FindFirstFile(wide_string.c_str(),&winFileData);
if (hFile!=INVALID_HANDLE_VALUE)
{
tags header;
//wcout<<winFileData.cFileName<<endl;
do {
fplaylist.out("#EXTINF: ");
FILE *file1;
wstring test(&winFileData.cFileName[0]);
string test2(test.begin(), test.end());
path=command.substr(command.find(" ")+1).append("\\")+test2;
cout<<path<<endl;
file1 = fopen(path.c_str(), "rb");
fseek(file1, -128, SEEK_END);
fread(&header,sizeof(header),1,file1);
fplaylist.out(header.name); fplaylist.out(" - ");
fplaylist.out(header.artist); fplaylist.out(" - ");
fplaylist.out(header.year); fplaylist.out("\n");
fplaylist.out(path.c_str()); fplaylist.out("\n");
fclose(file1);
}
while (FindNextFile(hFile, &winFileData)!=0);
FindClose(hFile);
}
cout<<"Was added!"<<endl;
}
void playlist_add_file(string command, WIN32_FIND_DATA &winFileData, HANDLE &hFile)
{
string name_list=command.substr(0, command.find(" "));
string path=command.substr(command.find(" ")+1).append(".mp3");
PlayList fplaylist(name_list, 0);
tags header;
FILE *file1;
cout<<path<<endl;
file1 = fopen(path.c_str(), "rb");
fplaylist.out("#EXTINF: ");
fseek(file1, -128, SEEK_END);
fread(&header,sizeof(header),1,file1);
fplaylist.out(header.name); fplaylist.out(" - ");
fplaylist.out(header.artist); fplaylist.out(" - ");
fplaylist.out(header.year); fplaylist.out("\n");
fplaylist.out(path.c_str()); fplaylist.out("\n");
fclose(file1);
cout<<"Was added!"<<endl;
}
void playlist_add_playlist(string command, WIN32_FIND_DATA &winFileData, HANDLE &hFile)
{
string name_list=command.substr(0, command.find(" "));
string name_list2=command.substr(command.find(" ")+1);
PlayList fplaylist(name_list, 0);
PlayList fplaylist1(name_list);
}
void help()
{
cout<<"Commanded:"<<endl;
cout<<"cd <name folder> or <name Disk(:)> or <..>"<<endl;
cout<<"ls - print name folder and file"<<endl;
cout<<"playlist create <name playlist> <name folder>"<<endl;
cout<<"playlist add <folder or file or playlist> <name>"<<endl;
}
void exit()
{
cout<<"END"<<endl;
}