Beispiel #1
0
QDir
lastfm::dir::cache()
{
#ifdef Q_OS_MAC
    return ensurePathExists( QDir::home().filePath( "Library/Caches/Last.fm" ) );
#else
    return ensurePathExists( runtimeData().filePath( "cache" ) );
#endif
}
Beispiel #2
0
QString PathResolve::tempPath()
{
    QString path = QDir::tempPath() + "/WizNote/";
    ensurePathExists(path);

    return path;
}
Beispiel #3
0
void FileName::ensurePathToNameExists(const char *name)
{
    const char *pt = path(name);
    if (*pt)
        ensurePathExists(pt);
    free(pt);
}
Beispiel #4
0
QString PathResolve::dataStorePath()
{
    QString strPath = QDir::homePath();
    strPath += "/.wiznote/";

    ensurePathExists(strPath);
    return strPath;
}
Beispiel #5
0
QDir
lastfm::dir::logs()
{
#ifdef Q_OS_MAC
    return ensurePathExists( QDir::home().filePath( "Library/Logs/Last.fm" ) );
#else
    return runtimeData();    
#endif
}
Beispiel #6
0
int FileName::ensurePathExists(const char *path)
{
    //printf("FileName::ensurePathExists(%s)\n", path ? path : "");
    if (path && *path)
    {
        if (!exists(path))
        {
            const char *p = FileName::path(path);
            if (*p)
            {
#if _WIN32
                size_t len = strlen(path);
                if ((len > 2 && p[-1] == ':' && strcmp(path + 2, p) == 0) ||
                    len == strlen(p))
                {   mem.free((void *)p);
                    return 0;
                }
#endif
                int r = ensurePathExists(p);
                mem.free((void *)p);
                if (r)
                    return r;
            }
#if _WIN32
            char sep = '\\';
#elif POSIX
            char sep = '/';
#endif
            if (path[strlen(path) - 1] != sep)
            {
                //printf("mkdir(%s)\n", path);
#if _WIN32
                int r = _mkdir(path);
#endif
#if POSIX
                int r = mkdir(path, 0777);
#endif
                if (r)
                {
                    /* Don't error out if another instance of dmd just created
                     * this directory
                     */
                    if (errno != EEXIST)
                        return 1;
                }
            }
        }
    }
    return 0;
}
Beispiel #7
0
static QDir dataDotDot()
{
#ifdef WIN32
    if ((QSysInfo::WindowsVersion & QSysInfo::WV_DOS_based) == 0)
    {
        // Use this for non-DOS-based Windowses
        char path[MAX_PATH];
        HRESULT h = SHGetFolderPathA( NULL, 
                                      CSIDL_LOCAL_APPDATA | CSIDL_FLAG_CREATE,
                                      NULL, 
                                      0, 
                                      path );
        if (h == S_OK)
            return QString::fromLocal8Bit( path );
    }
    return QDir::home();
#elif defined(Q_OS_MAC)
    return ensurePathExists( QDir::home().filePath( "Library/Application Support" ) );
#elif defined(Q_OS_LINUX) || defined(Q_OS_UNIX)
    return ensurePathExists( QDir::home().filePath( ".local/share" ) );
#else
    return QDir::home();
#endif
}
Beispiel #8
0
QString PathResolve::cachePath()
{
    QString strCachePath = qgetenv("XDG_CACHE_HOME");
    if (strCachePath.isEmpty()) {
#ifdef Q_OS_LINUX
        strCachePath = qgetenv("HOME") + "/.cache/wiznote/";
#else
        strCachePath = dataStorePath() + "cache/";
#endif
    } else {
        strCachePath += "/wiznote/";
    }

    ensurePathExists(strCachePath);
    return strCachePath;
}
Beispiel #9
0
void FileName::ensurePathExists(const char *path)
{
    //printf("FileName::ensurePathExists(%s)\n", path ? path : "");
    if (path && *path)
    {
        if (!exists(path))
        {
            char *p = FileName::path(path);
            if (*p)
            {
#if _WIN32
                size_t len = strlen(path);
                if (len > 2 && p[-1] == ':' && path + 2 == p)
                {   mem.free(p);
                    return;
                }
#endif
                ensurePathExists(p);
                mem.free(p);
            }
#if _WIN32
            if (path[strlen(path) - 1] != '\\')
#endif
#if POSIX
            if (path[strlen(path) - 1] != '\\')
#endif
            {
                //printf("mkdir(%s)\n", path);
#if _WIN32
                if (_mkdir(path))
#endif
#if POSIX
                if (mkdir(path, 0777))
#endif
                {
                    /* Don't error out if another instance of dmd just created
                     * this directory
                     */
                    if (errno != EEXIST)
                        error("cannot create directory %s", path);
                }
            }
        }
    }
}
Beispiel #10
0
QString PathResolve::logPath()
{
    QString strPath = dataStorePath() + "log/";
    ensurePathExists(strPath);
    return strPath;
}
Beispiel #11
0
QDir
lastfm::dir::runtimeData()
{
    return ensurePathExists( dataDotDot().filePath( "Last.fm" ) );
}