Просмотр исходного кода

dselect: Use modstatdb_can_lock() in refreshmenu() instead of ad-hoc code

Guillem Jover лет назад: 15
Родитель
Сommit
ad2f2b8ca2
1 измененных файлов с 3 добавлено и 8 удалено
  1. 3 8
      dselect/main.cc

+ 3 - 8
dselect/main.cc

@@ -397,8 +397,6 @@ static int
 refreshmenu(void)
 {
   char buf[2048];
-  static int l,lockfd;
-  static char *lockfile;
 
   curseson(); cbreak(); noecho(); nonl(); keypad(stdscr,TRUE);
 
@@ -425,14 +423,11 @@ refreshmenu(void)
   sprintf(buf, gettext(licensestring), DSELECT);
   addstr(buf);
 
-  l= strlen(admindir);
-  lockfile= new char[l+sizeof(LOCKFILE)+2];
-  strcpy(lockfile,admindir);
-  strcpy(lockfile+l, "/" LOCKFILE);
-  lockfd= open(lockfile, O_RDWR|O_CREAT|O_TRUNC, 0660);
-  if (errno == EACCES || errno == EPERM)
+  modstatdb_init(admindir);
+  if (!modstatdb_can_lock())
     addstr(_("\n\n"
              "Read-only access: only preview of selections is available!"));
+  modstatdb_done();
 
   return i;
 }