r1006: configure: Use libx264_pic instead of libx264 if available.
[cinelerra_cv/mob.git] / cinelerra / removethread.C
blobd29fb69efb7c13edb79efaf831e12b542e0b272e
1 #include "bcwindowbase.inc"
2 #include "condition.h"
3 #include "mutex.h"
4 #include "removethread.h"
6 #include <string.h>
8 extern "C"
10 #include <uuid/uuid.h>
15 RemoveThread::RemoveThread()
16  : Thread()
18         input_lock = new Condition(0, "RemoveThread::input_lock", 0);
19         file_lock = new Mutex("RemoveThread::file_lock");
22 void RemoveThread::remove_file(char *path)
24 // Rename to temporary
25         uuid_t id;
26         uuid_generate(id);
27         char string[BCTEXTLEN];
28         strcpy(string, path);
29         uuid_unparse(id, string + strlen(string));
30         rename(path, string);
31 printf("RemoveThread::run: renaming %s -> %s\n", path, string);
32         
33         file_lock->lock("RemoveThread::remove_file");
34         files.append(strdup(string));
35         file_lock->unlock();
36         input_lock->unlock();
39 void RemoveThread::create_objects()
41         Thread::start();
44 void RemoveThread::run()
46         while(1)
47         {
48                 char string[BCTEXTLEN];
49                 string[0] = 0;
50                 input_lock->lock("RemoveThread::run");
51                 file_lock->lock("RemoveThread::remove_file");
52                 if(files.total)
53                 {
54                         strcpy(string, files.values[0]);
55                         files.remove_object_number(0);
56                 }
57                 file_lock->unlock();
58                 if(string[0])
59                 {
60 printf("RemoveThread::run: deleting %s\n", string);
61                         remove(string);
62                 }
63         }