StelFileMgr.cpp   StelFileMgr.cpp 
skipping to change at line 20 skipping to change at line 20
#ifdef WIN32 #ifdef WIN32
# include <windows.h> # include <windows.h>
# ifndef _SHOBJ_H # ifndef _SHOBJ_H
# include <shlobj.h> # include <shlobj.h>
# include <QLibrary> # include <QLibrary>
# endif # endif
#endif #endif
#ifdef MACOSX #ifdef MACOSX
#include "MacosxDirs.hpp" #include "StelMacosxDirs.hpp"
#endif #endif
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
StelFileMgr::StelFileMgr() StelFileMgr::StelFileMgr()
{ {
// Set the userDir member. // Set the userDir member.
QFileInfo userDirFI; QFileInfo userDirFI;
#if defined(WIN32) #if defined(WIN32)
QString winApiPath = getWin32SpecialDirPath(CSIDL_APPDATA); QString winApiPath = getWin32SpecialDirPath(CSIDL_APPDATA);
skipping to change at line 57 skipping to change at line 57
{ {
qWarning() << "WARNING StelFileMgr::StelFileMgr user dir is not writable: " qWarning() << "WARNING StelFileMgr::StelFileMgr user dir is not writable: "
<< userDirFI.filePath(); << userDirFI.filePath();
} }
userDir = userDirFI.filePath(); userDir = userDirFI.filePath();
// OK, now we have the userDir set, we will add it and the installat ion // OK, now we have the userDir set, we will add it and the installat ion
// dir to the search path. The user directory is first. // dir to the search path. The user directory is first.
fileLocations.append(userDir); fileLocations.append(userDir);
// then the installation directory
try try
{ {
fileLocations.append(getInstallationDir()); fileLocations.append(getInstallationDir());
} }
catch(std::exception &e) catch(std::runtime_error &e)
{ {
qWarning() << "WARNING: could not locate installation direct ory"; qWarning() << "WARNING: could not locate installation direct ory";
} }
#if defined(WIN32) || defined(CYGWIN) || defined(__MINGW32__) || defined(MI NGW32) || defined(MACOSX) #if defined(WIN32) || defined(CYGWIN) || defined(__MINGW32__) || defined(MI NGW32) || defined(MACOSX)
screenshotDir = getDesktopDir(); screenshotDir = getDesktopDir();
#else #else
screenshotDir = QDir::homePath(); screenshotDir = QDir::homePath();
#endif #endif
skipping to change at line 114 skipping to change at line 115
foreach (QString i, fileLocations) foreach (QString i, fileLocations)
{ {
if (fileFlagsCheck(i + "/" + path, flags)) if (fileFlagsCheck(i + "/" + path, flags))
return i + "/" + path; return i + "/" + path;
} }
throw(std::runtime_error(QString("file not found: %1").arg(path).toL ocal8Bit().constData())); throw(std::runtime_error(QString("file not found: %1").arg(path).toL ocal8Bit().constData()));
} }
QSet<QString> StelFileMgr::listContents(const QString& path, const StelFile Mgr::Flags& flags) QSet<QString> StelFileMgr::listContents(const QString& path, const StelFile Mgr::Flags& flags, bool recursive)
{ {
QSet<QString> result; QSet<QString> result;
QStringList listPaths; QStringList listPaths;
if (recursive)
{
QSet<QString> dirs = listContents(path, Directory, false);
result = listContents(path, flags, false); // root
// add results for each sub-directory
foreach(QString d, dirs)
{
QSet<QString> subDirResult = listContents(path + "/"
+ d, flags, true);
foreach(QString r, subDirResult)
{
result.insert(d + "/" + r);
}
}
return result;
}
// If path is "complete" (a full path), we just look in there, else // If path is "complete" (a full path), we just look in there, else
// we append relative paths to the search paths maintained by this c lass. // we append relative paths to the search paths maintained by this c lass.
if (QFileInfo(path).isAbsolute()) if (QFileInfo(path).isAbsolute())
listPaths.append(""); listPaths.append("");
else else
listPaths = fileLocations; listPaths = fileLocations;
foreach (QString li, listPaths) foreach (QString li, listPaths)
{ {
QFileInfo thisPath(li+"/"+path); QFileInfo thisPath(li+"/"+path);
skipping to change at line 189 skipping to change at line 206
bool StelFileMgr::isWritable(const QString& path) bool StelFileMgr::isWritable(const QString& path)
{ {
return QFileInfo(path).isWritable(); return QFileInfo(path).isWritable();
} }
bool StelFileMgr::isDirectory(const QString& path) bool StelFileMgr::isDirectory(const QString& path)
{ {
return QFileInfo(path).isDir(); return QFileInfo(path).isDir();
} }
qint64 StelFileMgr::size(const QString& path)
{
return QFileInfo(path).size();
}
bool StelFileMgr::mkDir(const QString& path) bool StelFileMgr::mkDir(const QString& path)
{ {
return QDir("/").mkpath(path); return QDir("/").mkpath(path);
} }
QString StelFileMgr::dirName(const QString& path) QString StelFileMgr::dirName(const QString& path)
{ {
return QFileInfo(path).dir().canonicalPath(); return QFileInfo(path).dir().canonicalPath();
} }
skipping to change at line 229 skipping to change at line 251
} }
else else
{ {
// The user directory doesn't exist, lets create it. // The user directory doesn't exist, lets create it.
if (!QDir("/").mkpath(uDir.filePath())) if (!QDir("/").mkpath(uDir.filePath()))
{ {
qCritical() << "ERROR: Could not create user directory: " << uDir.filePath(); qCritical() << "ERROR: Could not create user directory: " << uDir.filePath();
} }
} }
} }
catch(std::exception& e) catch(std::runtime_error& e)
{ {
// This should never happen ;) // This should never happen ;)
qCritical() << "ERROR: cannot work out the user directory: " << e.what(); qCritical() << "ERROR: cannot work out the user directory: " << e.what();
} }
} }
bool StelFileMgr::fileFlagsCheck(const QString& path, const Flags& flags) bool StelFileMgr::fileFlagsCheck(const QString& path, const Flags& flags)
{ {
if ( ! (flags & Hidden) ) if ( ! (flags & Hidden) )
{ {
 End of changes. 7 change blocks. 
4 lines changed or deleted 27 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/