DE (FreeBSD): add fast path for xfce4 version detection

This commit is contained in:
李通洲
2023-08-29 10:47:24 +08:00
parent a3f13bdca9
commit bddcb4772c
3 changed files with 45 additions and 1 deletions
+6 -1
View File
@@ -1,3 +1,8 @@
# 2.0.6
Features:
* Add fast path for xfce4 version detection (DE, FreeBSD)
# 2.0.5
Bugfixes:
@@ -11,7 +16,7 @@ Features:
# 2.0.4
Bugfixes:
* Fix building on 32-bit FreeBSD (Memory, BSD)
* Fix building on 32-bit FreeBSD (Memory, FreeBSD)
* Fix `--file-raw` doesn't work (Logo)
Features:
+22
View File
@@ -12,6 +12,7 @@
typedef HANDLE FFNativeFD;
#else
#include <unistd.h>
#include <dirent.h>
typedef int FFNativeFD;
#endif
@@ -130,4 +131,25 @@ static inline bool wrapFclose(FILE** pfile)
}
#define FF_AUTO_CLOSE_FILE __attribute__((__cleanup__(wrapFclose)))
#ifndef _WIN32
static inline bool wrapClosedir(DIR** pdir)
{
assert(pdir);
if (!*pdir)
return false;
closedir(*pdir);
return true;
}
#else
static inline bool wrapClosedir(HANDLE* pdir)
{
assert(pdir);
if (!*pdir)
return false;
FindClose(*pdir);
return true;
}
#endif
#define FF_AUTO_CLOSE_DIR __attribute__((__cleanup__(wrapClosedir)))
#endif // FF_INCLUDED_common_io_io
+17
View File
@@ -233,6 +233,23 @@ static void getXFCE4(FFDisplayServerResult* result)
ffStrbufSetS(&result->dePrettyName, FF_DE_PRETTY_XFCE4);
ffParsePropFileData("gtk-doc/html/libxfce4ui/index.html", "<div><p class=\"releaseinfo\">Version", &result->deVersion);
#ifdef __FreeBSD__
if(result->deVersion.length == 0)
{
FF_AUTO_CLOSE_DIR DIR* dirp = opendir("/usr/local/share/licenses/");
if (dirp)
{
struct dirent* entry;
while((entry = readdir(dirp)) != NULL)
{
if(!ffStrStartsWith(entry->d_name, "xfce-") || !isdigit(entry->d_name[5]))
continue;
ffStrbufAppendS(&result->deVersion, &entry->d_name[5]);
}
}
}
#endif
if(result->deVersion.length == 0 && instance.config.allowSlowOperations)
{
//This is somewhat slow