root/branches/perian-1.1/Update Checker Sources/main.m

Revision 923, 0.8 kB (checked in by astrange, 4 months ago)

Merge trunk to the branch.
Disable ssse3 qpel stuff (https://roundup.mplayerhq.hu/roundup/ffmpeg/issue463)

Line 
1 //
2 //  main.m
3 //  Perian
4 //
5 //  Created by Augie Fackler on 1/7/07.
6 //  Copyright 2007 __MyCompanyName__. All rights reserved.
7 //
8
9 #import <Cocoa/Cocoa.h>
10 #include <sys/stat.h>
11 #include <unistd.h>
12
13 #define lockPath "/tmp/PerianUpdateLock"
14
15 static int fp = -1;
16
17 static void deleteLock()
18 {
19         close(fp);
20         unlink(lockPath);
21 }
22
23 int main(int argc, char *argv[])
24 {
25         fp = open(lockPath, O_CREAT | O_EXCL);
26         if(fp == -1)
27         {
28                 struct stat lockfile;
29                 time_t current = time(NULL);
30                 if(stat(lockPath, &lockfile))
31                 {
32                         if(lockfile.st_ctimespec.tv_sec + 60*60 > current)  //Only pay attention to lock file if it is no more than an hour old
33                         {
34                                 unlink(lockPath);
35                                 fp = open(lockPath, O_CREAT | O_EXCL | O_EXLOCK);
36                         }
37                 }               
38         }
39         if(fp == -1)
40                 return 0;
41        
42         atexit(deleteLock);
43
44         int ret = NSApplicationMain(argc,  (const char **) argv);
45        
46         return ret;
47 }
Note: See TracBrowser for help on using the browser.