summaryrefslogtreecommitdiff
path: root/src/file.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/file.cc')
-rw-r--r--src/file.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/file.cc b/src/file.cc
index ce06d67..1a94150 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -31,6 +31,10 @@
/*
* $Log$
+ * Revision 1.2 2005/06/13 20:38:19 deva
+ * Added some logfile code.
+ * Enhanced the file object... now ready to hook into mov_encoder
+ *
* Revision 1.1 2005/06/09 17:54:00 deva
* New file object, that takes care of uniqueness and counts up number in
* filename, when grown too big.
@@ -51,10 +55,12 @@
#include <stdlib.h>
-File::File(char *fn, char* ext)
+File::File(char *fn, char* ext, Info *i)
{
char path[256];
+ info = i;
+
filename = (char*)malloc(strlen(fn) + 1);
extension = (char*)malloc(strlen(ext) + 1);
@@ -62,6 +68,7 @@ File::File(char *fn, char* ext)
strcpy(extension, ext);
num = 0;
+ seqnum = 0;
fd = -1;
int pos = (int)strrchr(filename, '/');
@@ -92,18 +99,29 @@ int File::Open()
fd = -1;
while(fd == -1) {
- sprintf(fname, "%s%.3d.%s", filename, num, extension);
+ if(seqnum) {
+ // A sequence number > 0
+ sprintf(fname, "%s%.3d-%d.%s", filename, num, seqnum, extension);
+ } else {
+ // A sequence number of 0
+ sprintf(fname, "%s%.3d.%s", filename, num, extension);
+ }
fd = open(fname, O_CREAT | O_WRONLY | O_SYNC | O_EXCL, //| O_LARGEFILE
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
num ++;
// If more than 1000 files are created in one day, something is terribly wrong!
if(num > 1000) {
- fprintf(stderr, "Something is wrong with tha path [%s]!\n", fname);
+ info->error("Something is wrong with the path [%s]!\n", fname);
exit(1);
}
}
+
+ seqnum ++;
+
+ info->log("Opened the file %s for output.\n", fname);
+
return 0;
}
@@ -114,10 +132,11 @@ int File::Write(void* data, int size)
w = write(fd, data, size);
if(w != size) {
+ info->log("Wrapping file.\n");
Open();
w = write(fd, data, size);
if(w != size) {
- fprintf(stderr, "Out of diskspace!\n");
+ info->error("Out of diskspace!\n");
exit(1);
}
}