36 int FreeMB(
int *UsedMB = NULL);
43 const char *
Adjust(
const char *FileName);
72 while (l-- > 0 && isdigit(
name[l]))
76 int n = atoi(&
name[l]);
113 const char *ActualFileName = FileName;
122 if ((Flags & O_CREAT) != 0) {
126 int MaxFree = Dir.
FreeMB();
129 if (Free > MaxFree) {
135 ActualFileName = Dir.
Adjust(FileName);
136 if (!
MakeDirs(ActualFileName,
false))
138 if (symlink(ActualFileName, FileName) < 0) {
142 ActualFileName = strdup(ActualFileName);
147 if (ActualFileName != FileName)
148 free((
char *)ActualFileName);
154 int Result = File->
Close();
164 if (rename(OldName, NewName) == -1) {
180 if (Dir.
FreeMB() >= SizeMB * 2)
183 if (Dir.
FreeMB() >= SizeMB)
188 return Dir.
FreeMB() >= SizeMB;
193 int free = 0, used = 0;
200 }
while (Dir.
Next());
209 return (free + used) ? used * 100 / (free + used) : 0;
214 char PrefixedName[strlen(FileName) + 2];
216 const char *p = FileName + strlen(FileName);
218 while (p-- > FileName && n > 0) {
221 int l = p - FileName + 1;
222 strncpy(PrefixedName, FileName, l);
223 PrefixedName[l] = Prefix;
224 strcpy(PrefixedName + l + 1, p + 1);
236 const char *p = FileName + strlen(FileName);
237 while (p-- > FileName) {
253 }
while (Dir.
Next());
262 }
while (Dir.
Next());
268 #define DISKSPACECHEK 5 // seconds between disk space checks
269 #define MB_PER_MINUTE 25.75 // this is just an estimate!
286 if (MBperMinute <= 0)
293 if (State !=
state) {
cString NewVideoFileName(const char *FileName, const char *NewDirName)
int TotalFileSizeMB(void)
bool RemoveVideoFile(const char *FileName)
static cString String(void)
Returns a localized string of the form "Disk nn% - hh:mm free".
void SetVideoDirectory(const char *Directory)
bool VideoFileSpaceAvailable(int SizeMB)
static cString sprintf(const char *fmt,...) __attribute__((format(printf
const char * VideoDirectory
cUnbufferedFile * OpenVideoFile(const char *FileName, int Flags)
const char * Adjust(const char *FileName)
void RemoveEmptyVideoDirectories(const char *IgnoreFiles[])
cUnbufferedFile is used for large files that are mainly written or read in a streaming manner...
static bool HasChanged(int &State)
Returns true if the usage of the video disk space has changed since the last call to this function wi...
int FreeMB(int *UsedMB=NULL)
cRecordings DeletedRecordings
const char * Stored(void)
int VideoDiskSpace(int *FreeMB, int *UsedMB)
cString PrefixVideoFileName(const char *FileName, char Prefix)
bool IsOnVideoDirectoryFileSystem(const char *FileName)
double MBperMinute(void)
Returns the average data rate (in MB/min) of all recordings, or -1 if this value is unknown...
int CloseVideoFile(cUnbufferedFile *File)
static cUnbufferedFile * Create(const char *FileName, int Flags, mode_t Mode=DEFFILEMODE)
char * ExchangeChars(char *s, bool ToFileSystem)
bool RenameVideoFile(const char *OldName, const char *NewName)
static time_t lastChecked
static int FreeMB(void)
Returns the amount of free space on the video disk in MB.
static int UsedPercent(void)
Returns the used space of the video disk in percent.