- Timestamp:
- 2013-06-12T09:32:20+12:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/common-src/src/gdbmedit/db2txt/db2txt.cpp
r26650 r27597 31 31 32 32 #else 33 34 /* header file for mkdir */ 35 #include <sys/stat.h> 36 33 37 #include <gdbm.h> 34 38 #endif … … 57 61 cerr << "usage: " << program_name << " database-name" << endl << endl; 58 62 } 63 64 65 #ifdef _MSC32_ 66 // Windows implementation 67 HANDLE hFile = CreateFile(_T("c:\\file.txt"), GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); 68 69 #else 70 // assume Unix 71 // lock a file on linux 72 // [hs, 2 july 2010] 73 // - modified to create a locl file local to the collection [jmt12] 74 int lock () 75 { 76 string file_path (""); 77 char *collect_dir = getenv ("GSDLCOLLECTDIR"); 78 if (collect_dir != NULL) 79 { 80 file_path += collect_dir; 81 } 82 file_path += "/tmp"; 83 if ( access( file_path.c_str(), 00 ) != 0 ) 84 { 85 mkdir(file_path.c_str(), 00777); 86 } 87 file_path += "/gdb.lock"; 88 ///out << "txt2dbl::lock(" << file_path << ") => "; 89 int fd2 = open (file_path.c_str(), O_CREAT|O_RDWR, 00644); 90 close (fd2); 91 int fd = open (file_path.c_str(), O_RDWR); 92 flock lock = {F_WRLCK, SEEK_SET, 0, 0, 0}; 93 fcntl (fd, F_SETLKW, &lock); 94 ///out << "locked!" << endl; 95 return fd; 96 } 97 98 // unlock a file on linux 99 // [hs, 2 july 2010] 100 int unlock ( int fd ) 101 { 102 flock lock1 = {F_UNLCK, SEEK_SET, 0, 0, 0}; 103 fcntl (fd, F_SETLKW, &lock1); 104 return 0; 105 } 106 #endif 59 107 60 108
Note:
See TracChangeset
for help on using the changeset viewer.