Skip to content

Commit 08e32e0

Browse files
authored
Merge pull request #34 from ua0lnj/master
Added function for deleting files and empty directory. Version 1.5.0.
2 parents aab4053 + 9c9a1f4 commit 08e32e0

File tree

4 files changed

+82
-19
lines changed

4 files changed

+82
-19
lines changed

README

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ In the browser mode you can use
150150

151151
Red: Play selected file
152152
Green: Play selected directory, playlist mode
153-
Yellow: Shuffle playlist
153+
Yellow: Remove selected file or empty directory
154+
Blue: Shuffle playlist
154155

155156
The following remote keys are supported in normal operation (no disc menu active)
156157

filebrowser.c

Lines changed: 60 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ void cMpvFilebrowser::ShowDirectory(string Path)
8888
MenuTitle += " (" + Path.substr(rootDir.size() + 1, string::npos) + ")";
8989
SetTitle(MenuTitle.c_str());
9090
#ifdef USE_DISC
91-
SetHelp(tr("Disc"), Directories.size() ? tr("PlayDir") : NULL, tr("Shuffle"), NULL);
91+
SetHelp(tr("Disc"), Directories.size() ? tr("PlayDir") : NULL, tr("Remove"), tr("Shuffle"));
9292
#else
93-
SetHelp(NULL, Directories.size() ? tr("PlayDir") : NULL, tr("Shuffle"), NULL);
93+
SetHelp(NULL, Directories.size() ? tr("PlayDir") : NULL, tr("Remove"), tr("Shuffle"));
9494
#endif
9595
Display();
9696
}
@@ -134,19 +134,23 @@ int cMpvFilebrowser::PlayListCreate(string Path, FILE *fdPl)
134134

135135
if (!PlayDirectories.size() && !PlayFiles.size()) return -1;
136136

137-
sort(PlayDirectories.begin(), PlayDirectories.end());
138-
sort(PlayFiles.begin(), PlayFiles.end());
139-
140-
for (unsigned int i=0; i<PlayDirectories.size(); i++)
137+
if (fdPl)
141138
{
142-
string Filedir = Path + "/" + PlayDirectories[i];
143-
PlayListCreate(Filedir, fdPl);
144-
}
145139

146-
for (unsigned int i=0; i<PlayFiles.size(); i++)
147-
{
148-
string Filename = Path + "/" + PlayFiles[i];
149-
fprintf(fdPl, "%s\n", Filename.c_str());
140+
sort(PlayDirectories.begin(), PlayDirectories.end());
141+
sort(PlayFiles.begin(), PlayFiles.end());
142+
143+
for (unsigned int i=0; i<PlayDirectories.size(); i++)
144+
{
145+
string Filedir = Path + "/" + PlayDirectories[i];
146+
PlayListCreate(Filedir, fdPl);
147+
}
148+
149+
for (unsigned int i=0; i<PlayFiles.size(); i++)
150+
{
151+
string Filename = Path + "/" + PlayFiles[i];
152+
fprintf(fdPl, "%s\n", Filename.c_str());
153+
}
150154
}
151155
return 0;
152156
}
@@ -204,9 +208,9 @@ eOSState cMpvFilebrowser::ProcessKey(eKeys Key)
204208
if (!item) break;
205209
currentItem = item->Text();
206210
#ifdef USE_DISC
207-
SetHelp(tr("Disc"), item->IsDirectory() ? tr("PlayDir") : NULL, tr("Shuffle"), NULL);
211+
SetHelp(tr("Disc"), item->IsDirectory() ? tr("PlayDir") : NULL, tr("Remove"), tr("Shuffle"));
208212
#else
209-
SetHelp(NULL, item->IsDirectory() ? tr("PlayDir") : NULL, tr("Shuffle"), NULL);
213+
SetHelp(NULL, item->IsDirectory() ? tr("PlayDir") : NULL, tr("Remove"), tr("Shuffle"));
210214
#endif
211215
return State;
212216

@@ -215,7 +219,7 @@ eOSState cMpvFilebrowser::ProcessKey(eKeys Key)
215219
return osEnd;
216220
break;
217221

218-
case kYellow:
222+
case kBlue:
219223
item = (cMpvFilebrowserMenuItem *) Get(Current());
220224
if (!item) break;
221225
newPath = item->Path() + "/" + item->Text();
@@ -257,6 +261,46 @@ eOSState cMpvFilebrowser::ProcessKey(eKeys Key)
257261
}
258262
break;
259263

264+
case kYellow:
265+
item = (cMpvFilebrowserMenuItem *) Get(Current());
266+
if (!item) break;
267+
newPath = item->Path() + "/" + item->Text();
268+
if (item->IsDirectory())
269+
{
270+
int res;
271+
res = PlayListCreate(newPath, NULL);
272+
if (res != -1)
273+
{
274+
Skins.Message(mtError, tr("Not empty directory, can't remove!"));
275+
}
276+
else
277+
{
278+
if (Skins.Message(mtWarning, tr("Remove empty directory?"), 5) == kOk)
279+
{
280+
res = rmdir(newPath.c_str());
281+
if (res)
282+
{
283+
Skins.Message(mtError, tr("Unable to remove directory!"));
284+
}
285+
}
286+
}
287+
ShowDirectory(currentDir);
288+
}
289+
else
290+
{
291+
if (Skins.Message(mtWarning, tr("Remove file?"), 5) == kOk)
292+
{
293+
int res;
294+
res = remove(newPath.c_str());
295+
if (res)
296+
{
297+
Skins.Message(mtError, tr("Unable to remove file!"));
298+
}
299+
}
300+
}
301+
return osContinue;
302+
break;
303+
260304
default:
261305
break;
262306
}

mpv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "menu_options.h"
2020
#include "mpv_service.h"
2121

22-
static const char *VERSION = "1.4.4"
22+
static const char *VERSION = "1.5.0"
2323
#ifdef GIT_REV
2424
"-GIT" GIT_REV
2525
#endif

po/ru_RU.po

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ msgid ""
77
msgstr ""
88
"Project-Id-Version: vdr-mpv 0.0.4\n"
99
"Report-Msgid-Bugs-To: <see README>\n"
10-
"POT-Creation-Date: 2021-02-11 22:53+1000\n"
10+
"POT-Creation-Date: 2024-01-07 14:59+1000\n"
1111
"PO-Revision-Date: 2020-01-12 01:04+1000\n"
1212
"Last-Translator: ua0lnj\n"
1313
"Language-Team: ua0lnj\n"
@@ -56,12 +56,30 @@ msgstr "Диск"
5656
msgid "PlayDir"
5757
msgstr "Проиграть"
5858

59+
msgid "Remove"
60+
msgstr "Удалить"
61+
5962
msgid "Shuffle"
6063
msgstr "Смешать"
6164

6265
msgid "Playlist cannot be created!"
6366
msgstr "Нельзя создать плейлист!"
6467

68+
msgid "Not empty directory, can't remove!"
69+
msgstr "Не пустая папка, нельзя удалить!"
70+
71+
msgid "Remove empty directory?"
72+
msgstr "Удалить пустую папку?"
73+
74+
msgid "Unable to remove directory!"
75+
msgstr "Не могу удалить папку!"
76+
77+
msgid "Remove file?"
78+
msgstr "Удалить файл?"
79+
80+
msgid "Unable to remove file!"
81+
msgstr "Не могу удалить файл!"
82+
6583
msgid "Options"
6684
msgstr "Опции"
6785

0 commit comments

Comments
 (0)