FireBirdLib - Topfield TMS PVR TAP Programming Library
HDD_Unrecycle.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <string.h>
3#include "libFireBird.h"
4
5bool HDD_Unrecycle(const char *FileName)
6{
8
10 char OldName[TS_FILE_NAME_SIZE], NewName[TS_FILE_NAME_SIZE], LinuxPath[FBLIB_DIR_SIZE];
11 bool isRec, isDel, ret;
12 int fNumber;
13
14 ret = FALSE;
15 if(HDD_Exist(FileName))
16 {
17 ConvertPathType(FileName, LinuxPath, PF_FullLinuxPath);
18 SeparateFileNameComponents(LinuxPath, Path, Name, Ext, &fNumber, &isRec, &isDel);
19
20 if(isDel)
21 {
22 if(fNumber)
23 TAP_SPrint(NewName, "%s%s-%d%s", Path, Name, fNumber, Ext);
24 else
25 TAP_SPrint(NewName, "%s%s%s", Path, Name, Ext);
26
27 TAP_SPrint(OldName, "%s.del", NewName);
28 MakeUniqueFileName(NewName);
29 if(rename(OldName, NewName) == 0)
30 {
31 if(isRec && strcmp(Ext, ".nav"))
32 {
33 //.rec.inf
34 OldName[strlen(OldName) - 4] = '\0';
35 strcat(OldName, ".inf.del");
36 strcat(NewName, ".inf");
37 rename(OldName, NewName);
38
39 //.rec.nav
40 OldName[strlen(OldName) - 8] = '\0';
41 strcat(OldName, ".nav.del");
42 NewName[strlen(NewName) - 4] = '\0';
43 strcat(NewName, ".nav");
44 rename(OldName, NewName);
45
46 //.cut
47 OldName[strlen(OldName) - 12] = '\0';
48 strcat(OldName, ".cut.del");
49 NewName[strlen(NewName) - 8] = '\0';
50 strcat(NewName, ".cut");
51 rename(OldName, NewName);
52
53 //.cut.bak
54 OldName[strlen(OldName) - 8] = '\0';
55 strcat(OldName, ".cut.bak.del");
56 NewName[strlen(NewName) - 4] = '\0';
57 strcat(NewName, ".cut.bak");
58 rename(OldName, NewName);
59
60 //.srt
61 OldName[strlen(OldName) - 12] = '\0';
62 strcat(OldName, ".srt.del");
63 NewName[strlen(NewName) - 8] = '\0';
64 strcat(NewName, ".srt");
65 rename(OldName, NewName);
66 }
67 ret = TRUE;
68 }
69 }
70 }
71
72 TRACEEXIT();
73 return ret;
74}
void ConvertPathType(const char *Source, char *Dest, tPathFormat DestFormat)
bool HDD_Exist(const char *FileName)
Definition: HDD_Exist.c:4
bool HDD_Unrecycle(const char *FileName)
Definition: HDD_Unrecycle.c:5
void MakeUniqueFileName(char *FileName)
void SeparateFileNameComponents(const char *FileName, char *Path, char *Name, char *Ext, int *Index, bool *isRec, bool *isDel)
#define FBLIB_DIR_SIZE
Definition: libFireBird.h:1871
#define TRACEEXIT()
Definition: libFireBird.h:1244
#define TRACEENTER()
Definition: libFireBird.h:1243
#define TS_FILE_NAME_SIZE
Definition: libFireBird.h:167
@ PF_FullLinuxPath
Definition: libFireBird.h:1926