Use new location for thumbnails directory as per thumbnails std 8.0
This commit is contained in:
parent
20a5a01f9a
commit
05fb1ad4a3
3 changed files with 47 additions and 9 deletions
|
@ -111,6 +111,9 @@ RclConfig *recollinit(RclInitFlags flags,
|
||||||
// Init unac locking
|
// Init unac locking
|
||||||
unac_init_mt();
|
unac_init_mt();
|
||||||
|
|
||||||
|
// Init pathut static values
|
||||||
|
pathut_init_mt();
|
||||||
|
|
||||||
// Init Unac translation exceptions
|
// Init Unac translation exceptions
|
||||||
string unacex;
|
string unacex;
|
||||||
if (config->getConfParam("unac_except_trans", unacex) && !unacex.empty())
|
if (config->getConfParam("unac_except_trans", unacex) && !unacex.empty())
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <glob.h>
|
||||||
|
|
||||||
// Let's include all files where statfs can be defined and hope for no
|
// Let's include all files where statfs can be defined and hope for no
|
||||||
// conflict...
|
// conflict...
|
||||||
|
@ -359,10 +360,8 @@ extern string path_canon(const string &is)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <glob.h>
|
|
||||||
#include <sys/stat.h>
|
vector<string> path_dirglob(const string &dir, const string pattern)
|
||||||
vector<string> path_dirglob(const string &dir,
|
|
||||||
const string pattern)
|
|
||||||
{
|
{
|
||||||
vector<string> res;
|
vector<string> res;
|
||||||
glob_t mglob;
|
glob_t mglob;
|
||||||
|
@ -626,12 +625,36 @@ int Pidfile::remove()
|
||||||
return unlink(m_path.c_str());
|
return unlink(m_path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Freedesktop standard paths for thumbnails
|
|
||||||
|
// Freedesktop standard paths for cache directory (thumbnails are now in there)
|
||||||
|
static const string& xdgcachedir()
|
||||||
|
{
|
||||||
|
static string xdgcache;
|
||||||
|
if (xdgcache.empty()) {
|
||||||
|
const char *cp = getenv("XDG_CACHE_HOME");
|
||||||
|
if (cp == 0)
|
||||||
|
xdgcache = path_cat(path_home(), ".cache");
|
||||||
|
else
|
||||||
|
xdgcache = string(cp);
|
||||||
|
}
|
||||||
|
return xdgcache;
|
||||||
|
}
|
||||||
|
static const string& thumbnailsdir()
|
||||||
|
{
|
||||||
|
static string thumbnailsd;
|
||||||
|
if (thumbnailsd.empty()) {
|
||||||
|
thumbnailsd = path_cat(xdgcachedir(), "thumbnails");
|
||||||
|
if (access(thumbnailsd.c_str(), 0) != 0) {
|
||||||
|
thumbnailsd = path_cat(path_home(), ".thumbnails");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return thumbnailsd;
|
||||||
|
}
|
||||||
|
|
||||||
// Place for 256x256 files
|
// Place for 256x256 files
|
||||||
static const string thmbdirlarge = ".thumbnails/large";
|
static const string thmbdirlarge = "large";
|
||||||
// 128x128
|
// 128x128
|
||||||
static const string thmbdirnormal = ".thumbnails/normal";
|
static const string thmbdirnormal = "normal";
|
||||||
|
|
||||||
static void thumbname(const string& url, string& name)
|
static void thumbname(const string& url, string& name)
|
||||||
{
|
{
|
||||||
|
@ -647,13 +670,13 @@ bool thumbPathForUrl(const string& url, int size, string& path)
|
||||||
string name;
|
string name;
|
||||||
thumbname(url, name);
|
thumbname(url, name);
|
||||||
if (size <= 128) {
|
if (size <= 128) {
|
||||||
path = path_cat(path_home(), thmbdirnormal);
|
path = path_cat(thumbnailsdir(), thmbdirnormal);
|
||||||
path = path_cat(path, name);
|
path = path_cat(path, name);
|
||||||
if (access(path.c_str(), R_OK) == 0) {
|
if (access(path.c_str(), R_OK) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
path = path_cat(path_home(), thmbdirlarge);
|
path = path_cat(thumbnailsdir(), thmbdirlarge);
|
||||||
path = path_cat(path, name);
|
path = path_cat(path, name);
|
||||||
if (access(path.c_str(), R_OK) == 0) {
|
if (access(path.c_str(), R_OK) == 0) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -668,6 +691,15 @@ bool thumbPathForUrl(const string& url, int size, string& path)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call funcs that need static init (not initially reentrant)
|
||||||
|
void pathut_init_mt()
|
||||||
|
{
|
||||||
|
path_home();
|
||||||
|
tmplocation();
|
||||||
|
thumbnailsdir();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#else // TEST_PATHUT
|
#else // TEST_PATHUT
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
@ -138,4 +138,7 @@ private:
|
||||||
// returns true if the file already exists
|
// returns true if the file already exists
|
||||||
extern bool thumbPathForUrl(const string& url, int size, string& path);
|
extern bool thumbPathForUrl(const string& url, int size, string& path);
|
||||||
|
|
||||||
|
// Must be called in main thread before starting other threads
|
||||||
|
extern void pathut_init_mt();
|
||||||
|
|
||||||
#endif /* _PATHUT_H_INCLUDED_ */
|
#endif /* _PATHUT_H_INCLUDED_ */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue